Ich mache eine Anfrag auf einwn WS:
Code: Alles auswählen
import SOAPpy
proxy = SOAPpy.WSDL.Proxy("http://www.neurofuzz.com/modules/cryptoService/cryptoSOAP.php?wsdl")
proxy.soapproxy.config.dumpSOAPOut = 1
proxy.soapproxy.config.dumpSOAPIn = 1
def exploreService():
result=proxy.methods.keys()
i=0
while i< len(result):
print result[i]
printMethods(result[i])
i=i+1
def printMethods(methodName):
callinfo= proxy.methods[methodName]
i=0
while i< len(callinfo.inparams):
print callinfo.inparams[i].name
print callinfo.inparams[i].type
i=i+1
exploreService()
Answer= proxy.encrypt(string='Hallo', key='Welt')
print Answer
Code: Alles auswählen
decrypt
string
(u'http://www.w3.org/2001/XMLSchema', u'string')
key
(u'http://www.w3.org/2001/XMLSchema', u'string')
encrypt
string
(u'http://www.w3.org/2001/XMLSchema', u'string')
key
(u'http://www.w3.org/2001/XMLSchema', u'string')
*** Outgoing SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<ns1:encrypt xmlns:ns1="urn:encryptwsdl" SOAP-ENC:root="1">
<string xsi:type="xsd:string">Hallo</string>
<key xsi:type="xsd:string">Welt</key>
</ns1:encrypt>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************************************************************************
*** Incoming SOAP ******************************************************
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">error in msg parsing:
Charset from HTTP Content-Type 'US-ASCII' does not match encoding from XML declaration 'UTF-8'</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
************************************************************************
Traceback (most recent call last):
File "/home/Richard/workspace/WebServices/W7/myCrypt_client.py", line 24, in ?
Answer= proxy.encrypt(string='Hallo', key='Welt')
File "/usr/lib/python2.3/site-packages/SOAPpy/Client.py", line 470, in __call__
return self.__r_call(*args, **kw)
File "/usr/lib/python2.3/site-packages/SOAPpy/Client.py", line 492, in __r_call
self.__hd, self.__ma)
File "/usr/lib/python2.3/site-packages/SOAPpy/Client.py", line 406, in __call
raise p
SOAPpy.Types.faultType: <Fault Client: error in msg parsing:
Charset from HTTP Content-Type 'US-ASCII' does not match encoding from XML declaration 'UTF-8': >
Nochmal die Anfrage:
Code: Alles auswählen
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<ns1:encrypt xmlns:ns1="urn:encryptwsdl" SOAP-ENC:root="1">
<string xsi:type="xsd:string">Hallo</string>
<key xsi:type="xsd:string">Welt</key>
</ns1:encrypt>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Code: Alles auswählen
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:encryptResponse xmlns:ns1="urn:encryptwsdl">
<return xsi:type="xsd:string">4e7ac34fed1186157acc064e776a4a7358aa565da98b1de20458e4eff7b3c2fdb1bd0357ec</return>
</ns1:encryptResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Vielen Dank, Richard