R
Rodney Garland
Hi All,
I am a relative beginner to Python and am looking for help with sending and
XML message and getting back a return file. The server is:
https://node.deq.state.or.us/node/node.asmx
I have have successfully sent and recieved using the PING, AUTHENTICATE
(send in username and password and return a secuirity token), SOLICIT(send
in information for a query and get a number indicating the query),
GETSTATUS(status of query) using SOAPpy. I am using Python 2.4 on a Window
XP machine.
What I want to do now is download the result of my query using the DOWNLOAD
method. However, I cann't figure out how to do this. I have tried SOAPpy
and httplib and I cann't send the correct XML outgoing message. Any help
with this would be greatly appreciated. Following is the needed outgoing
XML file and my successful SOAPpy code.
Thank you,
Rodney ([email protected])
POST /node/node.asmx HTTP/1.1
Host: node.deq.state.or.us
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: ""
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl"
xmlns:types="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl/encodedTypes"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<q1ownload
xmlns:q1="http://www.ExchangeNetwork.net/schema/v1.0/node.xsd">
<securityToken xsi:type="xsd:string">string</securityToken>
<transactionId xsi:type="xsd:string">string</transactionId>
<dataflow xsi:type="xsd:string">string</dataflow>
<documents href="#id1" />
</q1ownload>
<soapenc:Array id="id1"
xmlns:q1="http://www.ExchangeNetwork.net/schema/v1.0/node.xsd"
soapenc:arrayType="q1:NodeDocument[2]">
<Item href="#id2" />
<Item href="#id3" />
</soapenc:Array>
<q3:NodeDocument id="id2" xsi:type="q3:NodeDocument"
xmlns:q3="http://www.ExchangeNetwork.net/schema/v1.0/node.xsd">
<name xsi:type="xsd:string">string</name>
<type xsi:type="xsd:string">string</type>
</q3:NodeDocument>
<q4:NodeDocument id="id3" xsi:type="q4:NodeDocument"
xmlns:q4="http://www.ExchangeNetwork.net/schema/v1.0/node.xsd">
<name xsi:type="xsd:string">string</name>
<type xsi:type="xsd:string">string</type>
</q4:NodeDocument>
</soap:Body>
</soap:Envelope>
Below is an example of the code that does work.
urlNode = 'https://node.deq.state.or.us/node/node.asmx?op=NodePing'
namespace = 'http://www.ExchangeNetwork.net/schema/v1.0/node.xsd'
server = SOAPProxy(urlNode, namespace)
PING = server.NodePing('Ping')
urlAuth = 'https://node.deq.state.or.us/node/node.asmx?op=Authenticate'
# AUTHENTICATE - Returns a variable with the token
server = SOAPProxy(urlAuth, namespace)
token = server.Authenticate(userId='MYUSERNAME', credential='MYPASSWORD',
authenticationMethod='Invoke')
print token
urlSolicit = 'https://node.deq.state.or.us/node/node.asmx?op=Solicit'
server = SOAPProxy(urlSolicit, namespace)
rowID='0'
maxRows='1000'
service='GetAirMeasurements'
fieldEventStartDate='2005-01-01'
fieldEventEndDate='2005-02-01'
analyteName='PM10'
parameters=[rowID,maxRows,'','','','','','','','','','','','','','','',fieldEventStartDate,fieldEventEndDate,'',analyteName]
transID = server.Solicit(securityToken = token, returnURL = '', request =
'GetAirMeasurements', parameters = parameters)
print transID
I am a relative beginner to Python and am looking for help with sending and
XML message and getting back a return file. The server is:
https://node.deq.state.or.us/node/node.asmx
I have have successfully sent and recieved using the PING, AUTHENTICATE
(send in username and password and return a secuirity token), SOLICIT(send
in information for a query and get a number indicating the query),
GETSTATUS(status of query) using SOAPpy. I am using Python 2.4 on a Window
XP machine.
What I want to do now is download the result of my query using the DOWNLOAD
method. However, I cann't figure out how to do this. I have tried SOAPpy
and httplib and I cann't send the correct XML outgoing message. Any help
with this would be greatly appreciated. Following is the needed outgoing
XML file and my successful SOAPpy code.
Thank you,
Rodney ([email protected])
POST /node/node.asmx HTTP/1.1
Host: node.deq.state.or.us
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: ""
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl"
xmlns:types="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl/encodedTypes"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<q1ownload
xmlns:q1="http://www.ExchangeNetwork.net/schema/v1.0/node.xsd">
<securityToken xsi:type="xsd:string">string</securityToken>
<transactionId xsi:type="xsd:string">string</transactionId>
<dataflow xsi:type="xsd:string">string</dataflow>
<documents href="#id1" />
</q1ownload>
<soapenc:Array id="id1"
xmlns:q1="http://www.ExchangeNetwork.net/schema/v1.0/node.xsd"
soapenc:arrayType="q1:NodeDocument[2]">
<Item href="#id2" />
<Item href="#id3" />
</soapenc:Array>
<q3:NodeDocument id="id2" xsi:type="q3:NodeDocument"
xmlns:q3="http://www.ExchangeNetwork.net/schema/v1.0/node.xsd">
<name xsi:type="xsd:string">string</name>
<type xsi:type="xsd:string">string</type>
</q3:NodeDocument>
<q4:NodeDocument id="id3" xsi:type="q4:NodeDocument"
xmlns:q4="http://www.ExchangeNetwork.net/schema/v1.0/node.xsd">
<name xsi:type="xsd:string">string</name>
<type xsi:type="xsd:string">string</type>
</q4:NodeDocument>
</soap:Body>
</soap:Envelope>
Below is an example of the code that does work.
urlNode = 'https://node.deq.state.or.us/node/node.asmx?op=NodePing'
namespace = 'http://www.ExchangeNetwork.net/schema/v1.0/node.xsd'
server = SOAPProxy(urlNode, namespace)
PING = server.NodePing('Ping')
urlAuth = 'https://node.deq.state.or.us/node/node.asmx?op=Authenticate'
# AUTHENTICATE - Returns a variable with the token
server = SOAPProxy(urlAuth, namespace)
token = server.Authenticate(userId='MYUSERNAME', credential='MYPASSWORD',
authenticationMethod='Invoke')
print token
urlSolicit = 'https://node.deq.state.or.us/node/node.asmx?op=Solicit'
server = SOAPProxy(urlSolicit, namespace)
rowID='0'
maxRows='1000'
service='GetAirMeasurements'
fieldEventStartDate='2005-01-01'
fieldEventEndDate='2005-02-01'
analyteName='PM10'
parameters=[rowID,maxRows,'','','','','','','','','','','','','','','',fieldEventStartDate,fieldEventEndDate,'',analyteName]
transID = server.Solicit(securityToken = token, returnURL = '', request =
'GetAirMeasurements', parameters = parameters)
print transID