We have web service (jaxws) which is calling another web service (aslo jaxws). Jaxws client configuration looks like this --
<jaxws:client id="helloClient"
serviceClass="demo.spring.HelloWorld"
address="http://localhost:9002/HelloWorld" >
<jaxws:outInterceptors>
<bean class="com.company.MyOutInterceptor"/>
</jaxws:outInterceptors>
<jaxws:inFaultInterceptors>
<bean class="com.company.MyInFaultInterceptor"/>
</jaxws:inFaultInterceptors>
<cxf:properties>
<entry key="org.apache.cxf.logging.FaultListener">
<bean class="com.company.MyFaultListener"/>
</entry>
</cxf:properties>
</jaxws:client>
As you can see we have two interceptors and one fault listener. We want to communication among these interceptors, fault listeners and web service code. As given in SO THREAD, we used cxf Exchange object for communication between web service and interceptor.
Our inFaultInterceptor code look like this --
public class MyInFaultInterceptor extends AbstractPhaseInterceptor<Message> {
public MyInFaultInterceptor() {
super(Phase.RECEIVE);
}
public void handleMessage(Message message) {
message.getExchange().put("key", "value");
}
}
Out web service code look like this --
public String addNumbers(int a, int b){
try{
myService.add(a,b);
}catch(MyServiceException e){
//Logging
}
Object value = PhaseInterceptorChain.getCurrentMessage().getExchange().get("key");
}
But, int the web service code we are getting null for given "key", means "key" is not present.
Is there any way in which we can communicate between interceptors and web service?
P.S : We are able to communicate within interceptors and listeners with the above method. That is, we are able to access key set in outInterceptor in inFaultInterceptor, but keys set in any interceptor or listener is not accessible in web service.