473,495 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 3164
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
1988
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
2531
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
1493
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
4399
by: johnny | last post by:
Anyone know how I can make Machine A python script execute a python script on Machine B ?
0
7120
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
6991
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
7160
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
7196
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
5456
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,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.