|
From: Joshua B. <JRB...@lb...> - 2004-12-14 22:16:05
|
Basically if you don't typecode the request ZSI is going to serialize
everything thru "Any" which is going to map the python type
to a SOAP type. If you want to specify the serialization you'll need to
do so via a typecode like this:
import sys
from ZSI.client import Binding
from ZSI import TC
class Request(str):
typecode = TC.String("wideip_name")
def AddPVS():
b =
Binding(tracefile=sys.stdout,port=443,auth=(1,"username","password"),host
= "3dns.srv.metro1.com", ssl=1)
request = Request("wideipname")
a=b.add_pool_virtual_server(request)
return a
TEST=AddPVS()
print TEST
_________________________________ Tue Dec 14 14:06:06 2004 REQUEST:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
<SOAP-ENV:Body>
<add_pool_virtual_server>
<wideip_name id="504ea0" xsi:type="xsd:string">wideipname</wideip_name>
</add_pool_virtual_server>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
-josh
E Lenny Brown wrote:
>I am trying to use the Binding class to send a simple request to a SOAP
>server.
>
>What it is expecting in XML looking like :
>
><wideip_name xsi:type="xsd:string">my_wideip</wideip_name>
>
>For the life of me, I cannot get my request formatted correctly.
>
>Here is an example of my sorry attempts:
>
>-------------------------------------------------------------------------------
>
>import sys
>from ZSI.client import Binding
>from ZSI import TC
>
>def AddPVS():
> b =
>Binding(tracefile=sys.stdout,url='https://3dns.srv.metro1.com/iControl/iControlPortal.cgi',port=443,auth=(1,"username","password"),host = "3dns.srv.metro1.com", ssl=1)
> b.SetNS("urn:iControl:ITCMGlobalLB/Wideip")
> request={}
> request['wideip_name']="wideipname"
> a=b.add_pool_virtual_server(request)
> return a
>
>TEST=AddPVS()
>print TEST
>
>---------------------------------------------------------------------------------
>That creates:
>
><SOAP-ENV:Body>
><add_pool_virtual_server>
><E40326a44>
><SOAP-ENC:string id="402dee08">wideipname</SOAP-ENC:string>
></E40326a44>
></add_pool_virtual_server>
></SOAP-ENV:Body>
>
>
>Please explain to poor brain-damaged me what I am missing.
>
>Lenny Brown
>
>
|