Kurt Telep
Kurt Telep

Reputation: 729

Complex Type issue with SOAPpy

I'm trying to access a function defined in my WSDL from HP Server Automation, I'm able to get servers/etc, but not able to pull anything that takes a server reference specifically via 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>

And it should look like this ( runs successfully via 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>

I believe the issue is that the xsi:type="ser:ServerRef" is not set, and not really sure how to do that with SOAPpy...

Upvotes: 4

Views: 2199

Answers (1)

pylover
pylover

Reputation: 8055

there are two different types of soap styles(RPC literal and Document literal),looks like the mentioned soap server just supports RPC

i saw this problem with soappy and suds. after some tests and benchmarks,i found the problem. ASP.NET and soappy. you need produce a rpc envelop with python instead document literal envelop style.

just ZSI(The Zolera Soap Infrastructure) works with asp.net and complex types.

this command generates the client proxy for you:

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

and you can import generated modules in your code and use the web methods.

Upvotes: 4

Related Questions