JAXB: default namespace declared in SOAP Envelop is not recognized in Body's xsi:type while unmarshalling - soap

Below is a pseudo soap response coming from the server as below.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn://tsys.com/xmlmessaging/T1">
<soap:Header>
<Header details/>
</soap:Header>
<soap:Body>
<inqMultiResponse>
<inqMultiResult status="000" statusMsg="passed" >
<inquireResult xsi:type="inqCustAddrResponseType" >
<addrInfo>
<addrType>Primary</addrType>
....
<x_4.0.0/>
</addrInfo>
</inquireResult>
<inquireResult xsi:type="inqGeneralAcctResponseType" status="000" statusMsg="passed">
<acctGeneralInfo>
<type>Z</type>
....
</stmtInfo>
<x_4.4.0/>
</acctGeneralInfo>
</inquireResult>
</inqMultiResult>
</inqMultiResponse>
</soap:Body>
While unmarshalling the xml using JAXB's Jaxb2Marshaller, i get the following exception in my EventHandler.
EVENT
SEVERITY: 1
MESSAGE: unrecognized type name: inqCustAddrResponseType. Did you mean {urn://tsys.com/xmlmessaging/T1}inqCustAddrResponseType?
LINKED EXCEPTION: null
LOCATOR
LINE NUMBER: -1
COLUMN NUMBER: -1
OFFSET: -1
OBJECT: null
NODE: [inquireResult: null]
URL: null
EVENT
SEVERITY: 2
MESSAGE: Unable to create an instance of com.tsys.xmlmessaging.t1.TSYSInquiryResponseType
LINKED EXCEPTION: java.lang.InstantiationException
LOCATOR
LINE NUMBER: -1
COLUMN NUMBER: -1
OFFSET: -1
OBJECT: null
NODE: [inquireResult: null]
URL: null
Below is my spring configuration.
<bean id="tsysTransactionMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="validationEventHandler" ref="validationEventHandler" />
<property name="contextPaths">
<list>
<value>com.tsys.xmlmessaging.t1</value>
</list>
</property>
</bean>
Request you to pls help me unmarshall the xml.
I have gone through various suggestions like
JAXB xsi:type subclass unmarshalling not working
and Blaise D blogs, but none of them talk of using it with Jaxb2Marshaller as in my case.
Please note,
- The classes are generated using XJC. Not including here to ensure that i dont clutter with unnecessary information. let me know if more info is required.
- We are not having any control on the xml soap response sent from server and hence we may not be able to change them.

Related

Apache Camel invoke SOAP service cast problem

I am new in Apache Camel and I use Red Hat CodeReady Studio 12.16.0.GA. I want invoke soap web service. I have used this example https://tomd.xyz/camel-consume-soap-service/
This is my camel context file
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel-cxf="http://camel.apache.org/schema/cxf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring https://camel.apache.org/schema/spring/camel-spring.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<bean class="org.apache.cxf.transport.common.gzip.GZIPInInterceptor" id="gZipInInterceptor"/>
<bean
class="org.apache.cxf.transport.common.gzip.GZIPOutInterceptor" id="gZipOutInterceptor"/>
<camel-cxf:cxfEndpoint
address="http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso"
id="fullCountryInfoResponseClient" serviceClass="org.oorsprong.websamples_countryinfo.CountryInfoServiceSoapType">
<camel-cxf:inInterceptors>
<ref bean="gZipInInterceptor"/>
</camel-cxf:inInterceptors>
<camel-cxf:outInterceptors>
<ref bean="gZipOutInterceptor"/>
</camel-cxf:outInterceptors>
</camel-cxf:cxfEndpoint>
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="bean-66d2672d-c6c0-4984-bc31-90bc30bfaaef"/>
<camelContext id="camel"
xmlns="http://camel.apache.org/schema/spring" xmlns:order="http://fabric8.com/examples/order/v7">
<route id="simple-route">
<from id="_to2" uri="timer:timerName?delay=0&repeatCount=1"/>
<setBody id="_setBody2">
<constant>"US"</constant>
</setBody>
<bean beanType="com.example.GetFullCountryInfoBuilder"
id="_bean1" method="getFullCountryInfo"/>
<setHeader headerName="operationNamespace" id="_setHeader1">
<constant>http://www.oorsprong.org/websamples.countryinfo</constant>
</setHeader>
<setHeader headerName="operationName" id="_setHeader2">
<constant>FullCountryInfo</constant>
</setHeader>
<to id="_to1" uri="cxf:bean:fullCountryInfoResponseClient"/>
<bean beanType="com.example.GetFullCountryInfoBuilder"
id="_bean2" method="getFullCountryInfoOutput"/>
<log id="_log1" message=">>>${body}"/>
</route>
</camelContext>
</beans>
this is my input bean
public class GetFullCountryInfoBuilder {
public GetFullCountryInfoBuilder() {}
#Bean
public FullCountryInfo getFullCountryInfo(#Body String id) {
FullCountryInfo request = new FullCountryInfo();
request.setSCountryISOCode(id);
return request;
}
#Bean
public String getFullCountryInfoOutput(#Body FullCountryInfoResponse response) {
String ret = response.getFullCountryInfoResult().getSName() + " - " + response.getFullCountryInfoResult().getSCapitalCity() + " - " + response.getFullCountryInfoResult().getSCurrencyISOCode();
return ret;
}
}
Still get error org.apache.cxf.interceptor.Fault: org.oorsprong.websamples.FullCountryInfo cannot be cast to java.lang.String
It looks like CXF don't handle FullCountryInfo object but String and Camel tries to convert it.
When I change return of getFullCountryInfo to String this exception disappear but couple of another come in.
Caused by: org.apache.camel.InvalidPayloadException: No body available of type: org.oorsprong.websamples.FullCountryInfoResponse but has value: [org.oorsprong.websamples.TCountryInfo#3c5110df] of type: org.apache.cxf.message.MessageContentsList on: Message[].
Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.oorsprong.websamples.FullCountryInfoResponse with value [org.oorsprong.websamples.TCountryInfo#3c5110df]] Caused by: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.oorsprong.websamples.FullCountryInfoResponse with value [org.oorsprong.websamples.TCountryInfo#3c5110df]. Exchange[ID-sw70-1599555257341-0-1].
So input for CXF is not an object as is described in example but string.
Output of CXF is org.apache.cxf.message.MessageContentsList that you have to convert to string to log it. I have used getFullCountryInfoOutput bean in this case.

Apache Camel How to pass SOAP message from JMS queue to CXF endpoint

I am trying to create a Camel route that will:
Get JMS messages from a queue, the message body is a SOAP request.
Send the message to a cxf endpoint.
Put the response onto a response queue.
This is my code:
private void setupRequestRoute() {
from("jms:queue:input")
.setHeader(CxfConstants.OPERATION_NAME, simple("XXXXXX"))
.setHeader(CxfConstants.OPERATION_NAMESPACE, simple("XXXXXX"))
.log("Route headers : ${headers}")
.to("cxf:bean:myEndpoint")
.to("jms:queue:response")
.end();
}
Endpoint configuration:
<cxf:cxfEndpoint id="myServiceEndpoint"
address="http://localhost:8080/MyService/V2"
wsdlURL="schemas/MyService.wsdl"
xmlns:c="http://xxxx.xxxx/xxxxxxxx/XXX/MyService/V2">
<cxf:outFaultInterceptors>
<ref bean="interceptor.out.soap.fault"/>
</cxf:outFaultInterceptors>
<cxf:properties>
<entry key="schema-validation-enabled" value="true" />
<entry key="dataFormat" value="PAYLOAD" />
<entry key="defaultBus" value="true" />
<entry key="allowStreaming" value="false" />
</cxf:properties>
</cxf:cxfEndpoint>
I feel I've misunderstood something fundamental about camel works in this scenario. It appears to be the presence of the soap envelope that is causing this issue. I had presumed that camel would be able to take the raw soap message and convert it to the correct message format for the cxf endpoint.
Could someone explain to me how I can pass the SOAP request to the CXF endpoint?
2018-12-03 12:27:32,222 | ERROR | INPUT] | DefaultErrorHandler | 43 - org.apache.camel.camel-core - 2.16.4 | Failed delivery for (MessageId: ID:xxxxxxxxxxxx-46588-1543829293785-1:21:1:1:1
on ExchangeId: ID-xxxxxxxxxxxx-35264-1543835233229-2-1). Exhausted after delivery attempt: 1 caught: java.lang.IllegalArgumentException: The PayLoad elements cannot fit with the message parts of the BindingOpera
tion. Please check the BindingOperation and PayLoadMessage.
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[from.XS.to.xsb?dat] [from.XS.to.xsb?dat] [jms://queue:input ] [ 17]
[from.XS.to.xsb?dat] [setHeader7 ] [setHeader[operationName] ] [ 0]
[from.XS.to.xsb?dat] [setHeader8 ] [setHeader[operationNamespace] ] [ 0]
[from.XS.to.xsb?dat] [log6 ] [log ] [ 12]
[from.XS.to.xsb?dat] [to45 ] [cxf:bean:myEndpoint ] [ 3]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
Id ID-xxxxxxxxxxxx-35264-1543835233229-2-1
ExchangePattern InOut
Headers {breadcrumbId=ID:xxxxxxxxxxxx-46588-1543829293785-1:21:1:1:1, CamelRedelivered=false, CamelRedeliveryCounter=0, JMSCorrelationID=null, JMSCorrelationIDAsBytes=null, JMSDeliveryMode=2,
JMSDestination=queue://input, JMSExpiration=0, JMSMessageID=ID:xxxxxxxxxxxx-46588-1543829293785-1:21:1:1:1, JMSPriority=4, JMSRedelivered=false, JMSReplyTo=queue://response, JMSTimestamp=1543840052184, JMSType=null, JMSXGroupID=null, JMSXUserID=null, operationName=MyOperation, operationNamespace=MyOperationNameSpace}
BodyType String
Body <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://xxxx.xxxx/xxxxxxxx/xxx/xxxxxxxxxxxxxxxxxx/V2" xmlns:v21="http://xxxx.xxxx/xxxxxxxx/xxx/xxxxxx/V2">
<soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecur
ity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-xxxx"><wsse:Username>username</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-ws
s-username-token-profile-1.0#PasswordDigest">xxxx</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
xxxxx</wsse:Nonce><wsu:Created>2018-12-03T12:27:32.183Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header> <soapenv:Body> <v2:MyRequest>
...
...
</v2:MyRequest> </soapenv:Body></soapenv:Envelope>
]
Stacktrace
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.IllegalArgumentException: The PayLoad elements cannot fit with the message parts of the BindingOperation. Please check the BindingOperation and PayLoadMessage.
at org.apache.camel.component.cxf.CxfEndpoint$CamelCxfClientImpl.setParameters(CxfEndpoint.java:1189)[44:org.apache.camel.camel-cxf:2.16.4]
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:470)[57:org.apache.cxf.cxf-core:3.1.5]
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:416)[57:org.apache.cxf.cxf-core:3.1.5]
at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:134)[44:org.apache.camel.camel-cxf:2.16.4]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:112)[46:org.apache.camel.camel-jms:2.16.4]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:555)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:515)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:485)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1103)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1095)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:992)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_181]
at java.lang.Thread.run(Thread.java:748)[:1.8.0_181]
You specify PAYLOAD data format, but according to the docs that is for soap:body processing. Can you XPath out the body into the current exchange, or do you need all the WSE headers?
Or try one of the other data formats MESSAGE (called RAW in later versions I think?) or CXF_MESSAGE sound like they are closer to what you're trying to achieve.

Mule ESB Flow calling SOAP not working but worked from SOAP UI

Details : I have created on flow in MuleESB which is calling a web-service without any parameter just sending it username, password and token in a property and it is working fine.
But the second API I want to post some parameters while calling soap request but I don't know how to use it I tried to pass through set payload but no response.
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="webservicehostadd" port="443" doc:name="HTTP Request Configuration">
<http:basic-authentication username="username" password="pass"/>
</http:request-config>
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="https://xxxx/1.0?wsdl" service="xxx" port="xxxx" serviceAddress="https://xxxxx/1.0" connectorConfig="HTTP_Request_Configuration" doc:name="Web Service Consumer"/>
<flow name="mycustomflow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/TEST" doc:name="HTTP"/>
<set-property propertyName="APIKey" value="xxx-xxx-xxx-xxx-xxx" doc:name="Property"/>
<dw:transform-message doc:name="Transform Message" metadata:id="xxx-xxx-xxx-xxx-xxxxxxxx">
<dw:input-payload mimeType="application/xml"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 http://localhost/getDetails:getDetailsWSD
---
{
ns0#getDetails: {
getDetailsOrder: {
ID: payload.ns0#getDetails.getDetailsOrder.ID,
AllData: payload.ns0#getDetails.getDetailsOrder.AllData
}
}
}]]></dw:set-payload>
</dw:transform-message>
<ws:consumer config-ref="Web_Service_Consumer" operation="employeeDetails" doc:name="Web Service Consumer"/>
</flow>
It showed the below error:
Exception while executing:
[row,col]: [1,1]
Unexpected character '{' (code 123) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1].
Updated answer:
<dw:transform-message metadata:id="XXXXX" doc:name="Transform Message">
<dw:set-payload><![CDATA[
%output application/xml skipNullOn="everywhere"
%namespace ns0 localhost/getDetails:getDetailsWSD
---
{
ns0#getDetails: {
getDetailsOrder: {
ID: payload.ns0#getDetails.getDetailsOrder.ID,
AllData: payload.ns0#getDetails.getDetailsOrder.AllData
}
}
}]]>
</dw:set-payload>
</dw:transform-message>
In your scenario: you are passing a body in XML format and sometimes an empty body in your Postman requests.
Passing an empty body results your payload to be {NullPayload}. To handle this, we have to remove explicitly defining the input mime type: <dw:input-payload mimeType="application/xml"/>.
In your transformation: ID: payload.ns0#getDetails.getDetailsOrder.ID,. You are retrieving a value from an empty payload and this will fail. To avoid failing, we have added: skipNullOn="everywhere". You can read more about it here.
I have tried the transformation myself which results to this:
<?xml version='1.0' encoding='UTF-8'?>
<ns0:getDetails xmlns:ns0="http://localhost/getDetails:getDetailsWSD">
<getDetailsOrder/>
</ns0:getDetails>
I think we are done with your initial issue regarding transformation of your empty payload. Your concern now is consuming the web service.
Thank you.

Apache camel cxfrs—Can't find the request for <URL> Observer

I tried to develop a rest service and expose the same via Apache Camel's CXFRS. I followed all the steps given in http://camel.apache.org/cxfrs.html and also referred to many samples given. I already referred to the question Can't find the the request for url Observer, but in my case it is a simple rest request. Below are the Service class, Route class, and cxf context used:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<context:annotation-config />
<!-- enable Spring #Component scan -->
<context:component-scan base-package="org.camelsample.rest" />
<cxf:rsServer id="rsServer" address="/rest"
serviceClass="org.camelsample.rest.service.SampleRestService"
loggingFeatureEnabled="true" loggingSizeLimit="20">
<cxf:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
</cxf:providers>
</cxf:rsServer>
<camel:camelContext id="samplerestservice"
xmlns="http://camel.apache.org/schema/spring">
<contextScan />
<jmxAgent id="agent" createConnector="true" />
</camel:camelContext>
</beans>
The Service Class:
package org.camelsample.rest.service;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
public class SampleRestService {
#GET
#Path("/")
public String sampleService() {
return null;
}
}
The Route Class:
package org.camelsample.rest.route;
import org.apache.camel.spring.SpringRouteBuilder;
public class SampleRestRoute extends SpringRouteBuilder {
#Override
public void configure() throws Exception {
// TODO Auto-generated method stub
from("cxfrs:bean:rsServer").log("Into Sample Route").setBody(constant("Success"));
}
}
But when I try to hit and test using http://localhost:8080/rest, I always get the following error message:
2015-05-29 13:38:37.920 WARN 6744 --- [nio-8080-exec-2] o.a.c.t.servlet.ServletController : Can't find the the request for http://localhost:8080/favicon.ico's Observer
2015-05-29 13:38:40.295 WARN 6744 --- [nio-8080-exec-3] o.a.c.t.servlet.ServletController : Can't find the the request for http://localhost:8080/rest's Observer
Am using Spring boot to test the rest sample.
Does it work with this URL instead ?
http://localhost:8181/cxf/rest
If you just use address="/rest" as your address then you will probably get the default Jetty port 8181 and default CXF servlet path /cxf as the base URL.
If you specifically want to use the URL you have given then try this instead:
address="http://0.0.0.0:8080/rest"

Spring Integration should route Message (with SOAP Headers)

I am trying to write configure a gateway, which should take a complete SOAP Message and then delegate it to another SOAP Provider (incl. all SOAP headers of the first request).
What I have done so far:
1) web.xml
MessageDispatcherServlet with Mapping:
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/appservices/*</url-pattern>
</servlet-mapping>
2) Configuration with an Endpoint-Mapping
<bean class="org.springframework.ws.server.endpoint.mapping.UriEndpointMapping">
<property name="defaultEndpoint" ref="ws-in-gw"/>
</bean>
3) Configuration of Spring Integration inbound-gateway and outbound-gateway
<int-ws:inbound-gateway id="ws-in-gw"
request-channel="in"
reply-channel="out"
mapped-request-headers="*" />
<int:channel id="in" />
<int:channel id="out" />
<int-ws:outbound-gateway
id="ws-out-gw-status"
request-channel="in-status"
reply-channel="out-status"
uri="http://${delegationServer}/${delegation.contextroot}/soap/AnotherService"
interceptor="soapEnricher"
</int-ws:outbound-gateway>
<bean id="soapEnricher" class="foo.bar.SoapHeaderEnricher" />
public class SoapHeaderEnricher implements ClientInterceptor {
#Override
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
try {
SoapMessage soapMessage = (SoapMessage) messageContext.getRequest();
SoapHeader sh = soapMessage.getSoapHeader();
// can use sh.addHeaderElement(new QName(...)) now, but where are the original Headers???
} catch () {
}
}
My first Problem was, that the original SOAP Headers had been cut of, so I introduced the ' mapped-request-headers="*" ' attribute at the inbound gateway.
When I now configure a wire-tap, I see the Headers (myToken:MySecretToken) are received:
DEBUG 10:46:53 - [Payload DOMSource content=javax.xml.transform.dom.DOMSource#24a6ce98][Headers={errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#43456ff4, myToken:MySecretToken=org.springframework.ws.soap.saaj.SaajSoapHeaderElement#3b91ead, ...}]
This is the SOAP Message for my test:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:stat="http://status.service.promakler.provinzial.com/">
<soapenv:Header>
<myToken:MySecretToken xmlns=""
xmlns:myToken="http://foo.bar">12345</myToken:MySecretToken>
</soapenv:Header>
<soapenv:Body>
<stat:getStatus/>
</soapenv:Body>
</soapenv:Envelope>
So the Headers are now in my Message, but in the ClientInterceptor, there is no way to get the Headers (just the payload)?! I can add new Headers, but how can I get the original Header?
Can anybody give me a hint (or perhaps there is even a quiet simpler solution??)
Regards
Timo
Try to introduce a custom extension of DefaultSoapHeaderMapper and override populateUserDefinedHeader to extract those SaajSoapHeaderElement from the MessageHeaders and populate them to the SoapHeader. And finally inject your solution to the header-mapper of your <int-ws:outbound-gateway>.