Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Working with SOAP WebServices with dynamic typing

    Given WSDL/XSD schema:
    Code:
    <xsd:complexType name="ArrayOfKeyValueOfstringanyType">
      <xsd:sequence>
        <xsd:element minOccurs="0" maxOccurs="unbounded"
               name="KeyValueOfstringanyType">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="Key" nillable="true" type="xsd:string"/>
              <xsd:element name="Value" nillable="true" type="xsd:anyType"/>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
    And some WSDL/SOAP WebService response with such an object property:
    Code:
    <Properties xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <a:KeyValueOfstringanyType>
      <a:Key>Name</a:Key>
      <a:Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">Тестовый отдел 19</a:Value>
    </a:KeyValueOfstringanyType>
    <a:KeyValueOfstringanyType>
      <a:Key>Parent</a:Key>
      <a:Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">88b4e90c-b9fb-4e30-b180-062e68204b11</a:Value>
    </a:KeyValueOfstringanyType>
    </Properties>
    DataSource transforms this XML with given XSD-schema into such JS-code:
    Code:
    Properties:{
    	'xmlns:a':"http://schemas.microsoft.com/2003/10/Serialization/Arrays", 
    	KeyValueOfstringanyType:[
    		{
    			Key:"Name", 
    			Value: {
    				'i:type': "b:string", 
    				'xmlns:b': "http://www.w3.org/2001/XMLSchema", 
    				xmlTextContent: "some text value"
    			}
    		}, 
    		{
    			Key:"Parent", 
    			Value: {
    				'i:nil': "true"
    			}
    		}
    	]
    }
    This result is pretty straightforward mapping between xml/xsd and JS. I'm not going to say it's incorrent.
    But Value element has standard typing attribute in standard W3C schema ("http://www.w3.org/2001/XMLSchema").
    Wouldn't it be a good idea to create just:
    Code:
    {Key: "Name", Value: "some text value"}
    (without any nested properties) ?

    It turns out that working with SOAP WebServices which returns data with dynamic typing (value _and_ its type in "http://www.w3.org/2001/XMLSchema" schema) is almost impossible.
    I have to write transforResponse method for WS-based DataSource and parse all cases into some simple structure like [{"Name": "some text value", "Parent": null}]. It's a pain.

    So treat this please as a feature request. And what are my options right now except parsing all XSD types on my own?
Working...
X