4

The CXF generated client sends the following SOAP request which does not return records from their side:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <PersonSearch xmlns="http://tlo.com/">
            <genericSearchInput>
                ....
            </genericSearchInput>
        </PersonSearch>
    </soap:Body>
</soap:Envelope>

The SoapUI request looks like the following and does return records:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tlo="http://tlo.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <tlo:PersonSearch>
         <!--Optional:-->
         <tlo:genericSearchInput>
             ...
         </tlo:genericSearchInput>
      </tlo:PersonSearch>
   </soapenv:Body>
</soapenv:Envelope>

The only difference I see is the default namespace declaration on instead of the namespace declaration on the soap envelope and the use of the namespace prefix. I have tried several different ways to get the CXF generated client to create the same kind of soap request. Can anyone give some pointers or do I need to use something else?

I am using org.apache.cxf:cxf-codegen-plugin:2.5.2 on JDK 6.

Norris
  • 635
  • 8
  • 9
  • 1
    Both are correct ways to do SOAP messages, but some services apparently interpret the SOAP standard in very strange ways. They apparently seem to want to remove the envelope by pure string operations, which is deeply wrong-headed. What service framework is doing the server-side bindings? – Donal Fellows Apr 17 '12 at 14:09

1 Answers1

2

Did you use JAXB for databinding? I was able to resolve the same problem by using XMLBEANS instead. See the db flag for wsdl2java: http://cxf.apache.org/docs/wsdl-to-java.html

I am still looking for a better solution than just changing the databinding.

Update 20012-04-18: Sergey and Aki from the cxf users mailing list were so kind to show me the TransformationFeature of CXF. Using the following code on the client side works for me:

        MyService myService = new MyService();
        myPort = myService.getMyServiceHttpSoap11Endpoint();
        // See http://cxf.apache.org/docs/transformationfeature.html
        Client client = ClientProxy.getClient(myPort);

        Map<String, String> outTransformMap = Collections.singletonMap(
                "{http://myNamespace}*",
                "{http://myNamespace}*");
        org.apache.cxf.interceptor.transform.TransformOutInterceptor transformOutInterceptor =
                new org.apache.cxf.interceptor.transform.TransformOutInterceptor();
        transformOutInterceptor.setOutTransformElements(outTransformMap);
            client.getOutInterceptors().add(transformOutInterceptor);

I'm using this with CXF 2.5.2. with 2.5.3 and 2.5.6 according to Aki you have to use the defaultNamespace property.

Arthur
  • 91
  • 4
  • Could you help me on this question, http://stackoverflow.com/questions/31181207/how-can-i-add-namespace-decalarations-in-soap-envelope – The Coder Jul 02 '15 at 10:09