开发者

How do I call IBM IMM methods using SOAPpy?

开发者 https://www.devze.com 2023-03-07 00:56 出处:网络
I\'m trying to use SOAPpy to call various SOAP methods of an IBM IMM (Integrated Management Module). Unfortunately I\'m rather new to SOAP and can\'t figure it out at all.

I'm trying to use SOAPpy to call various SOAP methods of an IBM IMM (Integrated Management Module). Unfortunately I'm rather new to SOAP and can't figure it out at all.

I don't have any kind of WSDL, so I've had to resort to watching to see what my browser does when it makes the various requests.

The actual call that's made looks like:

POST /wsman HTTP/1.1
Host: 192.168.0.166
Connection: keep-alive
Referer: http://192.168.0.166/
Content-Length: 857
Origin: http://192.168.0.166
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Ubuntu/10.10 Chromium/11.0.696.65 Chrome/11.0.696.65 Safari/534.24
Content-Type: text/xml
session_id: 54891711-7ccc-44ce-a903-48a91598b492
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: session_id=none


<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">
  <SOAP-ENV:Header>
    <wsa:To>http://192.168.0.166/wsman</wsa:To>
    <wsa:ReplyTo>
      <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
    </wsa:ReplyTo>
    <wsman:ResourceURI>http://www.ibm.com/iBMC/sp/Tasks</wsman:ResourceURI>
    <wsa:Action>http://www.ibm.com/iBMC/sp/Tasks/GetKVMStatus</wsa:Action>
    <wsa:MessageID>dt:1305665818978</wsa:MessageID>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <GetKVMStatus xmlns="http://www.ibm.com/iBMC/sp/Tasks" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"></GetKVMStatus>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

and the response:

HTTP/1.1 200 OK
Content-Type: application/soap+xml;charset=UTF-8
Content-Length: 884
Date: Tue, 17 May 2011 20:56:13 GMT
Server: lighttpd/1.4.13

<?xml version="1.0"?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" 
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wxf="http://schemas.xmlsoap.org/ws/2004/09/transfer">
    <s:Header>
        <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
        <wsa:Action>http://www.ibm.com/iBMC/sp/Tasks/GetKVMStatusResponse</wsa:Action>
        <wsa:RelatesTo>dt:1305665818978</wsa:RelatesTo>
        <wsa:From><wsa:Address>http://192.168.0.166/wsman</wsa:Address></wsa:From>
        <wsa:MessageID>uuid:db591e0e-36dd-459f-9cec-68a19a79318e</wsa:MessageID>
    </s:Header>
    <s:Body>
        <GetKVMStatusResponse>
        <ActiveSessions>0</ActiveSessions>
        <MaxSessions>4</MaxSessions>
        <Encrypted>0</Encrypted>
        <HasLicense>1</HasLicense>
        <HasPrivilege>1</HasPrivilege>
        <DisableHighSpeed>0</DisableHighSpeed>
        </GetKVMStatusResponse>
    </s:Body>
</s:Envelope>

I'm trying to generate this request properly using SOAPpy but I'm not get anywhere at all and I have no idea what to do or change to make this request. Here's what I've tried so far:

>>> sess = imm.ImmWeb()
Session ID: 8b3af28d-a746-4fc5-af02-b4560f85cac1
>>> server = SOAPpy.SOAPProxy('http://imm/wsman',namespace='http://www.ibm.com/iBMC/sp/Tasks')
>>> server.transport.cookies['session_id'] = '3f19329f-468b-4c86-b6e7-2197b1ed62aa'
>>> server.invoke('http://www.ibm.com/iBMC/sp/Tasks/GetKVMStatus', {})
*** Outgoing HTTP headers **********************************************
POST /wsman HTTP/1.0
Host: imm
User-agent: SOAPpy 0.12.4 (http://pywebsvcs.sf.net)
Content-type: text/xml; charset=UTF-8
Content-length: 484
SOAPAction: "http://www.ibm.com/iBMC/sp/Tasks/GetKVMStatus"
************************************************************************
*** 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:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>
<SOAP-ENV:Body>
<ns1:http://www.ibm.com/iBMC/sp/Tasks/GetKVMStatus xmlns:ns1="http://www.ibm.com/iBMC/sp/Tasks" SOAP-ENC:root="1">
<v1>
</v1>
</ns1:http://www.ibm.com/iBMC/sp/Tasks/GetKVMStatus>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
******************************************************开发者_如何学编程******************
«««traceback»»»
SOAPpy.Errors.HTTPError: <HTTPError 400 Bad Request>


it will be much better to use the WSDL file on the remote server to specify the methods (functions) and their corresponding parameters and data types.

Additionally, you will have the opportunity to know exactly the name space, encoding and formatting of the SOAP connection to be established.

Try using:

SERVER=SOAPpy.WSDL.Proxy('http://remote.server.url/service.wsdl')

Using the SOAPpy.Proxy directly, will make it a necessity to add the correct parameters to the server that you are talking to.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号