[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Antwort: 'Strange' constructed Webservice. How to process.
Richard,
WSDL2RPG supports element references and I will try to explain how it does
it. Before I start, here are sample request and response messages:
Request message:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:impl="http://wsdl.webservice.wsdl2rpg.tools400.de"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getStructure
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
</getStructure>
</soapenv:Body>
</soapenv:Envelope>
Response message:
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getStructureResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getStructureReturn href="#id0"/>
</getStructureResponse>
<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1:Structure"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://core.webservice.wsdl2rpg.tools400.de">
<address href="#id1"/>
<objBigDecimal xsi:type="xsd:decimal">3</objBigDecimal>
<objInt xsi:type="xsd:int">1</objInt>
<objJavaDate xsi:type="xsd:dateTime">2009-02-11T07:09:24.994
Z</objJavaDate>
<objString xsi:type="xsd:string">Hello, this is a Web
Service!</objString>
<priInt xsi:type="xsd:int">2</priInt>
</multiRef>
<multiRef id="id1"
soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:Address"
xmlns:ns2="http://core.webservice.wsdl2rpg.tools400.de"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<city xsi:type="xsd:string">Entenhausen</city>
<name xsi:type="xsd:string">Donald Duck</name>
<street xsi:type="xsd:string">Dagobert Duck Ave.</street>
<zip xsi:type="xsd:int">11223</zip>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
When WSDL2RPG encounters a reference to another element it saves the
current state of the start callback procedure and returns from it because
there is nothing more it can do:
e.g. <getStructureReturn href="#id0"/>:
---------------------------------------
if (MultiRef_isReference(attrs));
MultiRef_put(
attrs
: http_parser_get_userdata()
: depth
: namespace
: name
: path
: http_parser_get_start_cb()
: http_parser_get_end_cb());
return;
endif;
Procedure 'MultiRef_isReference(attrs)' returns TRUE if there is an
attribute 'href' with a value starting with '#'. The value of the 'href'
attribute is used as the key the callback state is assigned to.
'MultiRef_put(...)' stores the callback state in a 'Map' (key/value pair):
multiRef.isActive = cFalse;
multiRef.userData = i_userData;
multiRef.cbStart = i_cbStart;
multiRef.cbEnd = i_cbEnd;
multiRef.depth = i_depth;
multiRef.name = i_name;
multiRef.namespace = i_namespace;
multiRef.pathLen = 0;
BasicMap_put(g_hMultiRef
: hRef
: %addr(multiRef)
: %size(multiRef));
Notice: Although 'path' is passed to 'MultiRef_put()' is it not used. I
should remove that code.
When the current XML path is '/Envelope/Body' WSDL2RPG watches for
referenced elements:
e.g. <multiRef id="id0"
-----------------------
when (name = 'multiRef' and MultiRef_isData(attrs));
http_parser_switch_cb(
*NULL
: %paddr('WSDL2R94_MultiRef_startCallback')
: %paddr('WSDL2R94_MultiRef_endCallback'));
return;
Notice: So far I thought that referenced elements must be named 'multiRef'
but that may not be true. Hence I probably have to change then 'when'
statement above and remove the comparison between 'name' and 'multiRef'.
When WSDL2RPG encounters a referenced element, it switches the callback
procedures to special 'MultiRef' handler callbacks. The 'MultiRef' handler
callbacks basically restore the state of the callback procedures that
originally hit the referenced element and then forwards the request to the
original callback procedures.
>From an outside view it appears as if the following steps take place:
1. Processing is stopped for elements that references other elements (e.g.
href="#id0").
Current state is saved and assigned to e.g. '#id0'.
2. Normal processing goes on as usual for other elements.
3. If a referenced element is encountered (e.g. id="id0"), normal
processing is interrupted and the state of 1. is restored.
4. Processing goes on with the state of 1.
5. At the end of the referenced element state is switched back to normal
state.
6. Processing goes on as usual.
Feel free to download WSDL2RPG and have a look at module WSDL2R94. It
encapsulates the 'MultiRef' stuff. Instead of using 'BasicMap' you may use
an array to store key/value pairs.
Hope that helps.
Thomas.
ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 10.02.2009 18:41:41:
> Hello all,
>
> I have to use a WS of a new business partner. It uses a construction I
> have never seen until now.
>
> The response has several elements that refer to an array for its child
> elements.
> The 'child' array and the 'parent' element are on the same hierarchy
> level (see attached wsdl and example xml).
>
> Eg.:
> <unitFacilities href="#id2"/>
> <onSiteFacilities href="#id3"/>
> Refers to:
> <soapenc:Array id="id2" soapenc:arrayType="xsd:string[6]">
> <Item>Air Conditioning</Item>
> <Item>Ceiling Fans</Item>
> <Item>Air Conditioning (Some)</Item>
> <Item>Balcony</Item>
> <Item>Carpet</Item>
> <Item>Bathrobes</Item>
> </soapenc:Array>
> <soapenc:Array id="id3" soapenc:arrayType="xsd:string[4]">
> <Item>BBQ's / Braai</Item>
> <Item>Billiard Table</Item>
> <Item>Baby Sitting Assistance</Item>
> <Item>ATM</Item>
> </soapenc:Array>
>
> Ofcourse the value of the array id is dynamic. Next request "#id3" might
> be for "unitFacilities", depending on the data retrieved.
>
> Is there any support in httpapi (expat) for processing this kind of xml?
>
> Any suggestions on what would be the most intelligent way to program
> this, would be very much appreciated! :-)
>
> Regards,
> Richard la Croix
> Hapimag
> Switzerland
>
> http://www.hapimag.com
>
>
> Selber Flüge buchen auf http://flug.hapimag.com
> Book flights personally on http://flight.hapimag.com
>
>
>
>
>
> Diese E-Mail enthält vertrauliche Informationen, die rechtlich
> geschützt sein können. Sie ist nur für den beabsichtigten Empfänger
> bestimmt. Bitte benachrichtigen Sie uns umgehend, falls Sie die E-
> Mail irrtümlich erhalten haben und löschen Sie sie unverzüglich. Besten
Dank.
>
> This e-mail contains confidential information that may be
> privileged. It is for the sole attention and use of the intended
> recipient. Please notify us at once if you have received it in error
> and delete it immediately. Thank you.
>
> Les informations contenues dans cet e-mail sont soumises au secret
> professionnel et ont un caractère strictement confidentiel. Elles
> sont destinées à l'usage exclusif du destinataire. Si cet e-mail
> vous est parvenu par erreur, vous voudrez bien nous en aviser
> immédiatement et le détruire sans délai. Merci d'avance.
> [Anhang "LHR-example.xml" gelöscht von Thomas Raddatz/GfD/DE]
> [Anhang "daeoverbrand.wsdl" gelöscht von Thomas Raddatz/GfD/DE]
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list. To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
--
IMPORTANT NOTICE:
This email is confidential, may be legally privileged, and is for the
intended recipient only. Access, disclosure, copying, distribution, or
reliance on any of it by anyone else is prohibited and may be a criminal
offence. Please delete if obtained in error and email confirmation to the sender.
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------