473,396 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 3163
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 clients using PERL and a PHP. I tried to wirte a...
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 here: http://demo.seapine.com/ttsoapcgi.wsdl ...
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 to find the locations of all the places with the...
5
by: johnny | last post by:
Anyone know how I can make Machine A python script execute a python script on Machine B ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.