修改suds请求以定位SOAP

时间:2012-02-28 11:31:53

标签: python soap suds

我遇到了python suds尝试创建正确的Suds XML请求的问题:

这是我的suds Code(经过几次试验):

from suds import *
from suds.client import Client
from suds.transport.http import HttpAuthenticated
import logging

url = 'http://ws/webservices/600/ws.asmx?wsdl'
soap_client = Client(url, location='http://ws/webservices/600/ws.asmx')
soap_client.set_options(port='GatewayWebServiceSoap')

person = soap_client.factory.create('checkIfExists') 
person.UserID = 'toni.tester@anywhere.at'
person.SessionID = ''

eventService = soap_client.service.CustomerService(person)

print 'last received:'                                                                                                                                                                                          
print soap_client.last_received()                                                                                                                                                                               
print '-------------------------------------'                                                                                                                                                                                               
print 'last sent:'
print soap_client.last_sent()

这是我的肥皂泡发送的:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://service.example.at/gateway/v6.00" 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:Service>
          <ns0:Service>
             <ns0:SessionID></ns0:SessionID>
             <ns0:UserID>toni.tester@anywhere.at</ns0:UserID>
          </ns0:Service>
       </ns0:Service>
    </ns1:Body>
</SOAP-ENV:Envelope>

这就是WebService所期望的:

<?xml version="1.0" encoding="UTF-8"?>
<GATEWAY xmlns="urn:service-example-at:gateway:v4-00">
    <Service>
        <checkIfExists>
            <SessionID></SessionID>
            <UserID>test</UserID>
        </checkIfExists>
    </Service>
</GATEWAY>

我的问题:

  • 如何更改SOAP-ENV:Envelope - &gt; GATEWAY
  • 如何删除命名空间ns1,ns0?
  • 如何删除正文

1 个答案:

答案 0 :(得分:0)

如果你真的不关心WSDL和东西,你可以轻松自己编写请求生成器,因为xml请求只是一个字符串模板。这就是我did满足我的肥皂需求。