kartagis / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

How to extract SOAP response using pysimplesoap? #118

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am new on using pysimplesoap. I am succeed using pysimplesoap to generate a 
soap request to a SOAP server, and the soap server is responded correctly, 
however, I do not know how to extract the information returned.

This is my code on pysimplesoap for the request

> from pysimplesoap.client import SoapClient
> client = 
SoapClient(location="http://192.168.206.111:8998/axis2/services/SecurityService"
, action="", namespace="http://www.labtest.com/Security", ns="ns3")
> response = client.call("login", ("ns3:loginName", "administrator"), 
("ns3:password", "admin"))
The SOAP response is in below format.

   <soapenv:Envelope
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Body>
            <n:loginResponse
                xmlns:n="http://www.labtest.com/Security"
                xmlns:n0="http://www.labtest.com/Types">
                <n:errorCode>
                    <n0:hasError>
                        false
                        </n0:hasError>
                    <n0:status>
                        STATUS_SUCCESS
                        </n0:status>
                    </n:errorCode>
                <n:authorizationToken>
                    <n0:token>
                        6430303938366138316265646532313138623866353235343030346130653330
                        </n0:token>
                    <n0:securityPrivileges>
                        <n0:values>
                            <n0:securityAttribute>
                                SUPER_USER_ACCESS
                                </n0:securityAttribute>
                            <n0:accessRights>
                                <n0:values>
                                    FULL_CONTROL
                                    </n0:values>
                                </n0:accessRights>
                            </n0:values>
                        </n0:securityPrivileges>
                    </n:authorizationToken>
                </n:loginResponse>
            </soapenv:Body>
        </soapenv:Envelope>

I tried to use the print response or print (response), but nothing show up.

Original issue reported on code.google.com by paul...@gmail.com on 26 Sep 2013 at 7:37

GoogleCodeExporter commented 8 years ago
Response should be a SimpleXmlElement in this case

You could access the tags using the just getting the attributes or calling it:

response.authorizationToken.token

or

response("authorizationToken")("token")

To "see" the values, you need to convert them to strings:

str(response.authorizationToken.token)

For more info you can see the example in the wiki:

http://code.google.com/p/pysimplesoap/wiki/SoapClient#Raw_example

Let me know if this solved your issue

Original comment by reingart@gmail.com on 27 Sep 2013 at 8:44

GoogleCodeExporter commented 8 years ago
Closed due inactivity, if you need anything else, just comment or open a new 
issue.

Original comment by reingart@gmail.com on 22 Jan 2014 at 4:45