Calling Web Services from Python

I

Ivan Zuzak

Hello,

My Python application calls web services available on the Internet. The
web service being called is defined through application user input.

The Python built-in library allows access to web services using HTTP
protocol, which is not acceptible - generating SOAP messages for
arbitrary web services is something i wish to avoid.

I need a package/tool that generates web service proxies that will do
all the low-level HTTP work. (Someting like the WSDL.EXE tool in .NET
Framework) The ZSI and SOAPy packages [1] that i found (should) have
those functionalities but either have a bug (SOAPy) or either do not
work for arbitrary web services (ZSI). I tried the ZSI wsdl2py script on
a wsdl of one of my services, and the script crashes. I suppose the wsdl
was "too hard" for the script to parse.

Are there any other packages that utilize generation of web service
proxies that are compatible with SOAP & WSDL standards?

Thank you,
ivan zuzak

[1] - http://pywebsvcs.sourceforge.net/
 
J

John Salerno

Ivan said:
I need a package/tool that generates web service proxies that will do
all the low-level HTTP work. (Someting like the WSDL.EXE tool in .NET
Framework) The ZSI and SOAPy packages [1] that i found (should) have
those functionalities but either have a bug (SOAPy) or either do not
work for arbitrary web services (ZSI).

You might want to read this, specifically 12.5 and 12.6 for WSDL:
http://diveintopython.org/soap_web_services/index.html

It uses SOAPpy, which may or may not be different than SOAPy, depending
on if you made a typo or not. :)
 
M

m.banaouas

Can you tell us more about SOAPpy bug ?
Is it about authentication ?

Ivan Zuzak a écrit :
 
I

Ivan Zuzak

m.banaouas said:
Can you tell us more about SOAPpy bug ?
Is it about authentication ?

Ivan Zuzak a écrit :
...
I need a package/tool that generates web service proxies that will do
all the low-level HTTP work. (Someting like the WSDL.EXE tool in .NET
Framework) The ZSI and SOAPy packages [1] that i found (should) have
those functionalities but either have a bug (SOAPy) or either do not
work for arbitrary web services (ZSI). ...

SOAPy : http://soapy.sourceforge.net/
SOAPPy : http://pywebsvcs.sourceforge.net/

The bugged one is SOAPy (parsing errors and something else). I just
downloaded and tried SOAPPy and that one crashes too. I get an "Index
out of range" error while parsing the wsdl ( in XMLSchema.py ). The
traceback is a bit long, so I wont list the whole thing here.

Bellow this message is the wsdl of the service for which im trying to
get a proxy. If anyone manages to get a proxy out of it - please let me
know :).

Thank you for your help,
Ivan

//////////////////////// WSDL START ////////////////////////////////

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:s1="http://www.ris.fer.hr/overlay/addressing"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s3="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox/MessageStatistics"

xmlns:s2="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/XmlDoc"
xmlns:s4="http://ris.zemris.fer.hr/remotingSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox"

xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox"

xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox">
<s:import namespace="http://www.ris.fer.hr/overlay/addressing" />
<s:import
namespace="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/XmlDoc"

/>
<s:element name="Create">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="mbID"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
ref="s1:EndpointReference" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="CreateResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CreateResult"
type="s:boolean" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ResourceID" type="tns:ResourceID" />
<s:complexType name="ResourceID" mixed="true">
<s:annotation>
<s:appinfo>
<keepNamespaceDeclarations>xmlns</keepNamespaceDeclarations>
</s:appinfo>
</s:annotation>
</s:complexType>
<s:element name="Destroy">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
ref="s1:EndpointReference" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DestroyResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="DestroyResult"
type="s:boolean" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="PutMessage">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" ref="s2:xmlDoc" />
<s:element minOccurs="0" maxOccurs="1"
ref="s1:EndpointReference" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="PutMessageResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="PutMessageResult" type="s:boolean" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetMessage">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="timeParam"
type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="cb"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
ref="s1:EndpointReference" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetMessageResponse">
<s:complexType>
<s:sequence>
<s:any minOccurs="0" maxOccurs="1" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="FlushPerformanceLog">
<s:complexType />
</s:element>
<s:element name="FlushPerformanceLogResponse">
<s:complexType />
</s:element>
<s:element name="GetPerformanceLog">
<s:complexType />
</s:element>
<s:element name="GetPerformanceLogResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
name="GetPerformanceLogResult">
<s:complexType mixed="true">
<s:sequence>
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.ris.fer.hr/overlay/addressing">
<s:element name="EndpointReference"
type="s1:EndpointReferenceType" />
<s:complexType name="EndpointReferenceType">
<s:annotation>
<s:appinfo>
<keepNamespaceDeclarations>xmlns</keepNamespaceDeclarations>
</s:appinfo>
</s:annotation>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Address"
type="s1:AttributedURI" />
<s:element minOccurs="0" maxOccurs="1" name="RemotingAddress"
type="s1:AttributedURI" />
<s:element minOccurs="0" maxOccurs="1"
name="ReferenceProperties" type="s1:ReferencePropertiesType" />
<s:element minOccurs="0" maxOccurs="1" name="PortType"
type="s1:AttributedQName" />
<s:element minOccurs="0" maxOccurs="1" name="ServiceName"
type="s1:ServiceNameType" />
<s:element minOccurs="0" maxOccurs="1" name="To"
type="s1:AttributedURI" />
<s:element minOccurs="0" maxOccurs="1" name="From"
type="s1:EndpointReferenceType" />
</s:sequence>
</s:complexType>
<s:complexType name="AttributedURI">
<s:simpleContent>
<s:extension base="s:anyURI" />
</s:simpleContent>
</s:complexType>
<s:complexType name="ReferencePropertiesType">
<s:annotation>
<s:appinfo>
<keepNamespaceDeclarations>xmlns</keepNamespaceDeclarations>
</s:appinfo>
</s:annotation>
<s:sequence>
<s:any minOccurs="0" maxOccurs="unbounded" />
</s:sequence>
</s:complexType>
<s:complexType name="AttributedQName">
<s:simpleContent>
<s:extension base="s:QName" />
</s:simpleContent>
</s:complexType>
<s:complexType name="ServiceNameType">
<s:simpleContent>
<s:extension base="s:QName">
<s:attribute name="PortName" type="s:NCName" />
</s:extension>
</s:simpleContent>
</s:complexType>
<s:element name="FacilityID" type="s1:FacilityID" />
<s:complexType name="FacilityID" mixed="true">
<s:annotation>
<s:appinfo>
<keepNamespaceDeclarations>xmlns</keepNamespaceDeclarations>
</s:appinfo>
</s:annotation>
</s:complexType>
<s:element name="To" type="s1:ToAttributedURI" />
<s:complexType name="ToAttributedURI" mixed="true">
<s:anyAttribute />
</s:complexType>
</s:schema>
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/XmlDoc">
<s:element name="xmlDoc" nillable="true" type="s2:XmlDoc" />
<s:complexType name="XmlDoc" mixed="true">
<s:sequence>
<s:any minOccurs="0" maxOccurs="unbounded" />
</s:sequence>
<s:anyAttribute />
</s:complexType>
</s:schema>
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox/MessageStatistics">
<s:element name="MessageStatistics" type="s3:MessageStatistics" />
<s:complexType name="MessageStatistics">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="messageWaiting"
type="s:double" />
</s:sequence>
</s:complexType>
</s:schema>
<s:schema elementFormDefault="qualified"
targetNamespace="http://ris.zemris.fer.hr/remotingSchema">
<s:element name="service" type="s4:Service" />
<s:complexType name="Service">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="class"
type="s4:Classes" />
</s:sequence>
<s:attribute name="name" type="s:string" />
<s:attribute name="location" type="s:string" />
</s:complexType>
<s:complexType name="Classes">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="method"
type="s4:Methods" />
</s:sequence>
<s:attribute name="name" type="s:string" />
<s:attribute name="namespace" type="s:string" />
</s:complexType>
<s:complexType name="Methods">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="param"
type="s4:params" />
</s:sequence>
<s:attribute name="name" type="s:string" />
<s:attribute name="returnType" type="s:string" />
</s:complexType>
<s:complexType name="Params">
<s:attribute name="name" type="s:string" />
<s:attribute name="type" type="s:string" />
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="CreateSoapIn">
<wsdl:part name="parameters" element="tns:Create" />
</wsdl:message>
<wsdl:message name="CreateSoapOut">
<wsdl:part name="parameters" element="tns:CreateResponse" />
</wsdl:message>
<wsdl:message name="CreateFacilityID">
<wsdl:part name="FacilityID" element="s1:FacilityID" />
</wsdl:message>
<wsdl:message name="CreateResourceID">
<wsdl:part name="ResourceID" element="tns:ResourceID" />
</wsdl:message>
<wsdl:message name="CreateTo">
<wsdl:part name="To" element="s1:To" />
</wsdl:message>
<wsdl:message name="DestroySoapIn">
<wsdl:part name="parameters" element="tns:Destroy" />
</wsdl:message>
<wsdl:message name="DestroySoapOut">
<wsdl:part name="parameters" element="tns:DestroyResponse" />
</wsdl:message>
<wsdl:message name="DestroyFacilityID">
<wsdl:part name="FacilityID" element="s1:FacilityID" />
</wsdl:message>
<wsdl:message name="DestroyResourceID">
<wsdl:part name="ResourceID" element="tns:ResourceID" />
</wsdl:message>
<wsdl:message name="DestroyTo">
<wsdl:part name="To" element="s1:To" />
</wsdl:message>
<wsdl:message name="PutMessageSoapIn">
<wsdl:part name="parameters" element="tns:putMessage" />
</wsdl:message>
<wsdl:message name="PutMessageSoapOut">
<wsdl:part name="parameters" element="tns:putMessageResponse" />
</wsdl:message>
<wsdl:message name="PutMessageFacilityID">
<wsdl:part name="FacilityID" element="s1:FacilityID" />
</wsdl:message>
<wsdl:message name="PutMessageResourceID">
<wsdl:part name="ResourceID" element="tns:ResourceID" />
</wsdl:message>
<wsdl:message name="PutMessageTo">
<wsdl:part name="To" element="s1:To" />
</wsdl:message>
<wsdl:message name="GetMessageSoapIn">
<wsdl:part name="parameters" element="tns:GetMessage" />
</wsdl:message>
<wsdl:message name="GetMessageSoapOut">
<wsdl:part name="parameters" element="tns:GetMessageResponse" />
</wsdl:message>
<wsdl:message name="GetMessageFacilityID">
<wsdl:part name="FacilityID" element="s1:FacilityID" />
</wsdl:message>
<wsdl:message name="GetMessageResourceID">
<wsdl:part name="ResourceID" element="tns:ResourceID" />
</wsdl:message>
<wsdl:message name="GetMessageTo">
<wsdl:part name="To" element="s1:To" />
</wsdl:message>
<wsdl:message name="GetMessageMessageStatistics">
<wsdl:part name="MessageStatistics" element="s3:MessageStatistics" />
</wsdl:message>
<wsdl:message name="FlushPerformanceLogSoapIn">
<wsdl:part name="parameters" element="tns:FlushPerformanceLog" />
</wsdl:message>
<wsdl:message name="FlushPerformanceLogSoapOut">
<wsdl:part name="parameters"
element="tns:FlushPerformanceLogResponse" />
</wsdl:message>
<wsdl:message name="GetPerformanceLogSoapIn">
<wsdl:part name="parameters" element="tns:GetPerformanceLog" />
</wsdl:message>
<wsdl:message name="GetPerformanceLogSoapOut">
<wsdl:part name="parameters" element="tns:GetPerformanceLogResponse" />
</wsdl:message>
<wsdl:message name="GetPerformanceLogservice">
<wsdl:part name="service" element="s4:service" />
</wsdl:message>
<wsdl:portType name="MailBoxSoap">
<wsdl:eek:peration name="Create">
<wsdl:input message="tns:CreateSoapIn" />
<wsdl:eek:utput message="tns:CreateSoapOut" />
</wsdl:eek:peration>
<wsdl:eek:peration name="Destroy">
<wsdl:input message="tns:DestroySoapIn" />
<wsdl:eek:utput message="tns:DestroySoapOut" />
</wsdl:eek:peration>
<wsdl:eek:peration name="PutMessage">
<wsdl:input message="tns:putMessageSoapIn" />
<wsdl:eek:utput message="tns:putMessageSoapOut" />
</wsdl:eek:peration>
<wsdl:eek:peration name="GetMessage">
<wsdl:input message="tns:GetMessageSoapIn" />
<wsdl:eek:utput message="tns:GetMessageSoapOut" />
</wsdl:eek:peration>
<wsdl:eek:peration name="FlushPerformanceLog">
<wsdl:input message="tns:FlushPerformanceLogSoapIn" />
<wsdl:eek:utput message="tns:FlushPerformanceLogSoapOut" />
</wsdl:eek:peration>
<wsdl:eek:peration name="GetPerformanceLog">
<wsdl:input message="tns:GetPerformanceLogSoapIn" />
<wsdl:eek:utput message="tns:GetPerformanceLogSoapOut" />
</wsdl:eek:peration>
</wsdl:portType>
<wsdl:binding name="MailBoxSoap" type="tns:MailBoxSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
<wsdl:eek:peration name="Create">
<soap:eek:peration
soapAction="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox/Create"

style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:CreateFacilityID" part="FacilityID"
use="literal" />
<soap:header message="tns:CreateTo" part="To" use="literal" />
</wsdl:input>
<wsdl:eek:utput>
<soap:body use="literal" />
<soap:header message="tns:CreateResourceID" part="ResourceID"
use="literal" />
</wsdl:eek:utput>
</wsdl:eek:peration>
<wsdl:eek:peration name="Destroy">
<soap:eek:peration
soapAction="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox/Destroy"

style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:DestroyFacilityID" part="FacilityID"
use="literal" />
<soap:header message="tns:DestroyResourceID" part="ResourceID"
use="literal" />
<soap:header message="tns:DestroyTo" part="To" use="literal" />
</wsdl:input>
<wsdl:eek:utput>
<soap:body use="literal" />
</wsdl:eek:utput>
</wsdl:eek:peration>
<wsdl:eek:peration name="PutMessage">
<soap:eek:peration
soapAction="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox/PutMessage"

style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:putMessageFacilityID"
part="FacilityID" use="literal" />
<soap:header message="tns:putMessageResourceID"
part="ResourceID" use="literal" />
<soap:header message="tns:putMessageTo" part="To" use="literal" />
</wsdl:input>
<wsdl:eek:utput>
<soap:body use="literal" />
</wsdl:eek:utput>
</wsdl:eek:peration>
<wsdl:eek:peration name="GetMessage">
<soap:eek:peration
soapAction="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox/GetMessage"

style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:GetMessageFacilityID"
part="FacilityID" use="literal" />
<soap:header message="tns:GetMessageResourceID"
part="ResourceID" use="literal" />
<soap:header message="tns:GetMessageTo" part="To" use="literal" />
</wsdl:input>
<wsdl:eek:utput>
<soap:body use="literal" />
<soap:header message="tns:GetMessageMessageStatistics"
part="MessageStatistics" use="literal" />
</wsdl:eek:utput>
</wsdl:eek:peration>
<wsdl:eek:peration name="FlushPerformanceLog">
<soap:eek:peration
soapAction="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox/FlushPerformanceLog"

style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:eek:utput>
<soap:body use="literal" />
</wsdl:eek:utput>
</wsdl:eek:peration>
<wsdl:eek:peration name="GetPerformanceLog">
<soap:eek:peration
soapAction="http://www.ris.fer.hr/OpenCollectives/CoopetitionServices/MailBox/GetPerformanceLog"

style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:eek:utput>
<soap:body use="literal" />
<soap:header message="tns:GetPerformanceLogservice"
part="service" use="literal" />
</wsdl:eek:utput>
</wsdl:eek:peration>
</wsdl:binding>
<wsdl:service name="MailBox">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
<wsdl:port name="MailBoxSoap" binding="tns:MailBoxSoap">
<soap:address
location="http://localhost/coopetitionservices/mailbox/MailBox.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

//////////////////////////// WSDL END /////////////////////////////
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top