私はこのコードを実行しようとすると:無効SUDS封筒
mmurl = 'http://server/_mmwebext/mmwebext.dll?WSDL?server=localhost'
mmclient = Client(mmurl, plugins=[EnvelopeFixer()])
loginResult = mmclient.service[1].Login(u'localhost', u'user', u'pass')
次エンベロープが作成されます。
<SOAP-ENV:Envelope xmlns:ns0="http://menandmice.com/webservices/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:Login>
<ns0:server>localhost</ns0:server>
<ns0:loginName>user</ns0:loginName>
<ns0:password>pass</ns0:password>
</ns0:Login>
</ns1:Body>
</SOAP-ENV:Envelope>
返す:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Invalid command.</faultstring>
<detail>
<mmfaultdetails>
<message>Invalid command.</message>
<errorcode>5001</errorcode>
</mmfaultdetails>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
が、私はそれを変更した場合をsoapUI to
<SOAP-ENV:Envelope xmlns:ns0="http://menandmice.com/webservices/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns0:Login>
<ns0:server>localhost</ns0:server>
<ns0:loginName>user</ns0:loginName>
<ns0:password>pass</ns0:password>
</ns0:Login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
それは私の質問は、私は私がオーバー送られたXMLを変更することができるかどうかを確認するために、これを試してみました<SOAP-ENV:Body>
代わりの<ns1:Body>
としてbodyタグを作成するために泡を強制したり
であることができますされ、正常
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<LoginResponse xmlns="http://menandmice.com/webservices/">
<session>UEk6A0UC5bRJ92MqeLiU</session>
</LoginResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
を返します。ワイヤーとwiresharkを使用してトラフィックを盗聴し、送信されたメッセージを変更していないことが判明しました。私は、コンソールにプリントアウトを参照してくださいので、送付方法は
class EnvelopeFixer(MessagePlugin):
def sending(self, context):
# context is the envelope text
print type(context)
context.envelope = context.envelope.upper()
print context.envelope
return context
確実に呼び出されている私は送る代わりに整列化を使用するようにEnvelopeFixerを変更し、それはとてもトリック
class EnvelopeFixer(MessagePlugin):
def marshalled(self, context):
root = context.envelope.getRoot()
envelope = root.getChild("Envelope")
envelope.getChildren()[1].setPrefix("SOAP-ENV")
print envelope.getChildren()[1]
return context
を行っているようです今はbody要素の接頭辞を変更して、サーバーに必要なものに準拠させました。喜び!
こんにちはdavideagle、私はあなた自身のヘッダーを変更するために投稿を使用しました。しかし、私はsuds.clientのためのデバッグモードに泡を設定し、コンテキストは私のニーズに応じて変更されますが表示されます。しかし、泡は以前のものをまだ送っています。手伝って頂けますか? –
setup.py buildとsetup.pyを再度実行する前に、以前のeggファイルを削除しましたか? – davideagle
なぜそれをする必要がありますか?私は 'virtualenv'を使い、' pip install suds'を使っています。 –