INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to code data for a SOAP array

How to code data for a SOAP array

(OP)
Hello Folks!
Env: XP PRO, JScript, SOAP, WSDL, XML

I have to query the status of two devices (SEP0017593F52C4, SEP0007EB9F1118) using a SOAP RPC. The device list is suppose to be coded in a SOAP string array item.
Here is the WSDL:

CODE

The WSDL def for the select items array:
- <complexType name="CmSelectionCriteria">
- <sequence>
  <element name="MaxReturnedDevices" nillable="true" type="xsd:unsignedInt" />
  <element name="Class" nillable="true" type="xsd:string" />
  <element name="Model" nillable="true" type="xsd:unsignedInt" />
  <element name="Status" type="xsd:string" />
  <element name="NodeName" nillable="true" type="xsd:string" />
  <element name="SelectBy" type="xsd:string" />
  <element name="SelectItems" nillable="true" type="tns:SelectItems" />
  </sequence>
  </complexType>

- <complexType name="SelectItem">
- <sequence>
  <element name="Item" type="xsd:string" />
  </sequence>
  </complexType>
  
- <complexType name="SelectItems">
- <complexContent>
- <restriction base="soapenc:Array">
  <attribute ref="soapenc:arrayType" wsdl:arrayType="tns:SelectItem[]" />
  </restriction>
  </complexContent>
  </complexType>
  

The example I was told to use is:

CODE

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:tns="http://schemas.cisco.com/ast/soap/"
  xmlns:types="http://schemas.cisco.com/ast/soap/encodedTypes"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<tns:AstHeader> <SessionId xsi:type="xsd:string">613</SessionId> </tns:AstHeader>
</soap:Header>
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org
/soap/encoding/">
<tns:SelectCmDevice>
<StateInfo xsi:type="xsd:string"/>
<tns:CmSelectionCriteria xsi:type="tns:CmSelectionCriteria">
<MaxReturnedDevices xsi:type="xsd:unsignedInt">200</MaxReturnedDevices>
<NodeName xsi:type="xsd:string"/>
<SelectBy xsi:type="xsd:string">Name</SelectBy>
<SelectItems soapenc:arrayType="tns:SelectItem[1]" xsi:type="soapenc:Array">
<item xsi:type="tns:SelectItem">
<Item xsi:type="xsd:string">SEP0017593F52C4</Item>
</item> <item xsi:type="tns:SelectItem">
<Item xsi:type="xsd:string">SEP0007EB9F1118</Item>
</item>
</SelectItems>
</tns:CmSelectionCriteria>
</tns:SelectCmDevice>

I have some confusion so here are a couple of questions:
1) The above example worked but I noticed I have 2 items and SelectItems had "tns:SelectItem[1]". What does this "[1]" specify in this case.
 I was thinking it limits the number of items you are transmitting but that can't be the case because the RPC processed the 2 devices correctly.
 So what is that[1]?
2) Is there a shorter way to code this rather than all this code for each item inthe SOAP array?
<SelectItems soapenc:arrayType="tns:SelectItem[1]" xsi:type="soapenc:Array">
<item xsi:type="tns:SelectItem">
<Item xsi:type="xsd:string">SEP0017593F52C4</Item>
</item> <item xsi:type="tns:SelectItem">
<Item xsi:type="xsd:string">SEP0007EB9F1118</Item>
</item>
</SelectItems>

I tried this way but it only processes the last item in the list: SEP0007EB9F1118
<SelectItems soapenc:arrayType="tns:SelectItem[2]" xsi:type="soapenc:Array">
<item xsi:type="tns:SelectItem">
<Item xsi:type="xsd:string">SEP0017593F52C4</Item>
<Item xsi:type="xsd:string">SEP0007EB9F1118</Item>
</item>
</SelectItems>
</tns:CmSelectionCriteria>
</tns:SelectCmDevice>

 
 

RE: How to code data for a SOAP array

[0] >The example I was told to use is:
If that works, I would say cisco's that service does not respect its own typed definition on the elements I mentioned in your other thread! But, I am not here to seem critical to it: cisco does whatever they think fit.

[1] Q1:>What does this "[1]" specify in this case.
A1: On the face of it, it should specify the dimension (rank) of the contained "item" nodes (the named is not constraint, though). From the example you're told to use, it should theoretically better scripted like this:
    soapenc:arrayType="tns:SelectItem[2]"
But, would tns:SelectItem[1] work? It probably would. The dimension scripted there is only suggestive (soap 1.1): its matching/disparity is not under the scrutiny per w3c schema (xsd) data typing. It would be up to the application to accept it or not. Its validity would be application-level. If it accepts it, it is just fine.

[2] Q2: >Is there a shorter way to code this rather than all this code for each item inthe SOAP array? ...
It is possible but it is up to the authoring decision. In the hypothetical format, you've to have to modify the wsdl which is out of the client's control and is none of the client's business.

[2.1] Off-hand, it would look something like this instead for the corresponding type.

<complexType name="SelectItems">
  <complexContent>
    <restriction base="soapenc:Array">
      <sequence>
        <element name="Item" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
      </sequence>
      <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]" />
    </restriction>
  </complexContent>
</complexType>

RE: How to code data for a SOAP array

(OP)
Thanks Tsuji!!! I appreciate your comments and agree - yes - Cisco doesn't respect normal and proper SOAP procedures.
This is part of the API set for CallManager.
Their API is truly horrific and unfortunately, it was the first SOAP API I worked on.
:(
It's truly a bad example to have to work with as your first SOAP interface.
Thanks again for all your help - I really appreciate it.
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close