Generating a WSDL using Python and SOAPpy
Asked Answered
C

3

15

First of all, I will admit I am a novice to web services, although I'm familiar with HTML and basic web stuff. I created a quick-and-dirty web service using Python that calls a stored procedure in a MySQL database, that simply returns a BIGINT value. I want to return this value in the web service, and I want to generate a WSDL that I can give our web developers. I might add that the stored procedure only returns one value.

Here's some example code:

#!/usr/bin/python

import SOAPpy
import MySQLdb

def getNEXTVAL():
    cursor = db.cursor()
    cursor.execute( "CALL my_stored_procedure()" )  # Returns a number
    result=cursor.fetchall()

    for record in result:
        return record[0]

db=MySQLdb.connect(host="localhost", user="myuser", passwd="********", db="testing")
server = SOAPpy.SOAPServer(("10.1.22.29", 8080))
server.registerFunction(getNEXTVAL)
server.serve_forever()

I want to generate a WSDL that I can give to the web folks, and I'm wondering if it's possible to have SOAPpy just generate one for me. Is this possible?

Chickweed answered 7/11, 2008 at 18:5 Comment(1)
This user's attempt is the best I've seen so far of someone generating WSDL for use with their SOAPServer: osdir.com/ml/python.pywebsvcs.general/2006-07/msg00015.htmlExtortionary
G
12

When I tried to write Python web service last year, I ended up using ZSI-2.0 (which is something like heir of SOAPpy) and a paper available on its web.

Basically I wrote my WSDL file by hand and then used ZSI stuff to generate stubs for my client and server code. I wouldn't describe the experience as pleasant, but the application did work.

Gerstner answered 10/11, 2008 at 3:25 Comment(2)
I followed your advice and switched to ZSI instead of SOAPpy, and by using the paper and the other examples I ALMOST have it working now. Thanks!Chickweed
I am trying to implement my SOAP server using ZSI, but I encountered some problems. Can you take a look at this question and this one?Felicidad
C
1

I want to generate a WSDL that I can give to the web folks, ....

You can try soaplib. It has on-demand WSDL generation.

Conventionalism answered 8/11, 2008 at 4:34 Comment(0)
A
1

Sorry for the question few days ago. Now I can invoke the server successfully. A demo is provided:

def test_soappy():
    """test for SOAPpy.SOAPServer
    """
    #okay
    # it's good for SOAPpy.SOAPServer.
    # in a method,it can have morn than 2 ws server.
    server = SOAPProxy("http://localhost:8081/")
    print server.sum(1,2)
    print server.div(10,2)
Averse answered 1/12, 2011 at 2:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.