XML Mapping Problem

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

XML Mapping Problem

Postby TriSebastian » Sun Jan 17, 2010 1:41 am

Hi!

I have a sort of recursion problem while deserializing an XML Stream.

I got an xsd file containing the folloing:

<xs:complexType name="credential">
<xs:sequence>
<xs:element minOccurs="0" name="credential" type="xs:string" />
<xs:element name="error" type="xs:boolean" />
<xs:element minOccurs="0" name="errorText" type="xs:string" />
</xs:sequence>

Now I wrote a mapping file containing:

<ClassTypeMapping TypeName="credential" ClassName="XYZCredential" >
<AttributeMapping GetSelector="credential" SetSelector="credential:">
<SubElement>credential</SubElement>
</AttributeMapping>
<AttributeMapping GetSelector="error" SetSelector="error:">
<SubElement>error</SubElement>
</AttributeMapping>
<AttributeMapping GetSelector="errorText" SetSelector="errorText:">
<SubElement>errorText</SubElement>
</AttributeMapping>
</ClassTypeMapping>
"Type and Element names are equal!"

As a result from using this I get
an XYZCredential containing an empty XYZCredential in it's instance variable "credential".

What can I do? Any ideas?

Additional to that I have a problem with a wsdl file
The contained binding definition doesn't contain any style information:
...
<binding name="XYZWebServicePortBinding" type="tns:XYZWebService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getTriceptSoapArray">
<soap:operation soapAction="" />
<input>
<soap:body use="literal" />
</input> ......
Usualy no style Information means style="document".
But there must be something wrong in my application's XML initializations, because the MessageContext's encoder is allways "nil".
Adding <soap:binding style="document" transport="http://schemas.xmlsoap ...
Everything is fine.
Where/How should I tell VAST to use style="document" when handling these bindings?

Thanks a lot in advance!
Sebastian
TriSebastian
 
Posts: 76
Joined: Sun Jul 20, 2008 9:40 pm
Location: Nanaimo, BC, Canada

Re: XML Mapping Problem

Postby Diane Engles » Tue Jan 19, 2010 2:43 pm

Hi Sebastian,

In this case, I don't think you need the SubElement Mapping. It is generally used to map a class attribute to a complexType, which is what credential is in your case. Have you tried removing the SubElement tag from the mapping spec?
Instantiations Smalltalk Support
diane@instantiations.com
Diane Engles
Moderator
 
Posts: 66
Joined: Mon Oct 16, 2006 2:40 pm

Re: XML Mapping Problem

Postby TriSebastian » Wed Jan 20, 2010 3:18 am

Hi Diane,

thank you very much for the advice.
I tried to delete just the SubElement in my mapping spec.
I tried to delete all atrribute mappings in my mapping spec.
But I always get the same result:
aCredential
credential: aCredential
credential: nil
error: nil
errorText: nil
error: false
errorText: ''

The Response looks like this:
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:processCreateSessionResponse xmlns:ns2="http://URL/">
<return>
<credential>SomeCredentialString</credential>
<error>false</error>
<errorText></errorText>
</return>
</ns2:processCreateSessionResponse>
</S:Body>
</S:Envelope>

inspecting information from the mappings:
mapping xml-Name : credential
OrderedCollection(
an AbtAttributeMapping
VA attribute name: 'credential'
Creation method: nil
String conversion method: nil
Object-to-string conversion method: nil
Required: false
NameSpaceURI: 'http://URL/'
an AbtAttributeMapping
VA attribute name: 'error'
Creation method: nil
String conversion method: nil
Object-to-string conversion method: nil
Required: false
NameSpaceURI: 'http://URL/'
XML SubElement: 'error'
XML SubElement key: nil
an AbtAttributeMapping
VA attribute name: 'errorText'
Creation method: nil
String conversion method: nil
Object-to-string conversion method: nil
Required: false
NameSpaceURI: 'http://URL/'
XML SubElement: 'errorText'
XML SubElement key: nil )

mapping xml-Name: processCreateSessionResponse

OrderedCollection(
an AbtAttributeMapping
VA attribute name: 'return'
Creation method: nil
String conversion method: nil
Object-to-string conversion method: nil
Required: false
NameSpaceURI: 'http://URL/'
XML SubElement: 'return'
XML SubElement key: nil )

from the xsd delivered:
.....
....
<xs:complexType name="processCreateSessionResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:credential" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="credential">
<xs:sequence>
<xs:element minOccurs="0" name="credential" type="xs:string" />
<xs:element name="error" type="xs:boolean" />
<xs:element minOccurs="0" name="errorText" type="xs:string" />
</xs:sequence>
</xs:complexType>
.....
.....

Might this be a solution, or is there a chance/way to extend the mapping by information on what the parent tagname of <credential> (here <return>) is?!

Thanks!
Sebastian
TriSebastian
 
Posts: 76
Joined: Sun Jul 20, 2008 9:40 pm
Location: Nanaimo, BC, Canada

Re: XML Mapping Problem

Postby Diane Engles » Tue Jan 26, 2010 6:29 am

Hi Sebastian,

I added an operation I called "processCreateSession to the document literal insurance example, and I was able to get an XYZCredential instance deserialized with the credential instance variable set to a string using the following --

I added this to the schema:

<xsd:complexType name="credential">
<xsd:sequence>
<xsd:element minOccurs="0" name="credential" type="xsd:string" />
<xsd:element name="error" type="xsd:boolean" />
<xsd:element minOccurs="0" name="errorText" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>

This mapping to the insurance example mapping spec file:

<ClassTypeMapping TypeName="credential" ClassName="XYZCredential" >
</ClassTypeMapping>

Error and Error Text were deserialized properly without any explicit mappings.

The types section in the wsdl contained:

<types>
<xsd:schema targetNamespace="urn:SstWSInsurancePolicyInterface"
xmlns:ins="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
schemaLocation="http://vasthost:63001/SstWSInsurancePolicyInterface.xsd" />
<xsd:element name="processCreateSession" type="xsd:string" nillable="true"/>
<xsd:element name="processCreateSessionResponse" type="ins:credential"/>

.......
</xsd:schema>
</types>

and the messages were defined:

<message name="processCreateSession">
<part name="body" element="swsipi:processCreateSession"/>
</message>
<message name="processCreateSessionResponse">
<part name="body" element="swsipi:processCreateSessionResponse"/>
</message>

I invoked it like the about operation:
( service processCreateSession: nil)


If you would like to see the whole example, I can zip it up and send it to you. (There were other modifications to the example files made to complete the operation definition. ) Since I don't have your complete example, I'm not sure what the differences are.

You also mentioned your problem with a binding that did not include style information. I would recommend modifying the method

SstWSEncodingStrategy (class) >>styleFor: so that it returns 'document' as the default style. I also tried this with the insurance example after removing the style attribute from the binding stanza and it seemed to work fine.
Instantiations Smalltalk Support
diane@instantiations.com
Diane Engles
Moderator
 
Posts: 66
Joined: Mon Oct 16, 2006 2:40 pm


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest