Re: Using a web service [newbie]

2007-06-18 Thread Stevo
On Jun 18, 7:55 pm, Alchemist <[EMAIL PROTECTED]> wrote:
> I am working with Python 2.5 and would like to use of a web service.
>
> What shall I install on my setup (or import in my Python script)?
>
> I read about Zolera Soap Infrastructure, which seems to be the
> preferred Python web service framework (http://
> pywebsvcs.sourceforge.net/).  However, its documentation seems quite
> old (c. 2001/2002) whilst the Babel Fish translation example (http://
> livedocs.adobe.com/coldfusion/6.1/htmldocs/webserv3.htm) did not work
> for me.
>
> Are there any more recent frameworks or tools for using web services
> by Python scripts?
>
> Thank you.

This might be useful to you.

http://www.diveintopython.org/soap_web_services/index.html

-- 
http://mail.python.org/mailman/listinfo/python-list


ZSI Web Service Call

2007-07-02 Thread Stevo
Hi There,

I'm looking for an example of a simple SOAP web service call using the
Zolera SOAP Infrastructure library. The web service I am trying to
call contains a method that is supposed to accept a string as a
parameter and output it to a file.

I have tried the following and I am able to create the file on the web
server although the file is empty. Is there additional code required
for this?

from datetime import datetime
from EventsDatabase_services import *
from ZSI.client import *
import sys

def main():
SOAPAction = 'http://tempuri.org/ALU.EventsDatbase/
EventsDatabase/LogEventStringInputTest'
teststring = 'This is a test'
loc = EventsDatabaseLocator()
port = loc.getEventsDatabaseSoap()
req = LogEventStringInputTestSoapIn()
req.input = 'test'
resp = port.LogEventStringInputTest(req)
print resp

##
# EventsDatabase_services.py
# generated by ZSI.generate.wsdl2python
##

from EventsDatabase_services_types import *
import urlparse, types
from ZSI.TCcompound import ComplexType, Struct
from ZSI import client
import ZSI
from ZSI.generate.pyclass import pyclass_type

# Locator
class EventsDatabaseLocator:
EventsDatabaseSoap_address = "http://tipsy/ALU.EventsDatabase/
EventsDatabase.asmx"
def getEventsDatabaseSoapAddress(self):
return EventsDatabaseLocator.EventsDatabaseSoap_address
def getEventsDatabaseSoap(self, url=None, **kw):
return EventsDatabaseSoapSOAP(url or
EventsDatabaseLocator.EventsDatabaseSoap_address, **kw)

# Methods
class EventsDatabaseSoapSOAP:
def __init__(self, url, **kw):
kw.setdefault("readerclass", None)
kw.setdefault("writerclass", None)
# no resource properties
self.binding = client.Binding(url=url, **kw)
# no ws-addressing

# op: LogEventStringInputTest
def LogEventStringInputTest(self, request):
if isinstance(request, LogEventStringInputTestSoapIn) is
False:
raise TypeError, "%s incorrect request type" %
(request.__class__)
kw = {}
# no input wsaction
self.binding.Send(None, None, request, soapaction="http://
tempuri.org/ALU.EventsDatbase/EventsDatabase/LogEventStringInputTest",
**kw)
# no output wsaction
response =
self.binding.Receive(LogEventStringInputTestSoapOut.typecode)
return response

LogEventStringInputTestSoapIn =
ns0.LogEventStringInputTest_Dec().pyclass

LogEventStringInputTestSoapOut =
ns0.LogEventStringInputTestResponse_Dec().pyclass

##
##

import ZSI
import ZSI.TCcompound
from ZSI.schema import LocalElementDeclaration, ElementDeclaration,
TypeDefinition, GTD, GED
from ZSI.generate.pyclass import pyclass_type

##
# targetNamespace
# http://tempuri.org/ALU.EventsDatbase/EventsDatabase
##

class ns0:
targetNamespace = "http://tempuri.org/ALU.EventsDatbase/
EventsDatabase"

class LogEventStringInputTest_Dec(ZSI.TCcompound.ComplexType,
ElementDeclaration):
literal = "LogEventStringInputTest"
schema = "http://tempuri.org/ALU.EventsDatbase/EventsDatabase";
def __init__(self, **kw):
ns = ns0.LogEventStringInputTest_Dec.schema
TClist = [ZSI.TC.String(pname=(ns,"input"),
aname="_input", minOccurs=0, maxOccurs=1, nillable=False, typed=False,
encoded=kw.get("encoded"))]
kw["pname"] = ("http://tempuri.org/ALU.EventsDatbase/
EventsDatabase","LogEventStringInputTest")
kw["aname"] = "_LogEventStringInputTest"
self.attribute_typecode_dict = {}
 
ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw)
class Holder:
__metaclass__ = pyclass_type
typecode = self
def __init__(self):
# pyclass
self._input = None
return
Holder.__name__ = "LogEventStringInputTest_Holder"
self.pyclass = Holder

class
LogEventStringInputTestResponse_Dec(ZSI.TCcompound.ComplexType,
ElementDeclaration):
literal = "LogEventStringInputTestResponse"
schema = "http://tempuri.org/ALU.EventsDatbase/EventsDatabase";
def __init__(self, **kw):
ns = ns0.LogEventStringInputTestResponse_Dec.schema
TClist =
[ZSI.TC.String(pname=(ns,"LogEventStringInputTestResult"),
aname="_LogEventStringInputTestResult", minOccurs=0, maxOccurs=1,
nillable=False, typed=False, encoded=kw.get("encoded"))]
kw["pname"] = ("http://tempuri.org/ALU.EventsDatbase/
EventsDatabase","LogEventStringInputTestResponse")
kw["aname"] = "_LogEventStringInputTestResponse"
self.attribute_typecode_dict = {}
 
ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw)