FW: [Pywebsvcs-talk] Creating WSDLs

Ivan R. Judson judson at mcs.anl.gov
Thu May 20 15:08:55 CDT 2004


Charles works for Randy and Indiana University; this is an interesting thing
:-)

--ivan 

> -----Original Message-----
> From: pywebsvcs-talk-admin at lists.sourceforge.net 
> [mailto:pywebsvcs-talk-admin at lists.sourceforge.net] On Behalf 
> Of Charles Moad
> Sent: Thursday, May 20, 2004 2:11 PM
> To: Charles Moad
> Cc: pywebsvcs-talk at lists.sourceforge.net; blunck at gst.com
> Subject: Re: [Pywebsvcs-talk] Creating WSDLs
> 
> 	I found the problem.  I needed to pass the namespace to 
> the function registrations.  Below is what the server code 
> looks like now.  I can run "python py2wsdl.py calculator.py > 
> calculator.wsdl" to generate the wsdl file.  It handles 
> simple types right now, and I will consider adding complex 
> types depending on the interest.
> 
> calculator.py
> ----------------------------------------------------------
>  >> #!/usr/bin/python
>  >>
>  >> # py2wsdl
>  >> # service Calculator
>  >> # target impl:Calculator
>  >> # location http://hostname:10081
>  >> # int add int int
>  >> # int subtract int int
>  >> # double pi
>  >> # py2wsdl
>  >>
>  >> import math
>  >> import SOAPpy
>  >>
>  >> SOAPpy.Config.Debug=1
>  >>
>  >> def add(a, b):
>  >>     return a + b
>  >>
>  >> def subtract(a, b):
>  >>     return a - b
>  >>
>  >> def pi():
>  >>     return math.pi
>  >>
>  >> server = SOAPpy.SOAPServer(("euclid.uits.iupui.edu", 
> 10081))  >> server.registerFunction(add)  >> 
> server.registerFunction(subtract)  >> 
> server.registerFunction(pi)  >>  >> server.serve_forever()
> ----------------------------------------------------------
> 
> Charles Moad wrote:
> > As promised here is the error output I am seeing.  I am 
> having trouble 
> > getting the html debugging message for some reason.
> > 
> >  >>> import SOAPpy
> >  >>> SOAPpy.Config.Debug=1
> >  >>> p = SOAPpy.WSDL.Proxy('http://myhostname/calculator.wsdl')
> >  >>> p.methods.keys()
> > [u'add', u'pi', u'subtract']
> >  >>> p.pi()
> > <Fault SOAP-ENV:Client: No method impl:Calculator:pi found: 
> > exceptions.KeyError u'impl:Calculator'>Traceback (most 
> recent call last):
> >   File "<stdin>", line 1, in ?
> >   File "/usr/lib/python2.3/site-packages/SOAPpy/Client.py", 
> line 421, 
> > in __call__
> >     return self.__r_call(*args, **kw)
> >   File "/usr/lib/python2.3/site-packages/SOAPpy/Client.py", 
> line 443, 
> > in __r_call
> >     self.__hd, self.__ma)
> >   File "/usr/lib/python2.3/site-packages/SOAPpy/Client.py", 
> line 357, 
> > in __call
> >     raise p
> > SOAPpy.Types.faultType: <Fault SOAP-ENV:Client: No method 
> > impl:Calculator:pi found: exceptions.KeyError u'impl:Calculator'>
> > 
> > I would greatly appreciate it if anyone could isolate what 
> this error is.
> > 
> > Thanks,
> > 
> > 
> > Charles Moad wrote:
> > 
> >>     I have taken this into account.  Python's dynamic 
> typical would 
> >> make it impossible to create a wsdl that correctly reflected the 
> >> code.  The way I handle this is by adding a header (in 
> comments) that 
> >> could be thought of as function declarations with expected 
> types.  I 
> >> also include some other useful variables.  Below is the 
> file I have 
> >> been working so far, a simple calculator service.  This 
> code is just 
> >> like a java sample with Axis, and I can actually take my wsdl 
> >> generator output and point it at the axis web service and it works.
> >> SOAPpy.SOAPServer chokes when a method is invoked.  I get 
> the error 
> >> output exactly as I see it, and post it tomorrow.  I mention the 
> >> error I am seeing in more detail in a post below.
> >>     I am attaching the wsdl file that my program outputs if anyone 
> >> would like to try to see it they can reproduce the error.  Please 
> >> replace "hostname" accordingly.
> >>
> >> Thanks as always,
> >>     Charlie Moad
> >>
> >> 
> ---------------------------------------------------------------------
> >> ---
> >> #!/usr/bin/python
> >>
> >> # py2wsdl
> >> # service Calculator
> >> # target impl:Calculator
> >> # location http://hostname:10081
> >> # int add int int
> >> # int subtract int int
> >> # double pi
> >> # py2wsdl
> >>
> >> import math
> >> import SOAPpy
> >>
> >> SOAPpy.Config.Debug=1
> >>
> >> def add(a, b):
> >>     return a + b
> >>
> >> def subtract(a, b):
> >>     return a - b
> >>
> >> def pi():
> >>     return math.pi
> >>
> >> server = SOAPpy.SOAPServer(("euclid.uits.iupui.edu", 10081))
> >> server.registerFunction(add)
> >> server.registerFunction(subtract)
> >> server.registerFunction(pi)
> >>
> >> server.serve_forever()
> >> 
> ---------------------------------------------------------------------
> >> ---
> >>
> >>
> >> On May 19, 2004, at 3:47 PM, Christopher Blunck wrote:
> >>
> >>> Hi Charles-
> >>>
> >>> I work with the ZSI project a lot, but have a little 
> experience with 
> >>> SOAPpy.  I didn't respond because SOAPpy isn't my area of 
> expertise, 
> >>> but seeing as how nobody else responded I'll take a stab 
> at it and 
> >>> share my opinion on the concept of WSDL generation from a python 
> >>> codebase:  it's difficult.
> >>>
> >>> It's difficult primarily because of Python's late dynamic 
> binding.  
> >>> It's fairly
> >>> straightforward to navigate a dictionary consisting of primitives 
> >>> (Strings, ints, and the like) and produce a partially respectable 
> >>> WSDL from the static code analysis.  But, as soon as you 
> introduce 
> >>> more complex types (User, Loan, Vehicle, etc), it becomes more 
> >>> difficult.  How do you infer the "correct"
> >>> name for the parameter passed to the function:
> >>>   def CreateLoan(loan): pass
> >>>
> >>> In other languages that favor compile time type checking, this 
> >>> translation from source code to WSDL is trivial (Java and 
> C come to 
> >>> mind).  But in a dynamic langauge like Python it's difficult.  I 
> >>> believe this is the primary reason why not much work has been 
> >>> performed in this arena.
> >>>
> >>> If you have some reference code tho, I'm sure folks would love to 
> >>> take a look at what you've accomplished! :)
> >>>
> >>>
> >>> -c
> >>>
> >>> On Wed, May 19, 2004 at 03:34:14PM -0500, Charles Moad wrote:
> >>>
> >>>>     Alright, the lack of response lends me to believe 
> there is not a
> >>>> solution.  I have made fairly good progress on writing 
> my own wsdl
> >>>> generator, but I am running into the problem that 
> SOAPpy.SOAPServer 
> >>>> does
> >>>> not seem to handle request correctly from a 
> SOAP.WSDL.Proxy that is
> >>>> initialized from a wsdl.  I have equivalent python and 
> java services,
> >>>> and I can take the wsdl and point it at the java service 
> running in
> >>>> Axis, and it works fine.  The error I am getting says it 
> can't find
> >>>> method "http://localhost:10081/:pi" when I am calling 
> the pi() method.
> >>>>
> >>>> Thanks,
> >>>>
> >>>> Charles Moad wrote:
> >>>>
> >>>>>    How would one go about creating a wsdl for a 
> SOAPServer created
> >>>>> using SOAPpy?  I am hoping there is an automated solution as 
> >>>>> opposed to
> >>>>> a by-hand one.
> >>>>>
> >>>>> Thanks,
> >>>>>    Charles Moad
> > 
> > 
> > 
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: Oracle 10g
> > Get certified on the hottest thing ever to hit the 
> market... Oracle 10g. 
> > Take an Oracle 10g class now, and we'll give you the exam FREE.
> > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> > _______________________________________________
> > Pywebsvcs-talk mailing list
> > Pywebsvcs-talk at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... 
> Oracle 10g. 
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> Pywebsvcs-talk mailing list
> Pywebsvcs-talk at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk
> 
> 




More information about the ag-dev mailing list