Domanda

I am using Apache Camel CXF to integrate a SOAP WebService. Everything works fine but I have noticed that my response is coming back as HTTP 202 instead of 200. I am kinda concerned because I know many people hardcode things like if(httpCode == 200) {...} and this could break the current service.

I have tried using different interceptors to override the HTTP code from 202 to 200, but no luck. Also, 202 means Accepted which means the request is in process but not finished. 200 means OK which means the process has finished. Does this means that I am doing something wrong in my route?

What is the right way of fixing this? Interceptor? Setting a Camel headers? Doing something in the route to say it's complete?

I am using Apache Camel 2.12.1 and PAYLOAD mode.

EDIT: It seems something related to OneWay endpoint. Is there any way to deactivate that?

EDIT2: After hours trying things I think I have the root cause. My WSDL is not defining any output for that particular operation. I cannot change the WSDL. That said, I believe that when CXF is using the WSDL for creating the endpoint it automatically assumes it is a OneWay endpoint since there is no output. That means the response is sent back as soon as we get the request with code 202. Also, I believe there is no possible OutInteceptor chain because of this reason. Personally I believe it's ok to send back 202 but it is a service requirement to send back 200. Is there any configuration I change in CXF to set that in OneWay endpoint mode?

È stato utile?

Soluzione

Finally, we found an interceptor for doing that:

public class SoapResponseInterceptor extends AbstractSoapInterceptor {

    public SoapResponseInterceptor() {
        super(Phase.PRE_LOGICAL);
    }

    @Override
    public void handleMessage(SoapMessage message) throws Fault {
        message.getExchange().setOneWay(false);
    }
}

Hope it helps!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top