cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: Web method with no arguments, request wrapper and xsi:type
Date Wed, 03 Dec 2008 19:37:25 GMT

The problem is really that the schema is wrong.   

An element declaration of:
<xs:element name="myRequest"/>
does NOT mean an empty element.   Without a type, the default 
is "xsd:anyType".   Thus, when written out, some type is created and an 
xsi:type is outputted.     The best fix is to update the schema to look like:

<xs:element name="myRequest">
   <xs:complexType>
       <xs:sequence/>
   </xs:complexType>
</xs:element>

which defines an empty anonymous type for the element instead of anyType.

Dan




On Wednesday 03 December 2008 9:13:13 am Kirill R. wrote:
> The problem is this:
>
> I need to create a client using a schema describing its request/response
> types and others used by them.
> No wsdl exists, so I created an empty one referencing this schema, ran
> wsdl2java and it created Java
> classes for all types described in the schema. However, 2 of the WS methods
> have no arguments and
> the request element declaration for them looks like this:
> <xs:element name="myRequest"/>
> So no request wrappers were generated for them.
>
> Then I created a JAX-WS annotated interface using these classes and use it
> to create WS clients at runtime. The 2 methods with no arguments have no
> RequestWrapper annotation, like this:
>
> @ResponseWrapper(localName = "myResponse", targetNamespace = "myNs",
> className = "my.package.MyResponse")
> @WebMethod
> public void myRequest(
>         @WebParam(mode = WebParam.Mode.OUT, name = "ret1", targetNamespace
> = "myNs")
>         Holder<java.lang.Integer> ret1,
>         // ...other returned values
> )
>
>
> The other methods work fine, but for these 2 the generated request wrapper
> element has has an xsi:type attribute:
>
> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
>     <soap:Body>
>         <myRequest xmlns="myNs"
>             xmlns:ns2="http://www.w3.org/2003/05/soap-envelope"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>             xsi:type="myRequest" />
>     </soap:Body>
> </soap:Envelope>
>
> which apparently causes the web service on the other side (hardware, not
> running Java and CXF I
> assume :) to fail.
>
> Tried adding a RequestWrapper annotation to these methods and creating an
> empty Java class to match
> (with minimal annotations):
> @XmlRootElement(name = "myRequest")
> public class MyRequest {}
>
>
> Same thing.
>
>
> How do I handle this properly so the request doesn't have any unwanted
> attributes?
> Could somebody point me in the right direction, please?



-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Mime
View raw message