@Test public void shouldGetWsdl() throws Exception { mockServer.stubFor(WireMock.any(urlPathEqualTo(EXPECTED_WSDL_QUERY_PATH)) .willReturn(aResponse() .withBodyFile("wsdl_response.xml") .withHeader(HttpHeaders.CONTENT_TYPE, MULTIPART_RELATED + "; type=\"text/xml\"; charset=UTF-8; boundary=xroadZTLLyIMMYnAYliBumWCqHJYAhutxNf"))); mockServer.start(); final SecurityServerId providedIdentifier = SecurityServerId.create(EXPECTED_XR_INSTANCE, "memberClassGov", "memberCode11", "serverCode_"); ServerConf.reload(new TestServerConf() { @Override public SecurityServerId getIdentifier() { return providedIdentifier; } }); final ServiceId expectedServiceId = ServiceId.create(EXPECTED_XR_INSTANCE, "someMember", "serviceCode3322", "subsystem3", "serviceCode3", "version1.1"); when(mockRequest.getParameter(eq(WsdlRequestProcessor.PARAM_INSTANCE_IDENTIFIER))) .thenReturn(expectedServiceId.getXRoadInstance()); when(mockRequest.getParameter(eq(WsdlRequestProcessor.PARAM_MEMBER_CLASS))) .thenReturn(expectedServiceId.getMemberClass()); when(mockRequest.getParameter(eq(WsdlRequestProcessor.PARAM_MEMBER_CODE))) .thenReturn(expectedServiceId.getMemberCode()); when(mockRequest.getParameter(eq(WsdlRequestProcessor.PARAM_SERVICE_CODE))) .thenReturn(expectedServiceId.getServiceCode()); when(mockRequest.getParameter(eq(WsdlRequestProcessor.PARAM_SUBSYSTEM_CODE))) .thenReturn(expectedServiceId.getSubsystemCode()); when(mockRequest.getParameter(eq(WsdlRequestProcessor.PARAM_VERSION))) .thenReturn(expectedServiceId.getServiceVersion()); final List<String> expectedWSDLServiceNames = Arrays.asList("getRandom", "helloService"); WsdlRequestProcessor processorToTest = new WsdlRequestProcessor(mockRequest, mockResponse); processorToTest.process(); assertContentTypeIsIn(singletonList(TEXT_XML)); Definition definition = WSDLFactory.newInstance().newWSDLReader() .readWSDL(null, new InputSource(mockServletOutputStream.getAsInputStream())); List<String> operationNames = parseOperationNamesFromWSDLDefinition(definition); assertThat("Expected to find certain operations", operationNames, containsInAnyOrder(expectedWSDLServiceNames.toArray())); }
void process() throws Exception { ClientId client = ServerConf.getIdentifier().getOwner(); ServiceId service = getServiceId(); log.trace("process({}, {})", client, service); SoapMessageImpl message = createMessage(client, service); if (log.isTraceEnabled()) { log.trace("message:\n{}", message.getXml()); } HttpURLConnection connection = createConnection(message); try (InputStream in = connection.getInputStream(); SoapDecoderCallback callback = new SoapDecoderCallback()) { SoapMessageDecoder decoder = new SoapMessageDecoder(connection.getContentType(), callback); decoder.parse(in); } }
WsdlRequestProcessor { void process() throws Exception { ClientId client = ServerConf.getIdentifier().getOwner(); ServiceId service = getServiceId(); log.trace("process({}, {})", client, service); SoapMessageImpl message = createMessage(client, service); if (log.isTraceEnabled()) { log.trace("message:\n{}", message.getXml()); } HttpURLConnection connection = createConnection(message); try (InputStream in = connection.getInputStream(); SoapDecoderCallback callback = new SoapDecoderCallback()) { SoapMessageDecoder decoder = new SoapMessageDecoder(connection.getContentType(), callback); decoder.parse(in); } } }
WsdlRequestProcessor { void process() throws Exception { ClientId client = ServerConf.getIdentifier().getOwner(); ServiceId service = getServiceId(); log.trace("process({}, {})", client, service); SoapMessageImpl message = createMessage(client, service); if (log.isTraceEnabled()) { log.trace("message:\n{}", message.getXml()); } HttpURLConnection connection = createConnection(message); try (InputStream in = connection.getInputStream(); SoapDecoderCallback callback = new SoapDecoderCallback()) { SoapMessageDecoder decoder = new SoapMessageDecoder(connection.getContentType(), callback); decoder.parse(in); } }  }
WsdlRequestProcessor { void process() throws Exception { ClientId client = ServerConf.getIdentifier().getOwner(); ServiceId service = getServiceId(); log.trace("process({}, {})", client, service); SoapMessageImpl message = createMessage(client, service); if (log.isTraceEnabled()) { log.trace("message:\n{}", message.getXml()); } HttpURLConnection connection = createConnection(message); try (InputStream in = connection.getInputStream(); SoapDecoderCallback callback = new SoapDecoderCallback()) { SoapMessageDecoder decoder = new SoapMessageDecoder(connection.getContentType(), callback); decoder.parse(in); } }   }
WsdlRequestProcessor { void process() throws Exception { ClientId client = ServerConf.getIdentifier().getOwner(); ServiceId service = getServiceId(); log.trace("process({}, {})", client, service); SoapMessageImpl message = createMessage(client, service); if (log.isTraceEnabled()) { log.trace("message:\n{}", message.getXml()); } HttpURLConnection connection = createConnection(message); try (InputStream in = connection.getInputStream(); SoapDecoderCallback callback = new SoapDecoderCallback()) { SoapMessageDecoder decoder = new SoapMessageDecoder(connection.getContentType(), callback); decoder.parse(in); } }   static final String PARAM_INSTANCE_IDENTIFIER; static final String PARAM_MEMBER_CLASS; static final String PARAM_MEMBER_CODE; static final String PARAM_SERVICE_CODE; }