#10 Is there a way to use rpcvar to return heterogeneous Maps?

open
nobody
None
5
2006-03-10
2006-03-10
Kenneth Cox
No

My apache-based server uses tclsoap to implement
rpc-style web services. I'm trying to use rpcvar to
generate something that I can consume from Java using
Apache Axis and not too much work. I came up with this:

rpcvar::typedef -namespace
"http://xml.apache.org/xml-soap" {
key string
value string
} mapItem
rpcvar::typedef -namespace
"http://xml.apache.org/xml-soap" {
items mapItem()
} Map

set l {}
lappend l [list key a value 1]
lappend l [list key b value 2]
lappend l [list key c value 3.0]
return [wrap Map [list items $l]]

But this means that all the elements are deserialized
as strings. I want them to be Boolean, Int, Calendar,
etc. All that has to happen for Axis to be happy is
for the elements to be named like so:

<items>
<item>
<key>k</key>
<value>v</value>
</item>
</items>

Can I do that using rpcvar without making the
collection homogeneous?

Discussion

  • Subba Reddy  Madireddygari

    How to send the complex Type "ArrayOfKeyValue"? What is the tcl data
    type struct for this type complex type?
    2. How to pass this complex type parameter to soap method call? The complex
    type format is defined in the wsdl as mentioned in the "What is the
    expected output?".

    Here how to generate and send the
    subelements <option><item><key/><value/></item></option>
    using tclsoap at method call.

     
  • Subba Reddy  Madireddygari

    How to send the complex Type parameter - repeated "sub record" in a method - tclsoap Options

    What steps will reproduce the problem?
    I am trying tclsoap and tclws (both). But, tclws generated request has
    xs: at subelements, so trying with tclsoap.
    But, stuck with complex types - SOAP request with repeated "sub
    record"

    1. How to send the complex Type "ArrayOfKeyValue"? What is the tcl
    data
    type struct for this type complex type?
    2. How to pass this complex type parameter to soap method call? The
    complex
    type format is defined in the wsdl as mentioned in the "What is the
    expected output?".

    What is the expected output? What do you see instead?
    Expected soap request -
    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-
    instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:urn="urn:emsprov">
    <soapenv:Header/>
    <soapenv:Body>
    <urn:getDevice
    soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <transactionID xsi:type="xsd:string">1</transactionID>
    <deviceUID xsi:type="xsd:string">1</deviceUID>
    <options xsi:type="urn:ArrayOfKeyValue">
    <!--Zero or more repetitions:-->
    <item xsi:type="urn:KeyValue">
    <key xsi:type="xsd:string">k1</key>
    <value xsi:type="xsd:string">v1</value>
    </item>
    </options>
    </urn:getDevice>
    </soapenv:Body>
    </soapenv:Envelope>

    WSDL -
    <types>

    <schema
    targetNamespace="urn:emsprov"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:ns="urn:emsprov"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

    <xsd:complexType name="KeyValue">
    <xsd:sequence>
    <xsd:element name="key" type="xsd:string"/>
    <xsd:element name="value" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="ArrayOfKeyValue">
    <xsd:sequence>
    <xsd:element minOccurs="0" maxOccurs="unbounded" name="item"
    type="ns:KeyValue"/>
    </xsd:sequence>
    </xsd:complexType>

    </schema>
    </types>
    <message name="getDeviceRequest">
    <part name="transactionID" type="xsd:string"></part>
    <part name="deviceUID" type="xsd:string"></part>
    <part name="options" type="ns:ArrayOfKeyValue"></part>
    </message>

    What version of the product are you using? On what operating system?
    tclsoap (1.6.7)
    WebServices-1.1.2 (tclws)
    tDOM-0.8.2
    tclsh8.5
    x86_64 x86_64 x86_64 GNU/Linux SUSE

    Please provide any additional information below.
    Expected SOAP request is -
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
    envelope/" xmlns:ns0="urn:emsprov" xmlns:xsd="http://www.w3.org/2001/
    XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <ns0:getDevice>
    <transactionID soapenv:encodingStyle="http://schemas.xmlsoap.org/
    soap/encoding/" xsi:type="xsd:string">1</transactionID>
    <deviceUID soapenv:encodingStyle="http://schemas.xmlsoap.org/
    soap/encoding/" xsi:type="xsd:string">1</deviceUID>
    <options soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/
    encoding/" xsi:type="ns0:ArrayOfKeyValue">
    <item xsi:type="ns0:KeyValue">
    <key xsi:type="xsd:string">Key1</key>
    <value xsi:type="xsd:string">Value1</value>
    </item>
    </options>
    </ns0:getDevice>
    </soapenv:Body>
    </soapenv:Envelope>

    Here how to generate and send the
    subelements <option><item><key/><value/></item></option>

    Please adivse with any information.

    --
    ~ Subba

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks