473,683 Members | 3,702 Online
Bytes | Software Development & Data Engineering Community
+ 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:Envelop e
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/">'
SOAPdata = SOAPdata + '\n <soap:Body>'
SOAPdata = SOAPdata + '\n <checkPasswor d
xmlns="COM.COAI R.WWW.Technolog y.CoWebServices .COWSEmployeeSe rviceCenter">'
SOAPdata = SOAPdata + '\n <employeeID>XXX XXX</employeeID>'
SOAPdata = SOAPdata + '\n <password>XXXXX X</password>'
SOAPdata = SOAPdata + '\n <accessCode>XXX XX</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("insidecoa ir5")
req.putrequest( "POST",
"/cowsemployeeser vicecenter/cowsemployeeser vicecenter.asmx ")
req.putheader(" Accept", "text/xml; charset=utf-8")
req.putheader(" Content-Type", "text/xml; charset=utf-8")
req.putheader(" Content-Legth", str(len(postdat a)))
req.putheader(" SOAPAction",
"COM.COAIR.WWW. Technology.CoWe bServices.COWSE mployeeServiceC enter/checkPassword")

req.endheaders( )

# Send SOAP body
req.send(postda ta)
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 3175
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:Envelop e
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/">'
SOAPdata = SOAPdata + '\n <soap:Body>'
SOAPdata = SOAPdata + '\n <checkPasswor d
xmlns="COM.COAI R.WWW.Technolog y.CoWebServices .COWSEmployeeSe rviceCenter">'
SOAPdata = SOAPdata + '\n <employeeID>XXX XXX</employeeID>'
SOAPdata = SOAPdata + '\n <password>XXXXX X</password>'
SOAPdata = SOAPdata + '\n <accessCode>XXX XX</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("insidecoa ir5")
req.putrequest( "POST",
"/cowsemployeeser vicecenter/cowsemployeeser vicecenter.asmx ")
req.putheader(" Accept", "text/xml; charset=utf-8")
req.putheader(" Content-Type", "text/xml; charset=utf-8")
req.putheader(" Content-Legth", str(len(postdat a)))
req.putheader(" SOAPAction",
"COM.COAIR.WWW. Technology.CoWe bServices.COWSE mployeeServiceC enter/checkPassword")

req.endheaders( )

# Send SOAP body
req.send(postda ta)
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
2004
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 new SOAP client using python but I'm having problems. First, I can't seem to find a good documentation of the SOAPpy module. Second, I found a code snippet of a python SOAP client but it was designed only to use the SOAPproxy function. How can I...
0
2539
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 My wsdl is the same, only different is the address of the cgi file. for example i cannot use defectRequest method:
0
1501
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 name 'Alexandria.' I tried to keep this simple by putting a soap message in a string and sending the request using httplib. I am receiving the following error message.
5
4408
by: johnny | last post by:
Anyone know how I can make Machine A python script execute a python script on Machine B ?
0
8504
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9043
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8753
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7582
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6429
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5789
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4299
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2934
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2195
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.