1

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"?

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
Ceddoc
  • 63
  • 7

2 Answers2

3

You can try to use Interceptor.

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

good luck

Community
  • 1
  • 1
saitakyuz
  • 76
  • 4
  • This seems to be fine, but perhaps too long to set up, if nothing else works, i think i'll end up to do an interceptor. – Ceddoc Nov 30 '12 at 09:45
  • I got the same error.I've tried so many ways. this way is long way, but it's work. – saitakyuz Nov 30 '12 at 09:52
0

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

Daniel Kulp
  • 14,447
  • 4
  • 45
  • 37
  • In my response Wrapper I've got something like this: ` @XmlElement(name = "Output") protected MaMethodePrincipaleResponse.Output output;` – Ceddoc Dec 05 '12 at 15:14