[vwnc] WSDL: problem marshaling <xsd:any>

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] WSDL: problem marshaling <xsd:any>

Holger Kleinsorgen-4
Hello,

I currently try to talk to a WSDL service that includes a type with
<xsd:any> content. The relevant types:


<xsd:complexType name="FoundObjects">
   <xsd:sequence>
     <xsd:element name="object" type="tns:Object" minOccurs="0"
maxOccurs="unbounded"/>
   </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Object">
   <xsd:sequence>
     <xsd:element name="id" type="xsd:string"/>
     <xsd:element name="name" type="xsd:string"/>
     <xsd:any namespace="##any" processContents="lax" minOccurs="0"
maxOccurs="1"/>
   </xsd:sequence>
</xsd:complexType>


the WSDL wizard has created a class for FoundObjects, and uses a Struct
for Object:

FoundObjects>>object: aStruct
   <addAttribute: #(#object #optional) type: #(#Collection
#'WebServices.Struct') >
   object := aStruct

However, the contents of the Object struct is never marshaled. Given the
following:

object := WebServices.Struct new.
object at: 'id' put: 'foobar'.
foundObjects := FoundObjects new.
foundObjects object: (OrderedCollection with: object).

marshaled as:

<ns:FoundObjects
       xsi:type="ns:FoundObjects"
       xmlns:ns="urn:schemas.xxx:query"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <ns:object xsi:type="ns:Object"></ns:object>
</ns:FoundObjlistType>


tested with VW 7.6
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] WSDL: problem marshaling <xsd:any>

Kogan, Tamara
Try to change:
> object := WebServices.Struct new.
> object at: 'id' put: 'foobar'.
> foundObjects := FoundObjects new.
> foundObjects object: (OrderedCollection with: object).
As
 object := WebServices.Struct new.
 object at: #id put: 'foobar'.
 foundObjects := FoundObjects new.
 foundObjects object: (OrderedCollection with: object).

See the attached test case.

HTH,
Tamara Kogan
Smalltalk development,
Cincom Systems
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Holger Kleinsorgen
> Sent: Monday, October 26, 2009 9:18 AM
> To: vwnc List
> Subject: [vwnc] WSDL: problem marshaling <xsd:any>
>
> Hello,
>
> I currently try to talk to a WSDL service that includes a type with
> <xsd:any> content. The relevant types:
>
>
> <xsd:complexType name="FoundObjects">
>    <xsd:sequence>
>      <xsd:element name="object" type="tns:Object" minOccurs="0"
> maxOccurs="unbounded"/>
>    </xsd:sequence>
> </xsd:complexType>
>
> <xsd:complexType name="Object">
>    <xsd:sequence>
>      <xsd:element name="id" type="xsd:string"/>
>      <xsd:element name="name" type="xsd:string"/>
>      <xsd:any namespace="##any" processContents="lax" minOccurs="0"
> maxOccurs="1"/>
>    </xsd:sequence>
> </xsd:complexType>
>
>
> the WSDL wizard has created a class for FoundObjects, and
> uses a Struct
> for Object:
>
> FoundObjects>>object: aStruct
>    <addAttribute: #(#object #optional) type: #(#Collection
> #'WebServices.Struct') >
>    object := aStruct
>
> However, the contents of the Object struct is never
> marshaled. Given the
> following:
>
> object := WebServices.Struct new.
> object at: 'id' put: 'foobar'.
> foundObjects := FoundObjects new.
> foundObjects object: (OrderedCollection with: object).
>
> marshaled as:
>
> <ns:FoundObjects
>        xsi:type="ns:FoundObjects"
>        xmlns:ns="urn:schemas.xxx:query"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>    <ns:object xsi:type="ns:Object"></ns:object>
> </ns:FoundObjlistType>
>
>
> tested with VW 7.6
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

marshalingAny.zip (916 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] WSDL: problem marshaling <xsd:any>

Holger Kleinsorgen-4
Hello,

Kogan, Tamara wrote:

> Try to change:
>> object := WebServices.Struct new.
>> object at: 'id' put: 'foobar'.
>> foundObjects := FoundObjects new.
>> foundObjects object: (OrderedCollection with: object).
> As
>  object := WebServices.Struct new.
>  object at: #id put: 'foobar'.
>  foundObjects := FoundObjects new.
>  foundObjects object: (OrderedCollection with: object).
>
> See the attached test case.

the WSDL wizard created the following x2oBinding:

<struct name="Object" smalltalkClass="Struct">
   <any maxOccurs="1" minOccurs="0" namespace="##any"
processContents="lax"></any>
</struct>

the binding of the testcase includes id/name:

<struct name="Object" >
   <element name="id" ref="xsd:string" minOccurs="0" />
   <element name="name" ref="xsd:string" minOccurs="0" />
   <any aspect="something" minOccurs="0"  />
</struct>

with this binding and the correct key (#id instead of 'id'), I can now
successfully (un)marshal id/name - thanks!

However, it seems to be impossible to unmarshal <any> content, e.g.

   <object xsi:type="ns:Object">
      <weight xsi:type="ns0:float">1.0</weight>
   </object>

is unmarshaled as an empty struct. is it possible to (un)marshal such
generic content in any way?
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] WSDL: problem marshaling <xsd:any>

Kogan, Tamara
>
> Hello,
>
> Kogan, Tamara wrote:
> > Try to change:
> >> object := WebServices.Struct new.
> >> object at: 'id' put: 'foobar'.
> >> foundObjects := FoundObjects new.
> >> foundObjects object: (OrderedCollection with: object).
> > As
> >  object := WebServices.Struct new.
> >  object at: #id put: 'foobar'.
> >  foundObjects := FoundObjects new.
> >  foundObjects object: (OrderedCollection with: object).
> >
> > See the attached test case.
>
> the WSDL wizard created the following x2oBinding:
>
> <struct name="Object" smalltalkClass="Struct">
>    <any maxOccurs="1" minOccurs="0" namespace="##any"
> processContents="lax"></any>
> </struct>
>
> the binding of the testcase includes id/name:
>
> <struct name="Object" >
>    <element name="id" ref="xsd:string" minOccurs="0" />
>    <element name="name" ref="xsd:string" minOccurs="0" />
>    <any aspect="something" minOccurs="0"  />
> </struct>
>
> with this binding and the correct key (#id instead of 'id'),
> I can now
> successfully (un)marshal id/name - thanks!
>
> However, it seems to be impossible to unmarshal <any> content, e.g.
>
>    <object xsi:type="ns:Object">
>       <weight xsi:type="ns0:float">1.0</weight>
>    </object>
>
> is unmarshaled as an empty struct. is it possible to (un)marshal such
> generic content in any way?

The problem is you need an aspect for <any>. The #aspect is used to create Xpath to unmarchal and get the value from an object to marshal.
<element  name="weight" ref="xsd:float" />
<struct name="Object" >
        <element name="id" ref="xsd:string" minOccurs="0" />
        <element name="name" ref="xsd:string" minOccurs="0" />
        <any aspect="weight" minOccurs="0"  />
</struct>

You can try <choice>
<struct name="MyChoice" smalltalkClass="Struct">
 <choice>
        <element name="weight" ref="xsd:float"/>
        <element name="int" ref="xsd:short"/>
 </choice>
</struct>
<struct name="Object" >
        <element name="id" ref="xsd:string" minOccurs="0" />
        <element name="name" ref="xsd:string" minOccurs="0" />
        <any aspect="myChoice" minOccurs="0"  />
</struct>


Tamara

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc