2012-02-28 207 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