Nope.   Not a bug.   This is per spec.   As soon as you remove the "wrapper" 
element from the request, it's no longer considers "wrapped doc/lit" and thus 
we no longer can unwrap it.     

That said, doing what you did ALSO results in a WSDL that is no longer WSI-BP 
compliant.     The incoming soap message would have an empty body and not have 
any indication what operation it's really targeting.    Thus, I definitely 
don't recommend that approach.

My suggestion is to change the schema for the getContactsByCriteria element to 
just:


<xsd:element name="getContactsByCriteria">
        <xsd:complexType>
          <xsd:sequence/>
        </xsd:complexType>
</xsd:element>


That should solve the problem and keep it WSI-BP compliant.

Dan


> 
> 
> I've got the following WSDL:
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> 
> <wsdl:definitions xmlns:contact="http://www.jemos.co.uk/schemas/contact";
> 
>                           xmlns:jem="http://www.jemos.co.uk/cxftest/";
> 
>                          
>  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
> 
> 
>                           xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
> 
>                           xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> 
> 
>                           name="cxftest"
> targetNamespace="http://www.jemos.co.uk/cxftest/";>
> 
> 
> 
>   <!-- Data types definition -->
> 
>   <wsdl:types>
> 
>     <xsd:schema targetNamespace="http://www.jemos.co.uk/cxftest/";>
> 
>       <xsd:import schemaLocation="../xsd/contact.xsd"
> namespace="http://www.jemos.co.uk/schemas/contact";>
> 
>       </xsd:import>
> 
>       <xsd:element name="getContactsByCriteria">
> 
>         <xsd:complexType>
> 
>           <xsd:sequence>
> 
>             <xsd:element name="in" type="xsd:int"/>
> 
>           </xsd:sequence>
> 
>         </xsd:complexType>
> 
>       </xsd:element>
> 
>       <xsd:element name="getContactsByCriteriaResponse">
> 
>         <xsd:complexType>
> 
>           <xsd:sequence>
> 
>             <xsd:element name="out" type="contact:contact"
> maxOccurs="unbounded"/>
> 
>           </xsd:sequence>
> 
>         </xsd:complexType>
> 
>       </xsd:element>
> 
>     </xsd:schema>
> 
>   </wsdl:types>
> 
> 
> 
>   <!-- This defines the SOAP messages resulting in a WRAPPED style -->
> 
>   <wsdl:message name="getContactsByCriteriaRequest">
> 
>     <wsdl:part element="jem:getContactsByCriteria" name="parameters"/>
> 
>   </wsdl:message>
> 
>   <wsdl:message name="getContactsByCriteriaResponse">
> 
>     <wsdl:part element="jem:getContactsByCriteriaResponse"
> name="parameters"/>
> 
>   </wsdl:message>
> 
> 
> 
>   <!-- This will define the Java interface -->
> 
>   <wsdl:portType name="IJemosService">
> 
>     <!-- The method on the interface -->
> 
>     <wsdl:operation name="getContactsByCriteria">
> 
>       <wsdl:input message="jem:getContactsByCriteriaRequest"/>
> 
>       <wsdl:output message="jem:getContactsByCriteriaResponse"/>
> 
>     </wsdl:operation>
> 
>   </wsdl:portType>
> 
> 
> 
>   <!-- This binds the Java interface definition with SOAP characteristics
> -->
> 
>   <wsdl:binding name="JemosServiceSOAPBinding" type="jem:IJemosService">
> 
>     <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
> 
>     <wsdl:operation name="getContactsByCriteria">
> 
>       <!-- TCP/IP monitoring address
> 
>       <soap:operation
> soapAction="http://localhost:9977/cxf-test/JemosService/getContactsByCriter
> i a"/>
> 
>        -->
> 
>       <soap:operation
> soapAction="http://localhost:8080/cxf-test/JemosService/getContactsByCriter
> i a"/>
> 
>       <wsdl:input>
> 
>         <soap:body use="literal"/>
> 
>       </wsdl:input>
> 
>       <wsdl:output>
> 
>         <soap:body use="literal"/>
> 
>       </wsdl:output>
> 
>     </wsdl:operation>
> 
>   </wsdl:binding>
> 
> 
> 
>   <wsdl:service name="JemosServiceWebClient">
> 
>     <wsdl:port name="JemosServicePort"
>  binding="jem:JemosServiceSOAPBinding"
> 
> 
>     <!-- TCP/IP monitoring address
> 
>       <soap:address
>  location="http://localhost:9977/cxf-test/JemosService"/>
> 
>     -->
> 
>     <soap:address location="http://localhost:8080/cxf-test/JemosService"/>
> 
>     </wsdl:port>
> 
>   </wsdl:service>
> 
> </wsdl:definitions>
> 
> 
> 
> This imports the Contact definition in the following schema:
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
> 
>             elementFormDefault="qualified"
> 
>             xmlns:contact="http://www.jemos.co.uk/schemas/contact";
> 
>             targetNamespace="http://www.jemos.co.uk/schemas/contact"; >
> 
>       <xs:complexType name="contact">
> 
>         <xs:sequence>
> 
>           <xs:element name="firstName" type="xs:string" />
> 
>           <xs:element name="lastName" type="xs:string" />
> 
>           <xs:element name="emailAddress" type="xs:string" />
> 
>           <xs:element name="ordersCount" type="xs:integer" />
> 
>         </xs:sequence>
> 
>     </xs:complexType>
> 
> 
> 
> </xs:schema>
> 
> 
> 
> 
> 
> So far so good. When I launch the wsdl2java through Maven plugin everything
> gets created nicely. The interface looks like:
> 
> 
> 
> package uk.co.jemos.cxftest;
> 
> 
> 
> import javax.jws.WebMethod;
> 
> import javax.jws.WebParam;
> 
> import javax.jws.WebResult;
> 
> import javax.jws.WebService;
> 
> import javax.xml.bind.annotation.XmlSeeAlso;
> 
> import javax.xml.ws.RequestWrapper;
> 
> import javax.xml.ws.ResponseWrapper;
> 
> 
> 
> /**
> 
>  * This class was generated by Apache CXF 2.2.4
> 
>  * Sun Nov 15 17:42:01 GMT 2009
> 
>  * Generated source version: 2.2.4
> 
>  *
> 
>  */
> 
> 
> 
> @WebService(targetNamespace = "http://www.jemos.co.uk/cxftest/";, name =
> "IJemosService")
> 
> @XmlSeeAlso({ObjectFactory.class,uk.co.jemos.schemas.contact.ObjectFactory.
> c lass})
> 
> public interface IJemosService {
> 
> 
> 
>     @WebResult(name = "out", targetNamespace = "")
> 
>     @RequestWrapper(localName = "getContactsByCriteria", targetNamespace =
> "http://www.jemos.co.uk/cxftest/";, className =
> "uk.co.jemos.cxftest.GetContactsByCriteria")
> 
>     @ResponseWrapper(localName = "getContactsByCriteriaResponse",
> targetNamespace = "http://www.jemos.co.uk/cxftest/";, className =
> "uk.co.jemos.cxftest.GetContactsByCriteriaResponse")
> 
>     @WebMethod(action =
> "http://localhost:8080/cxf-test/JemosService/getContactsByCriteria";)
> 
>     public java.util.List<uk.co.jemos.schemas.contact.Contact>
> getContactsByCriteria(
> 
>         @WebParam(name = "in", targetNamespace = "")
> 
>         int in
> 
>     );
> 
> }
> 
> 
> 
> However I realised that the operation should not have any arguments, so I
> changed the WSDL as follows:
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> 
> <wsdl:definitions xmlns:contact="http://www.jemos.co.uk/schemas/contact";
> 
>                           xmlns:jem="http://www.jemos.co.uk/cxftest/";
> 
>                          
>  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
> 
> 
>                           xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
> 
>                           xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> 
> 
>                           name="cxftest"
> targetNamespace="http://www.jemos.co.uk/cxftest/";>
> 
> 
> 
>   <!-- Data types definition -->
> 
>   <wsdl:types>
> 
>     <xsd:schema targetNamespace="http://www.jemos.co.uk/cxftest/";>
> 
>       <xsd:import schemaLocation="../xsd/contact.xsd"
> namespace="http://www.jemos.co.uk/schemas/contact";>
> 
>       </xsd:import>
> 
>       <xsd:element name="getContactsByCriteriaResponse">
> 
>         <xsd:complexType>
> 
>           <xsd:sequence>
> 
>             <xsd:element name="out" type="contact:contact"
> maxOccurs="unbounded"/>
> 
>           </xsd:sequence>
> 
>         </xsd:complexType>
> 
>       </xsd:element>
> 
>     </xsd:schema>
> 
>   </wsdl:types>
> 
> 
> 
>   <!-- This defines the SOAP messages resulting in a WRAPPED style -->
> 
>   <wsdl:message name="getContactsByCriteriaRequest" />
> 
> 
> 
>   <wsdl:message name="getContactsByCriteriaResponse">
> 
>     <wsdl:part element="jem:getContactsByCriteriaResponse"
> name="parameters"/>
> 
>   </wsdl:message>
> 
> 
> 
>   <!-- This will define the Java interface -->
> 
>   <wsdl:portType name="IJemosService">
> 
>     <!-- The method on the interface -->
> 
>     <wsdl:operation name="getContactsByCriteria">
> 
>       <wsdl:input message="jem:getContactsByCriteriaRequest"/>
> 
>       <wsdl:output message="jem:getContactsByCriteriaResponse"/>
> 
>     </wsdl:operation>
> 
>   </wsdl:portType>
> 
> 
> 
>   <!-- This binds the Java interface definition with SOAP characteristics
> -->
> 
>   <wsdl:binding name="JemosServiceSOAPBinding" type="jem:IJemosService">
> 
>     <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
> 
>     <wsdl:operation name="getContactsByCriteria">
> 
>       <!-- TCP/IP monitoring address
> 
>       <soap:operation
> soapAction="http://localhost:9977/cxf-test/JemosService/getContactsByCriter
> i a"/>
> 
>        -->
> 
>       <soap:operation
> soapAction="http://localhost:8080/cxf-test/JemosService/getContactsByCriter
> i a"/>
> 
>       <wsdl:input>
> 
>         <soap:body use="literal"/>
> 
>       </wsdl:input>
> 
>       <wsdl:output>
> 
>         <soap:body use="literal"/>
> 
>       </wsdl:output>
> 
>     </wsdl:operation>
> 
>   </wsdl:binding>
> 
> 
> 
>   <wsdl:service name="JemosServiceWebClient">
> 
>     <wsdl:port name="JemosServicePort"
>  binding="jem:JemosServiceSOAPBinding"
> 
> 
>     <!-- TCP/IP monitoring address
> 
>       <soap:address
>  location="http://localhost:9977/cxf-test/JemosService"/>
> 
>     -->
> 
>     <soap:address location="http://localhost:8080/cxf-test/JemosService"/>
> 
>     </wsdl:port>
> 
>   </wsdl:service>
> 
> </wsdl:definitions>
> 
> 
> 
> 
> 
> However now the interface doesn't return a List<Contact> anymore but it
> returns the following:
> 
> 
> 
> package uk.co.jemos.cxftest;
> 
> 
> 
> import javax.jws.WebMethod;
> 
> import javax.jws.WebResult;
> 
> import javax.jws.WebService;
> 
> import javax.jws.soap.SOAPBinding;
> 
> import javax.xml.bind.annotation.XmlSeeAlso;
> 
> 
> 
> /**
> 
>  * This class was generated by Apache CXF 2.2.4
> 
>  * Sun Nov 15 17:54:27 GMT 2009
> 
>  * Generated source version: 2.2.4
> 
>  *
> 
>  */
> 
> 
> 
> @WebService(targetNamespace = "http://www.jemos.co.uk/cxftest/";, name =
> "IJemosService")
> 
> @XmlSeeAlso({ObjectFactory.class,uk.co.jemos.schemas.contact.ObjectFactory.
> c lass})
> 
> @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
> 
> public interface IJemosService {
> 
> 
> 
>     @WebResult(name = "getContactsByCriteriaResponse", targetNamespace =
> "http://www.jemos.co.uk/cxftest/";, partName = "parameters")
> 
>     @WebMethod(action =
> "http://localhost:8080/cxf-test/JemosService/getContactsByCriteria";)
> 
>     public GetContactsByCriteriaResponse getContactsByCriteria();
> 
> }
> 
> 
> 
> The following annotations have gone
> 
> 
> 
> @RequestWrapper(localName = "getContactsByCriteria", targetNamespace =
> "http://www.jemos.co.uk/cxftest/";, className =
> "uk.co.jemos.cxftest.GetContactsByCriteria")
> 
> @ResponseWrapper(localName = "getContactsByCriteriaResponse",
> targetNamespace = "http://www.jemos.co.uk/cxftest/";, className =
> "uk.co.jemos.cxftest.GetContactsByCriteriaResponse")
> 
> 
> 
> Is this a bug?
> 
> 
> 
> Regards,
> 
> 
> 
> M.
> 

-- 
Daniel Kulp
[email protected]
http://www.dankulp.com/blog

Reply via email to