I'm trying to generate soap request simliar to this :
I've been able to access the server via soappy , but i didn't find a good example to to pass nest xml parameter to GetStopMonitoringService
I would be if someone can provide some info/like to an example .
thanks .
A sample soap request i need to gerenate via python :
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:acsb="http://www.ifopt.org.uk/acsb" xmlns:datex2="http://datex2.eu/schema/1_0/1_0" xmlns:ifopt="http://www.ifopt.org.uk/ifopt" xmlns:siri="http://www.siri.org.uk/siri" xmlns:siriWS="http://new.webservice.namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="./siri">
<SOAP-ENV:Header />
<SOAP-ENV:Body>
<siriWS:GetStopMonitoringService>
<Request xsi:type="siri:ServiceRequestStructure">
<siri:RequestTimestamp>2012-10-31T09:39:39.480+02:00</siri:RequestTimestamp>
<siri:RequestorRef xsi:type="siri:ParticipantRefStructure">KLM12345</siri:RequestorRef>
<siri:MessageIdentifier xsi:type="siri:MessageQualifierStructure">0100700:1351669188:4684</siri:MessageIdentifier>
<siri:StopMonitoringRequest version="IL2.6" xsi:type="siri:StopMonitoringRequestStructure">
<siri:RequestTimestamp>2012-10-31T09:39:39.480+02:00</siri:RequestTimestamp>
<siri:MessageIdentifier xsi:type="siri:MessageQualifierStructure">0</siri:MessageIdentifier>
<siri:PreviewInterval>PT1H</siri:PreviewInterval>
<siri:MonitoringRef xsi:type="siri:MonitoringRefStructure">39795</siri:MonitoringRef>
<siri:MaximumStopVisits>100</siri:MaximumStopVisits>
</siri:StopMonitoringRequest>
</Request>
</siriWS:GetStopMonitoringService>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I use this python code :
#!/usr/bin/python
from SOAPpy import SOAPProxy
import httplib
httplib.HTTPConnection.debuglevel = 1
soapaction='http://siri.motrealtime.co.il:8081/Siri/SiriServices/GetStopMonitoringService'
namespace='http://www.ifopt.org.uk/ifopt'
server = SOAPProxy('http://siri.motrealtime.co.il:8081/Siri/SiriServices',soapaction=soapaction,namespace=namespace)
Request = {
'RequestTimestamp':"2014-02-04T09:39:39.480+02:00",
'RequestorRef':"AG566778",
'MessageIdentifier':"0100700:1351669188:4684",
'StopMonitoringRequest':
{'version':"IL2.6",
'RequestTimestamp' :"2014-02-04T09:39:39.480+02:00",
'MessageIdentifier':0,
'PreviewInterval':"PT1H",
'MonitoringRefStructure':21705,
'MaximumStopVisits':100}
}
server.soapproxy.config.dumpSOAPOut = 1
server.soapproxy.config.dumpSOAPIn = 1
print server.GetStopMonitoringService(Request = Request)
but it still doesn't work
I read the source code to figure this out. I recommend doing the same when you are stuck!
The essential answer to your question (for SOAPpy) is that you need to use a "structType" in order to create a nesting. Here's an example code snippet where I add a soap header, and in that header I've nested a "SessionHeader" node, and within that a "sessionId" node.
from SOAPpy import WSDL, Types as soapTypes
....
soapProxy = server.soapProxy._sa( "urn:sessionid" )
soapHeader = soapTypes.headerType()
soapHeader.SessionHeader = soapTypes.structType( None, "SessionHeader" )
soapHeader.SessionHeader.sessionId = soapTypes.stringType( sessionId )
soapProxy = soapProxy._hd( soapHeader )
server.soapproxy = soapProxy
That produces this SOAP (well, the header section of the xml):
<SOAP-ENV:Header>
<xsd:SessionHeader SOAP-ENC:root="1">
<sessionId xsi:type="xsd:string">345423534532774</sessionId>
</xsd:SessionHeader>
</SOAP-ENV:Header>
The same kind of thing could be achieved with the soap body.
Note that anywhere you see "SessionHeader" or "sessionid" here, that is an arbitrary customization. Those could have whatever names you want for your own purposes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With