python - SOAPpy 的复杂类型问题

标签 python xml soap soappy

我正在尝试从 HP Server Automation 访问我的 WSDL 中定义的函数,我能够获取服务器等,但无法通过 SOAPpy 提取任何需要服务器引用的内容。

import SOAPpy
from SOAPpy import WSDL
from SOAPpy import structType

SOAPpy.Config.debug=1
server = WSDL.Proxy('ServerService.wsdl')

serverRef = structType(name='self', typed=0)
serverRef._addItem('id',SOAPpy.longType(19250001))

print server.getCustAttr(serverRef,key='HPSW_ED_win32_diskspace',useScope=False)

The SOAP envelope generated from this code looks like this:
*** Outgoing 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:xsd2="http://www.w3.org/2000/10/XMLSchema"
  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>
<ns1:getCustAttr xmlns:ns1="http://server.opsware.com" SOAP-ENC:root="1">
<xsd:self>
<id xsi:type="xsd2:long">19250001</id>
</xsd:self>
<useScope xsi:type="xsd:boolean">False</useScope>
<key xsi:type="xsd:string">HPSW_ED_win32_diskspace</key>
</ns1:getCustAttr>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

它应该看起来像这样(通过 SOAPUI 成功运行):

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://server.opsware.com">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:getCustAttr soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
           <self xsi:type="ser:ServerRef">
              <id xsi:type="xsd:long">19250001</id>
           </self>
         <key xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">HPSW_ED_win32_diskspace</key>
         <useScope xsi:type="xsd:boolean">False</useScope>
      </ser:getCustAttr>
   </soapenv:Body>
</soapenv:Envelope>

我认为问题是 xsi:type="ser:ServerRef"没有设置,并且不确定如何使用 SOAPpy 来做到这一点...

最佳答案

有两种不同类型的 soap 样式(RPC literal and Document literal),看起来提到的 soap 服务器只支持 RPC

我在 SOAP 水和 SOAP 水中看到了这个问题。经过一些测试和基准测试,我发现了问题。 ASP.NET 和 soappy。您需要使用 Python 生成一个 rpc 信封,而不是文档文字信封样式。

只是ZSI(The Zolera Soap Infrastructure)适用于 asp.net 和复杂类型。

此命令为您生成客户端代理:

wsdl2py http://terraservice.net/TerraService.asmx?WSDL

您可以在代码中导入生成的模块并使用网络方法。

关于python - SOAPpy 的复杂类型问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5902199/

相关文章:

python - 将 2D Numpy 灰度值数组转换为 PIL 图像

java - jackson 单独使用字段名称对响应进行排序

python - 使用 scikit-learn 重新初始化学习到的线性模型

python - Beautifulsoup4 性能树莓派3

css - 如何将 css 文件和 xml 文件与 GTK3 元素组合

php - Symfony2 使用 besimple/soap-client 包使用 SOAP 服务

java - 如何解析大型 SOAP 响应

php - 如何使用 PHP SOAP 扩展获取 SSL 连接?

python - 如何通过 PyCharm 安装 PyGObject

android - 如何将静态字符串与 XML 字符串资源连接起来?