我正在尝试使用 Python 解释器中的以下代码调用简单的 SOAP Web 服务:
from SOAPpy import WSDL
wsdl = "http://www.webservicex.net/whois.asmx?wsdl"
proxy = WSDL.Proxy(wsdl)
proxy.soapproxy.config.dumpSOAPOut=1
proxy.soapproxy.config.dumpSOAPIn=1
proxy.GetWhoIS(HostName="google.com")
(是的,我是 Python 的新手,正在做 Diveintopython 的事情......)
对 GetWhoIS 方法的调用失败 - 否则我不会在这里问,我猜。这是我传出的 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>
<GetWhoIS SOAP-ENC:root="1">
<HostName xsi:type="xsd:string">google.com</HostName>
</GetWhoIS>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
这是传入的响应。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>
System.Web.Services.Protocols.SoapException:
Server was unable to process request. --->
System.ArgumentNullException: Value cannot be null.
at whois.whois.GetWhoIS(String HostName)
--- End of inner exception stack trace ---
</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
(手动格式化以便于阅读)
谁能告诉我我做错了什么?
理想情况下,无论是就 SOAPpy 的使用而言,还是 SOAP 消息不正确的原因。
谢谢!