<address> <number>100</number> <street>Spear Street</street> <city>San Francisco</city> <state>CA</state> <zip>94107</zip> <phone> <area>415</area> <exchange>343</exchange> <number>3000</number> </phone> </address>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body s:EncodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <m:getAddressResponse xmlns:m="http://address.examples.org/schema/"> <address> <number>100</number> <street>Spear Street</street> <city>San Francisco</city> <state>CA</state> <zip>94107</zip> <phone> <area>415</area> <exchange>343</exchange> <number>3000</number> </phone> </address> </m:getAddressResponse> </s:Body> </s:Envelope>The following code will access the fields of the complex type returned.
' Assuming env is a pocketSOAP Envelope object, and http is a transport object, and that we've sucessfully built and sent the request.
' parse the response
env.parse http
' address is the first child in the response parameters, so lets grab that first
dim adr
set adr = env.Parameters.Item(0).Value
' now we simply use the ItemByName function on the Nodes collection class to access each contained field
wscript.echo adr.Nodes.ItemByName("number").Value & " " & adr.Nodes.ItemByName("street").value
wscript.echo adr.Nodes.ItemByName("city").Value & " " & adr.Nodes.ItemByName("state").value
wscript.echo adr.Nodes.ItemByName("zip").Value
' as phone is a nested complex type, we grab the phone node, then look at its children
dim ph
set ph = adr.Nopdes.ItemByName("phone")
wscript.echo ph.Nodes.ItemByName("area").value & " " & ph.Nodes.ItemByName("exchange").value & " " & ph.Nodes.ItemByName("number").value
dim env, adr, ph
set env = CreateObject("pocketSOAP.Envelope.2")
env.SetMethod "addAddress", "http://address.example.org/"
set adr = env.Parameters.Create ("address", empty)
adr.Nodes.Create "number", "100"
adr.Nodes.Create "street", "Spear Street"
adr.Nodes.Create "city",   "San Francisco"
adr.Nodes.Create "state",  "CA"
adr.Nodes.Create "zip",    "94107"
set ph = adr.Nodes.Create ("phone", empty)
ph.Nodes.Create "area", "415"
ph.Nodes.Create "exchange", "343"
ph.Nodes.Create "number", "3000"
wscript.echo env.serialize
Copyright © Simon Fell, 2000-2004. All rights reserved.