2012-02-28 157 views
0

我有蟒蛇肥皂水试图建立一个合适的肥皂水XML请求了一个问题:修改肥皂水请求目标SOAP

这是我的泡沫代码(几个试验后):

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 = '[email protected]' 
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>[email protected]</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:信封 - > GATEWAY
  • 我如何删除命名空间NS1,NS0?
  • 我怎么能清除体内

回答

0

如果你真的不关心WSDL和东西,你可以很容易地编写自己请求产生,因为XML请求只是一个字符串模板。这就是我0123.为我的肥皂需求。

+0

对不起,但这不是选项 - 我们的WSDL服务真的很庞大:-) – user966660 2012-03-07 13:30:22