List of usage examples for javax.xml.soap SOAPMessage getSOAPHeader
public SOAPHeader getSOAPHeader() throws SOAPException
From source file:ee.ria.xroad.proxy.serverproxy.ProxyMonitorServiceHandlerTest.java
/** * As above but only environmental parameters defined in outputSpec. * * @throws Exception/*from ww w.j av a2 s . c o m*/ */ @Test public void startHandingShouldProduceRequestedMetrics() throws Exception { // setup ProxyMonitorServiceHandlerImpl handlerToTest = new ProxyMonitorServiceHandlerImpl(); final SoapMessageImpl soapMessage = build(false, DEFAULT_OWNER_CLIENT, MONITOR_SERVICE_ID, "testUser", randomUUID().toString(), new MetricsQueryBuilder(Arrays.asList("proxyVersion", "CommittedVirtualMemory", "DiskSpaceFree"))); when(mockProxyMessage.getSoap()).thenReturn(soapMessage); when(mockProxyMessage.getSoapContent()) .thenReturn(new ByteArrayInputStream(soapMessage.getXml().getBytes(soapMessage.getCharset()))); handlerToTest.canHandle(MONITOR_SERVICE_ID, mockProxyMessage); final String expectedMetricsSetName = "someName"; MetricSetType metricSetType = new MetricSetType(); metricSetType.setName(expectedMetricsSetName); final List<MetricType> metrics = metricSetType.getMetrics(); StringMetricType type = new StringMetricType(); final String expectedMetricName = "metricName123-23"; type.setName(expectedMetricName); final String expectedMetricValue = "123SomeValue"; type.setValue(expectedMetricValue); metrics.add(type); MonitorClient mockMonitorClient = PowerMockito.mock(MonitorClient.class); PowerMockito.when(mockMonitorClient.getMetrics(org.mockito.Matchers.anyList())).thenReturn(metricSetType); RestoreMonitorClientAfterTest.setMonitorClient(mockMonitorClient); // execution handlerToTest.startHandling(mockRequest, mockProxyMessage, mock(HttpClient.class), mock(OpMonitoringData.class)); //verification assertThat("Wrong content type", handlerToTest.getResponseContentType(), is(TEXT_XML_UTF8)); final SOAPMessage message = messageFactory.createMessage(null, handlerToTest.getResponseContent()); final SoapHeader xrHeader = unmarshaller.unmarshal(message.getSOAPHeader(), SoapHeader.class).getValue(); assertThat("Response client does not match", xrHeader.getClient(), is(DEFAULT_OWNER_CLIENT)); assertThat("Response client does not match", xrHeader.getService(), is(MONITOR_SERVICE_ID)); final MetricSetType root = verifyAndGetSingleBodyElementOfType(message.getSOAPBody(), GetSecurityServerMetricsResponse.class, () -> unmarshaller).getMetricSet(); // root metrics should have the security server id as name assertThat("Metrics set name does not match", root.getName(), is(DEFAULT_OWNER_SERVER.toString())); final List<MetricType> responseMetrics = root.getMetrics(); assertThat("Missing proxy version from metrics", responseMetrics, hasItem(hasProperty("name", is("proxyVersion")))); assertThat("Missing the expected metrics set", responseMetrics, hasItem(instanceOf(MetricSetType.class))); final MetricSetType responseDataMetrics = (MetricSetType) responseMetrics.stream() // we just asserted this.. .filter(m -> m instanceof MetricSetType).findFirst().orElseThrow(IllegalStateException::new); assertThat(responseDataMetrics.getName(), is(expectedMetricsSetName)); assertThat(responseDataMetrics.getMetrics().size(), is(1)); final StringMetricType responseMetric = (StringMetricType) responseDataMetrics.getMetrics().get(0); assertThat("Wrong metric name", responseMetric.getName(), is(expectedMetricName)); assertThat("Wrong metric value", responseMetric.getValue(), is(expectedMetricValue)); }
From source file:com.googlecode.ddom.saaj.SOAPMessageTest.java
/** * Tests the behavior of {@link SOAPMessage#getSOAPHeader()} after removing the header from the * message. Note that the SAAJ specification requires the implementation to throw an exception * in this case. However, the reference implementation simply returns <code>null</code> (see * also <a href="http://java.net/jira/browse/SAAJ-15">SAAJ-15</a>). We stick to the behavior of * the reference implementation./*from www . j a va 2 s . com*/ * * @throws Exception */ @Validated @Test public void testGetSOAPHeaderWithNoHeader() throws Exception { SOAPMessage message = getFactory().createMessage(); SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); // Remove the SOAP header (created by default by MessageFactory) using plain DOM methods Node child = envelope.getFirstChild(); while (child != null) { if (child instanceof Element && ((Element) child).getLocalName().equals("Header")) { envelope.removeChild(child); break; } } assertNull(message.getSOAPHeader()); }
From source file:ee.ria.xroad.proxy.serverproxy.MetadataServiceHandlerTest.java
@Test public void shouldHandleListMethods() throws Exception { // setup// ww w . jav a2 s . c om List<ServiceId> expectedServices = Arrays.asList(ServiceId.create(DEFAULT_CLIENT, "getNumber"), ServiceId.create(DEFAULT_CLIENT, "helloThere"), ServiceId.create(DEFAULT_CLIENT, "putThings")); final ClientId expectedClient = DEFAULT_CLIENT; final ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, LIST_METHODS); ServerConf.reload(new TestServerConf() { @Override public List<ServiceId> getAllServices(ClientId serviceProvider) { assertThat("Client id does not match expected", serviceProvider, is(expectedClient)); return expectedServices; } }); MetadataServiceHandlerImpl handlerToTest = new MetadataServiceHandlerImpl(); InputStream soapContentInputStream = new TestSoapBuilder().withClient(DEFAULT_CLIENT).withService(serviceId) .withModifiedBody( soapBody -> soapBody.addChildElement(LIST_METHODS_REQUEST).addChildElement(REQUEST)) .buildAsInputStream(); when(mockProxyMessage.getSoapContent()).thenReturn(soapContentInputStream); handlerToTest.canHandle(serviceId, mockProxyMessage); // execution handlerToTest.startHandling(mockRequest, mockProxyMessage, httpClientMock, mock(OpMonitoringData.class)); // verification assertThat("Content type does not match", handlerToTest.getResponseContentType(), is(TEXT_XML_UTF8)); final SOAPMessage message = messageFactory.createMessage(null, handlerToTest.getResponseContent()); final SoapHeader xrHeader = unmarshaller.unmarshal(message.getSOAPHeader(), SoapHeader.class).getValue(); List<ServiceId> resultServices = verifyAndGetSingleBodyElementOfType(message.getSOAPBody(), MethodListType.class).getService(); assertThat("Response client does not match", xrHeader.getClient(), is(expectedClient)); assertThat("Response client does not match", xrHeader.getService(), is(serviceId)); assertThat("Wrong amount of services", resultServices.size(), is(expectedServices.size())); assertThat("Wrong services", resultServices, containsInAnyOrder(expectedServices.toArray())); }
From source file:ee.ria.xroad.proxy.serverproxy.MetadataServiceHandlerTest.java
@Test public void shouldHandleAllowedMethods() throws Exception { // setup/*w ww . j a v a 2 s . c o m*/ List<ServiceId> expectedServices = Arrays.asList(ServiceId.create(DEFAULT_CLIENT, "getNumber"), ServiceId.create(DEFAULT_CLIENT, "helloThere"), ServiceId.create(DEFAULT_CLIENT, "putThings")); final ClientId expectedClient = DEFAULT_CLIENT; final ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, ALLOWED_METHODS); ServerConf.reload(new TestServerConf() { @Override public List<ServiceId> getAllowedServices(ClientId serviceProvider, ClientId client) { assertThat("Wrong client in query", client, is(expectedClient)); assertThat("Wrong service provider in query", serviceProvider, is(serviceId.getClientId())); return expectedServices; } }); MetadataServiceHandlerImpl handlerToTest = new MetadataServiceHandlerImpl(); InputStream soapContentInputStream = new TestSoapBuilder().withClient(DEFAULT_CLIENT).withService(serviceId) .withModifiedBody( soapBody -> soapBody.addChildElement(ALLOWED_METHODS_REQUEST).addChildElement(REQUEST)) .buildAsInputStream(); when(mockProxyMessage.getSoapContent()).thenReturn(soapContentInputStream); handlerToTest.canHandle(serviceId, mockProxyMessage); // execution handlerToTest.startHandling(mockRequest, mockProxyMessage, httpClientMock, mock(OpMonitoringData.class)); // verification assertThat("Content type does not match", handlerToTest.getResponseContentType(), is(TEXT_XML_UTF8)); final SOAPMessage message = messageFactory.createMessage(null, handlerToTest.getResponseContent()); final SoapHeader xrHeader = unmarshaller.unmarshal(message.getSOAPHeader(), SoapHeader.class).getValue(); List<ServiceId> resultServices = verifyAndGetSingleBodyElementOfType(message.getSOAPBody(), MethodListType.class).getService(); assertThat("Response client does not match", xrHeader.getClient(), is(expectedClient)); assertThat("Response client does not match", xrHeader.getService(), is(serviceId)); assertThat("Wrong amount of services", resultServices.size(), is(expectedServices.size())); assertThat("Wrong services", resultServices, containsInAnyOrder(expectedServices.toArray())); }
From source file:com.jkoolcloud.tnt4j.streams.custom.inputs.CastIronWsStream.java
/** * Appends SOAP request message with {@code "sessionId"} header having token received from scenario {@code "login"} * step and saved in streams cache./* w ww . j ava 2 s . c o m*/ * * @param soapRequest * SOAP request message instance * @throws javax.xml.soap.SOAPException * if there was an error adding the SOAP message header */ @Override protected void addSoapHeaders(SOAPMessage soapRequest) throws SOAPException { SOAPFactory soapFactory = SOAPFactory.newInstance(); SOAPElement sessionIdElem = soapFactory.createElement("sessionId", "sec", // NON-NLS "http://www.approuter.com/schemas/2008/1/security"); // NON-NLS String cachedToken = String.valueOf(StreamsCache.getValue(tokenCacheKey)); logger().log(OpLevel.DEBUG, StreamsResources.getBundle(WsStreamConstants.RESOURCE_BUNDLE_NAME), "CastIronStream.adding.req.header", sessionIdElem.getLocalName(), cachedToken); sessionIdElem.setTextContent(cachedToken); soapRequest.getSOAPHeader().addChildElement(sessionIdElem); }
From source file:eu.domibus.ebms3.sender.ReliabilityChecker.java
public boolean check(SOAPMessage request, SOAPMessage response, String pmodeKey) throws EbMS3Exception { LegConfiguration legConfiguration = this.pModeProvider.getLegConfiguration(pmodeKey); assert legConfiguration != null; // we would have crashed in the security handler if (legConfiguration.getReliability() != null && ReplyPattern.RESPONSE.equals(legConfiguration.getReliability().getReplyPattern())) { ReliabilityChecker.LOG.debug("Checking reliability for outgoing message"); Messaging messaging;/*from w w w .java 2 s .c o m*/ try { messaging = this.jaxbContext .createUnmarshaller().unmarshal((Node) response.getSOAPHeader() .getChildElements(ObjectFactory._Messaging_QNAME).next(), Messaging.class) .getValue(); } catch (JAXBException | SOAPException e) { ReliabilityChecker.LOG.error(e.getMessage(), e); return false; } SignalMessage signalMessage = messaging.getSignalMessage(); //ReceiptionAwareness or NRR found but not expected? report if configuration=true //TODO: make configurable in domibus.properties //SignalMessage with Receipt expected if (signalMessage.getReceipt() != null && signalMessage.getReceipt().getAny().size() == 1) { String contentOfReceiptString = signalMessage.getReceipt().getAny().get(0); try { if (!legConfiguration.getReliability().isNonRepudiation()) { UserMessage userMessage = this.jaxbContext.createUnmarshaller() .unmarshal( new StreamSource( new ByteArrayInputStream(contentOfReceiptString.getBytes())), UserMessage.class) .getValue(); UserMessage userMessageInRequest = this.jaxbContext.createUnmarshaller() .unmarshal( (Node) request.getSOAPHeader() .getChildElements(ObjectFactory._Messaging_QNAME).next(), Messaging.class) .getValue().getUserMessage(); return userMessage.equals(userMessageInRequest); } Iterator<Element> elementIterator = response.getSOAPHeader() .getChildElements(new QName(WSConstants.WSSE_NS, WSConstants.WSSE_LN)); if (!elementIterator.hasNext()) { throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0302, "Invalid NonRepudiationInformation: No security header found", null, MSHRole.SENDING); } Element securityHeaderResponse = elementIterator.next(); if (elementIterator.hasNext()) { throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0302, "Invalid NonRepudiationInformation: Multiple security headers found", null, MSHRole.SENDING); } String wsuIdOfMEssagingElement = messaging.getOtherAttributes() .get(new QName(WSConstants.WSU_NS, "Id")); ReliabilityChecker.LOG.debug(wsuIdOfMEssagingElement); NodeList nodeList = securityHeaderResponse.getElementsByTagNameNS(WSConstants.SIG_NS, WSConstants.REF_LN); boolean signatureFound = false; for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (this.compareReferenceIgnoreHashtag( node.getAttributes().getNamedItem("URI").getNodeValue(), wsuIdOfMEssagingElement)) { signatureFound = true; break; } } if (!signatureFound) { throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0302, "Invalid NonRepudiationInformation: eb:Messaging not signed", null, MSHRole.SENDING); } NodeList referencesFromSecurityHeader = this.getNonRepudiationNodeList(request.getSOAPHeader() .getElementsByTagNameNS(WSConstants.SIG_NS, WSConstants.SIG_LN).item(0)); NodeList referencesFromNonRepudiationInformation = this.getNonRepudiationNodeList(response .getSOAPHeader() .getElementsByTagNameNS(NonRepudiationConstants.NS_NRR, NonRepudiationConstants.NRR_LN) .item(0)); if (!this.compareUnorderedReferenceNodeLists(referencesFromSecurityHeader, referencesFromNonRepudiationInformation)) { throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0302, "Invalid NonRepudiationInformation: non repudiation information and request message do not match", null, MSHRole.SENDING); } return true; } catch (JAXBException e) { ReliabilityChecker.LOG.error("", e); } catch (SOAPException e) { ReliabilityChecker.LOG.error("", e); } } else { throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0302, "There is no content inside the receipt element received by the responding gateway", signalMessage.getMessageInfo().getMessageId(), signalMessage.getMessageInfo().getMessageId(), null, MSHRole.SENDING); } } return false; }
From source file:com.centurylink.mdw.hub.servlet.SoapServlet.java
/** * Allow version specific factory passed in to support SOAP 1.1 and 1.2 * <b>Important</b> Faults are treated differently for 1.1 and 1.2 For 1.2 * you can't use the elementName otherwise it throws an exception * * @see http://docs.oracle.com/cd/E19159-01/819-3669/bnbip/index.html * * @param factory//from w w w . j a v a2 s .c om * @param code * @param message * @return Xml fault string * @throws SOAPException * @throws TransformerException */ protected String createSoapFaultResponse(String soapVersion, String code, String message) throws SOAPException, TransformerException { SOAPMessage soapMessage = getSoapMessageFactory(soapVersion).createMessage(); SOAPBody soapBody = soapMessage.getSOAPBody(); /** * Faults are treated differently for 1.1 and 1.2 For 1.2 you can't use * the elementName otherwise it throws an exception * * @see http://docs.oracle.com/cd/E19159-01/819-3669/bnbip/index.html */ SOAPFault fault = null; if (soapVersion.equals(SOAPConstants.SOAP_1_1_PROTOCOL)) { // existing 1.1 functionality fault = soapBody.addFault(soapMessage.getSOAPHeader().getElementName(), message); if (code != null) fault.setFaultCode(code); } else if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) { /** * For 1.2 there are only a set number of allowed codes, so we can't * just use any one like what we did in 1.1. The recommended one to * use is SOAPConstants.SOAP_RECEIVER_FAULT */ fault = soapBody.addFault(SOAPConstants.SOAP_RECEIVER_FAULT, code == null ? message : code + " : " + message); } return DomHelper.toXml(soapMessage.getSOAPPart().getDocumentElement()); }
From source file:com.novartis.opensource.yada.adaptor.SOAPAdaptor.java
/** * Constructs and executes a SOAP message. For {@code basic} authentication, YADA uses the * java soap api, and the {@link SOAPConnection} object stored in the query object. For * NTLM, which was never successful using the java api, YADA calls out to {@link #CURL_EXEC} * in {@link #YADA_BIN}. // w w w .j a va 2 s . c o m * @see com.novartis.opensource.yada.adaptor.Adaptor#execute(com.novartis.opensource.yada.YADAQuery) */ @Override public void execute(YADAQuery yq) throws YADAAdaptorExecutionException { String result = ""; resetCountParameter(yq); SOAPConnection connection = (SOAPConnection) yq.getConnection(); for (int row = 0; row < yq.getData().size(); row++) { yq.setResult(); YADAQueryResult yqr = yq.getResult(); String soapUrl = yq.getSoap(row); try { this.endpoint = new URL(soapUrl); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(); byte[] authenticationToken = Base64.encodeBase64((this.soapUser + ":" + this.soapPass).getBytes()); // Assume a SOAP message was built previously MimeHeaders mimeHeaders = message.getMimeHeaders(); if ("basic".equals(this.soapAuth.toLowerCase())) { mimeHeaders.addHeader("Authorization", this.soapAuth + " " + new String(authenticationToken)); mimeHeaders.addHeader("SOAPAction", this.soapAction); mimeHeaders.addHeader("Content-Type", "text/xml"); SOAPHeader header = message.getSOAPHeader(); SOAPBody body = message.getSOAPBody(); header.detachNode(); l.debug("query:\n" + this.queryString); try { Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new ByteArrayInputStream(this.soapData.getBytes())); //SOAPBodyElement docElement = body.addDocument(xml); Authenticator.setDefault(new YadaSoapAuthenticator(this.soapUser, this.soapPass)); SOAPMessage response = connection.call(message, this.endpoint); try (ByteArrayOutputStream responseOutputStream = new ByteArrayOutputStream()) { response.writeTo(responseOutputStream); result = responseOutputStream.toString(); } } catch (IOException e) { String msg = "Unable to process input or output stream for SOAP message with Basic Authentication. This is an I/O problem, not an authentication issue."; throw new YADAAdaptorExecutionException(msg, e); } l.debug("SOAP Body:\n" + result); } else if (AUTH_NTLM.equals(this.soapAuth.toLowerCase()) || "negotiate".equals(this.soapAuth.toLowerCase())) { ArrayList<String> args = new ArrayList<>(); args.add(Finder.getEnv(YADA_BIN) + CURL_EXEC); args.add("-X"); args.add("-s"); args.add(this.soapSource + this.soapPath); args.add("-u"); args.add(this.soapDomain + "\\" + this.soapUser); args.add("-p"); args.add(this.soapPass); args.add("-a"); args.add(this.soapAuth); args.add("-q"); args.add(this.soapData); args.add("-t"); args.add(this.soapAction); String[] cmds = args.toArray(new String[0]); l.debug("Executing soap request via script: " + Arrays.toString(cmds)); String s = null; try { ProcessBuilder pb = new ProcessBuilder(args); l.debug(pb.environment().toString()); pb.redirectErrorStream(true); Process p = pb.start(); try (BufferedReader si = new BufferedReader(new InputStreamReader(p.getInputStream()))) { while ((s = si.readLine()) != null) { l.debug(s); if (null == result) { result = ""; } result += s; } } } catch (IOException e) { String msg = "Unable to execute NTLM-authenticated SOAP call using system call to 'curl'. Make sure the curl executable is still accessible."; throw new YADAAdaptorExecutionException(msg, e); } } } catch (SOAPException e) { String msg = "There was a problem creating or executing the SOAP message, or receiving the response."; throw new YADAAdaptorExecutionException(msg, e); } catch (SAXException e) { String msg = "Unable to parse SOAP message body."; throw new YADAAdaptorExecutionException(msg, e); } catch (ParserConfigurationException e) { String msg = "There was a problem creating the xml document for the SOAP message body."; throw new YADAAdaptorExecutionException(msg, e); } catch (YADAResourceException e) { String msg = "Cannot find 'curl' executable at specified JNDI path " + YADA_BIN + CURL_EXEC; throw new YADAAdaptorExecutionException(msg, e); } catch (MalformedURLException e) { String msg = "Can't create URL from provided source and path."; throw new YADAAdaptorExecutionException(msg, e); } finally { try { ConnectionFactory.releaseResources(connection, yq.getSoap().get(0)); } catch (YADAConnectionException e) { l.error(e.getMessage()); } } yqr.addResult(row, result); } }
From source file:eu.domibus.ebms3.sender.EbMS3MessageBuilder.java
public SOAPMessage buildSOAPMessage(UserMessage userMessage, SignalMessage signalMessage, LegConfiguration leg) throws EbMS3Exception { String messageId = null;//from ww w . j a va2 s . c o m SOAPMessage message; try { message = this.messageFactory.createMessage(); final Messaging messaging = this.ebMS3Of.createMessaging(); if (userMessage != null) { if (userMessage.getMessageInfo() != null && userMessage.getMessageInfo().getTimestamp() == null) { userMessage.getMessageInfo().setTimestamp(new Date()); } messageId = userMessage.getMessageInfo().getMessageId(); messaging.setUserMessage(userMessage); for (PartInfo partInfo : userMessage.getPayloadInfo().getPartInfo()) { this.attachPayload(partInfo, message); } } if (signalMessage != null) { MessageInfo msgInfo = new MessageInfo(); messageId = this.messageIdGenerator.generateMessageId(); msgInfo.setMessageId(messageId); msgInfo.setTimestamp(new Date()); signalMessage.setMessageInfo(msgInfo); } messaging.setSignalMessage(signalMessage); this.jaxbContext.createMarshaller().marshal(messaging, message.getSOAPHeader()); message.saveChanges(); } catch (final SAXParseException e) { throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0001, "Payload in body must be valid XML", messageId, e, null); } catch (final JAXBException | SOAPException | ParserConfigurationException | IOException | SAXException ex) { throw new SendMessageException(ex); } return message; }
From source file:com.nortal.jroad.endpoint.AbstractXTeeBaseEndpoint.java
@SuppressWarnings("unchecked") protected SOAPElement createXteeMessageStructure(SOAPMessage requestMessage, SOAPMessage responseMessage) throws Exception { SOAPUtil.addBaseMimeHeaders(responseMessage); SOAPUtil.addBaseNamespaces(responseMessage); if (!metaService) { // Assign xroad namespaces according to request List<String> xteeNamespaces = new ArrayList<String>(); xteeNamespaces.add(version.getNamespaceUri()); if (XRoadProtocolVersion.V4_0 == version) { xteeNamespaces.add(XTeeWsdlDefinition.XROAD_IDEN_NAMESPACE); }/*w w w . j a v a 2 s .co m*/ Iterator<String> prefixes = requestMessage.getSOAPPart().getEnvelope().getNamespacePrefixes(); while (prefixes.hasNext()) { String nsPrefix = (String) prefixes.next(); String nsURI = requestMessage.getSOAPPart().getEnvelope().getNamespaceURI(nsPrefix).toLowerCase(); if (xteeNamespaces.contains(nsURI)) { SOAPUtil.addNamespace(responseMessage, nsPrefix, nsURI); } } // Copy headers from request NodeList reqHeaders = requestMessage.getSOAPHeader().getChildNodes(); for (int i = 0; i < reqHeaders.getLength(); i++) { Node reqHeader = reqHeaders.item(i); if (reqHeader.getNodeType() != Node.ELEMENT_NODE) { continue; } Node rspHeader = responseMessage.getSOAPPart().importNode(reqHeader, true); responseMessage.getSOAPHeader().appendChild(rspHeader); } } responseMessage.getSOAPPart().getEnvelope().setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/"); Node teenusElement = SOAPUtil.getFirstNonTextChild(requestMessage.getSOAPBody()); if (teenusElement.getPrefix() == null || teenusElement.getNamespaceURI() == null) { throw new IllegalStateException("Service request is missing namespace."); } SOAPUtil.addNamespace(responseMessage, teenusElement.getPrefix(), teenusElement.getNamespaceURI()); String teenusElementName = teenusElement.getLocalName(); if (teenusElementName.endsWith(SuffixBasedMessagesProvider.DEFAULT_REQUEST_SUFFIX)) { teenusElementName = teenusElementName.substring(0, teenusElementName.lastIndexOf(SuffixBasedMessagesProvider.DEFAULT_REQUEST_SUFFIX)); } teenusElementName += SuffixBasedMessagesProvider.DEFAULT_RESPONSE_SUFFIX; return responseMessage.getSOAPBody().addChildElement(teenusElementName, teenusElement.getPrefix(), teenusElement.getNamespaceURI()); }