python - 我的 Python SOAPpy 网络服务调用有什么问题?

标签 python wsdl soappy

我正在尝试使用 Python 解释器中的以下代码调用一个简单的 SOAP 网络服务:

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. ---&gt;
           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 消息不正确的原因方面都是理想的。

谢谢!

最佳答案

你的电话对我来说似乎没问题,我认为这可能是一个肥皂问题或配置错误的服务器(虽然我没有彻底检查过)。

该文档还提出了 soappy 和 webservicex.net 之间的不兼容性: http://users.jyu.fi/~mweber/teaching/ITKS545/exercises/ex5.pdf

在这种特定情况下,我将如何解决这个问题?

import urllib

url_handle = urllib.urlopen( "http://www.webservicex.net/whois.asmx/GetWhoIS?HostName=%s" \
                             % ("www.google.com") )
print url_handle.read()

关于python - 我的 Python SOAPpy 网络服务调用有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/679302/

相关文章:

可用服务的 Python zeep 概述

python - 在 SOAPpy 中启用详细日志记录

python - 如何使用 SOAPpy/Python 将 SSL 证书传递给 SOAP 服务器

python - python打印网页源码

Python:strptime() 格式时区字段未按预期工作

python - Pandas :使用字典(包括运算符)从数据框中返回列子集

eclipse - 如何让 Eclipse 忽略 WSDL 文件中的错误?

python - PyInstaller 无法包含 C :\Python27\Lib 中的某些模块

WCF:如何在没有 WSDL:import 的情况下生成单个 WSDL 文档?

python - 安装 SOAPpy 模块的困难