Ceddoc
Ceddoc

Reputation: 63

CXF Web-Services Response return invalid name

I used CXF WSDL2java to generate a server for an existing WSDL.

This gave me a SEI like that :

@WebService(targetNamespace = "http://mon.namespace.1", name = "MonWs")
@XmlSeeAlso({ObjectFactory.class})
public interface MonWs {

    @WebResult(name = "Output", targetNamespace = "http://mon.namespace.1")
    @RequestWrapper(localName = "maMethodePrincipale", targetNamespace = "http://mon.namespace.1", className = "MaMethodePrincipaleRequest")
    @WebMethod(operationName = "maMethodePrincipale", action = "http://mon.namespace.1/MonWs/maMethodePrincipale")
    @ResponseWrapper(localName = "maMethodePrincipaleResponse", targetNamespace = "http://mon.namespace.1", className = "MaMethodePrincipaleResponse")
    public MaMethodePrincipaleResponse.Output maMethodePrincipale(
        @WebParam(name = "Input", targetNamespace = "http://mon.namespace.1")
        MaMethodePrincipaleRequest.Input Input
    );
}

I created a basic implementation but when I call it on my server (hosted on tomcat, with de CXfNonSpringServlet) with soapUI (and other client) I got this kind of return :

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns1:MaMethodePrincipaleResponse xmlns:ns1="http://mon.namespace.1">
         <ns2:return xmlns="http://mon.namespace.2" xmlns:ns2="http://mon.namespace.1"/>
            ...
            my return object field list correctly named
            ...
         </ns2:return>
      </ns1:MaMethodePrincipaleResponse>
   </soap:Body>
</soap:Envelope>

my problem is the the tag "ns2:return ..." it should be name "Output" like I define in all the annotations (even in maMethodePrincipaleResponse name etc...) So when i try to call my server with a java client I've got an error message like

javax.xml.bind.UnmarshalException: Unexpected Element (URI : "http://mon.namespace.1", local : "return"). Expected elements are <{http://mon.namespace.1}Output>

I already try a bunch of possible correction like set the soap binding to "bare" and set every partname or name to "Output" But nothing works.

What should i do to have this return parameter named "Output"?

Upvotes: 1

Views: 2575

Answers (2)

Daniel Kulp
Daniel Kulp

Reputation: 14607

You are using Request/ResponseWrapper's. Thus, the names for the elements would be defined in the annotations on the fields in those classes.

Upvotes: 0

saitakyuz
saitakyuz

Reputation: 76

You can try to use Interceptor.

in this link you can see how you can modify cxf response.

good luck

Upvotes: 3

Related Questions