Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-4461

soap 1.1 response Content-Type is not handled as expected with soap 1.2 binding in camel-cxf endpoint

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • fuse-7.0
    • jboss-fuse-6.1, jboss-fuse-6.3
    • Camel, CXF
    • None
    • % %
    • Hide

      Attached are 2 reproducer,

      1. cxf-server-hello-world-soap12.zip – This is a pure CXF JAX-WS endpoint configuration which has a soap 1.2 binding.

      To execute, just type `mvn -Pserver`.
      In another terminal, just execute the script, ./request.sh

      You can see that the request and response Content-Type for soap 1.1 are the same, which is 'text/xml'.

      Content-Type: text/xml
      Headers: {Accept=[*/*], Content-Length=[205], content-type=[text/xml], Host=[localhost:9000], User-Agent=[curl/7.40.0]}
      Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://apache.org/hello_world_soap12_http/types">
      <soap:Header/>
      <soap:Body>
          <typ:pingMe/>
      </soap:Body>
      </soap:Envelope>
      --------------------------------------
      2015-11-19 23:08:10,238 [tp1051462612-18]  INFO  GreeterImpl                    - Executing operation pingMe
      2015-11-19 23:08:10,263 [tp1051462612-18]  INFO  Greeter                        - Outbound Message
      ---------------------------
      ID: 2
      Response-Code: 200
      Encoding: UTF-8
      Content-Type: text/xml
      Headers: {}
      Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><pingMeResponse xmlns="http://apache.org/hello_world_soap12_http/types"/></soap:Body></soap:Envelope>
      

      --------------------------------------

      2. camel-cxf-blueprint-server-6.1 — This is the reproducer with camel-cxf transport which has the issue.

      • Deploy the jar file or install the bundle in Fuse 6.1.
      • Execute the ./request.sh to fire the client request.

      You will see that with soap 1.1 request, the Content-Type send is 'text/xml', which the response returned is 'application/soap+xml', which is not correct.

      Content-Type: text/xml
      Headers: {Accept=[*/*], Content-Length=[205], content-type=[text/xml], Host=[localhost:9292], User-Agent=[curl/7.40.0]}
      Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://apache.org/hello_world_soap12_http/types">
      <soap:Header/>
      <soap:Body>
          <typ:pingMe/>
      </soap:Body>
      </soap:Envelope>
      
      Content-Type: application/soap+xml
      Headers: {Accept=[*/*], breadcrumbId=[ID-localhost-41911-1447953817085-2-1], Host=[localhost:9292], User-Agent=[curl/7.40.0]}
      Payload: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><pingMeResponse xmlns="http://apache.org/hello_world_soap12_http/types"/></soap:Body></soap:Envelope>
      
      Show
      Attached are 2 reproducer, 1. cxf-server-hello-world-soap12.zip – This is a pure CXF JAX-WS endpoint configuration which has a soap 1.2 binding. To execute, just type `mvn -Pserver`. In another terminal, just execute the script, ./request.sh You can see that the request and response Content-Type for soap 1.1 are the same, which is 'text/xml'. Content-Type: text/xml Headers: {Accept=[*/*], Content-Length=[205], content-type=[text/xml], Host=[localhost:9000], User-Agent=[curl/7.40.0]} Payload: <soap:Envelope xmlns:soap= "http: //schemas.xmlsoap.org/soap/envelope/" xmlns:typ= "http://apache.org/hello_world_soap12_http/types" > <soap:Header/> <soap:Body> <typ:pingMe/> </soap:Body> </soap:Envelope> -------------------------------------- 2015-11-19 23:08:10,238 [tp1051462612-18] INFO GreeterImpl - Executing operation pingMe 2015-11-19 23:08:10,263 [tp1051462612-18] INFO Greeter - Outbound Message --------------------------- ID: 2 Response-Code: 200 Encoding: UTF-8 Content-Type: text/xml Headers: {} Payload: <soap:Envelope xmlns:soap= "http: //schemas.xmlsoap.org/soap/envelope/" ><soap:Body><pingMeResponse xmlns= "http://apache.org/hello_world_soap12_http/types" /></soap:Body></soap:Envelope> -------------------------------------- 2. camel-cxf-blueprint-server-6.1 — This is the reproducer with camel-cxf transport which has the issue. Deploy the jar file or install the bundle in Fuse 6.1. Execute the ./request.sh to fire the client request. You will see that with soap 1.1 request, the Content-Type send is 'text/xml', which the response returned is 'application/soap+xml', which is not correct. Content-Type: text/xml Headers: {Accept=[*/*], Content-Length=[205], content-type=[text/xml], Host=[localhost:9292], User-Agent=[curl/7.40.0]} Payload: <soap:Envelope xmlns:soap= "http: //schemas.xmlsoap.org/soap/envelope/" xmlns:typ= "http://apache.org/hello_world_soap12_http/types" > <soap:Header/> <soap:Body> <typ:pingMe/> </soap:Body> </soap:Envelope> Content-Type: application/soap+xml Headers: {Accept=[*/*], breadcrumbId=[ID-localhost-41911-1447953817085-2-1], Host=[localhost:9292], User-Agent=[curl/7.40.0]} Payload: <soap:Envelope xmlns:soap= "http: //www.w3.org/2003/05/soap-envelope" ><soap:Body><pingMeResponse xmlns= "http://apache.org/hello_world_soap12_http/types" /></soap:Body></soap:Envelope>
    • Fuse 7.0 Sprint 26

    Description

      When soap 1.2 binding is set in camel-cxf transport, the expectation is that it should serve for both soap 1.1 as well as 1.2 soap requests.

      However, when soap 1.1 request is sent, the Content-Type returned in the response is 'application/soap+xml', which is not correct.
      The expected soap response Content-type for soap 1.1 message with soap 1.2 binding set should still be 'text/xml'.

      This behaviour of camel-cxf transport differs from the pure CXF's JAX-WS frontend configuration, wherein, the Content-Type returned in response for soap 1.1 request is 'text/xml'.

      Workaround :

      • As a workaround for this issue, you have to include a custom interceptor as below to change the Content-Type:
      public class Soap11ContentTypeOutInterceptor extends AbstractSoapInterceptor {
      
      	public Soap11ContentTypeOutInterceptor() {
      		super(Phase.POST_PROTOCOL);
      		addAfter(SoapPreProtocolOutInterceptor.class.getName());
      	}
      
      	public void handleMessage(SoapMessage message) throws Fault {
      
      		if (message.getVersion() instanceof Soap11) {
      			message.put(Message.CONTENT_TYPE, ((Soap11) message.getVersion()).getContentType());
      		}
      
      		/*Map<String, List<String>> headers = CastUtils
      				.cast((Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS));
      
      		if (headers.containsKey("content-type.override")) {
      			message.put(Message.CONTENT_TYPE, headers.get("content-type.override").get(0));
      			headers.remove("content-type.override");
      		}*/
      
      	}
      
      	public void setContentTypeOverride(@Headers Map<String, Object> headers) {
      
      		org.apache.cxf.binding.soap.SoapMessage cxfMsg = (SoapMessage) headers.get("CamelCxfMessage");
      
      		SoapVersion version = (SoapVersion) cxfMsg.get("org.apache.cxf.binding.soap.SoapVersion");
      
      		if (version instanceof Soap11) {
      			headers.put("content-type.override", ((Soap11) version).getContentType());
      		}
      	}
      
      }
      

      Attachments

        Activity

          People

            yfang@redhat.com Freeman(Yue) Fang
            rhn-support-vgohel Viral Gohel
            Viliam Kasala Viliam Kasala
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: