Problem mit encoding aus der XML declaration mit SOAPpy

Sockets, TCP/IP, (XML-)RPC und ähnliche Themen gehören in dieses Forum
Antworten
Benutzeravatar
Richard_M
User
Beiträge: 11
Registriert: Samstag 13. Januar 2007, 19:22
Wohnort: Nähe Stuttgart
Kontaktdaten:

Hallo, Ich bin hier auf etwas gestossen, das ich mir nicht so recht erklären kann:
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
Und bekomme die Folgende Antwort:

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 &apos;US-ASCII&apos; does not match encoding from XML declaration &apos;UTF-8&apos;</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': >
Wenn ich die Anfrage aus der oben gezeigten Ausgabe in SoapUI kopiere funktioniert aber alles:
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>
Und nun die Antwort mit SoapUI:

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>
Kennt jemand dieses Verhalten und kann mir einen Tipp geben, wie ich beispielsweise das Encoding vom Serve erfragen kann, und dann in meiner XML declaration anpassen kann?
Vielen Dank, Richard
Antworten