Python and SOAP

J

JuiceMan

Hi, i've been trying to access the my company's SOAP webservice with
no luck.
I'm using the httplib library.

This is my code:



from httplib import HTTP
from urllib import quote

# Establish SOAP data

SOAPdata = '<?xml version="1.0" encoding="utf-8"?>'
SOAPdata = '<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
SOAPdata = SOAPdata + '\n <soap:Body>'
SOAPdata = SOAPdata + '\n <checkPassword
xmlns="COM.COAIR.WWW.Technology.CoWebServices.COWSEmployeeServiceCenter">'
SOAPdata = SOAPdata + '\n <employeeID>XXXXXX</employeeID>'
SOAPdata = SOAPdata + '\n <password>XXXXXX</password>'
SOAPdata = SOAPdata + '\n <accessCode>XXXXX</accessCode>'
SOAPdata = SOAPdata + '\n </checkPassword>'
SOAPdata = SOAPdata + '\n </soap:Body>'
SOAPdata = SOAPdata + '\n</soap:Envelope>'

postdata = quote(SOAPdata)


print "\n************************* OUTGOING SOAP
************************************"
print postdata

# Begin HTTP request
req = HTTP("insidecoair5")
req.putrequest("POST",
"/cowsemployeeservicecenter/cowsemployeeservicecenter.asmx")
req.putheader("Accept", "text/xml; charset=utf-8")
req.putheader("Content-Type", "text/xml; charset=utf-8")
req.putheader("Content-Legth", str(len(postdata)))
req.putheader("SOAPAction",
"COM.COAIR.WWW.Technology.CoWebServices.COWSEmployeeServiceCenter/checkPassword")

req.endheaders()

# Send SOAP body
req.send(postdata)


ec, em, h = req.getreply()
print "\n*************************** HTTP RESPONSE
**********************************"
print ec, em

print "\n*************************** HTTP HEADER RESPONSE
***************************"
print h

# get file-like object from HTTP response
# and print received HTML to screen
fd = req.getfile()
textlines = fd.read()
fd.close()

print "\n************************** INCOMING SOAP
***********************************"
print textlines


I get back a faultstring with a "THe root element is missing" error

I cant seem to see what im doing wrong. Any help would be greatly
appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,489
Latest member
BrigidaD91

Latest Threads

Top