472,353 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Python and SOAP

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.COWS EmployeeServiceCenter">'
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.COWSEmploy eeServiceCenter/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.
Jul 18 '05 #1
1 3013
Download soappy

http://pywebsvcs.sourceforge.net/

Randall

JuiceMan wrote:
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.COWS EmployeeServiceCenter">'
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.COWSEmploy eeServiceCenter/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.


Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alvin A. Delagon | last post by:
Hello python programmers! I would like to add myself to the ever increasing number of python users. Here's my first question. I've written two SOAP...
0
by: Rafal Zawadzki | last post by:
Hi. I tried earlier to write python zsi mail list, but nobody answered. I am using ZSI 1.7/2.0rc1 with TTPro Soap SDK. The wsdl file can be found...
0
by: Doug Caldwell | last post by:
Hi! ** Accessing the USGS Web Service Using Python ** I am trying to access the US Geological Survey's gazetteer SOAP web service using Python...
5
by: johnny | last post by:
Anyone know how I can make Machine A python script execute a python script on Machine B ?
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.