使用 Python 和 SOAPpy 生成 WSDL [英] Generating a WSDL using Python and SOAPpy

查看:25
本文介绍了使用 Python 和 SOAPpy 生成 WSDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我承认我是 Web 服务的新手,尽管我熟悉 HTML 和基本的 Web 内容.我使用 Python 创建了一个快速而肮脏的 Web 服务,它调用 MySQL 数据库中的一个存储过程,它只返回一个 BIGINT 值.我想在 web 服务中返回这个值,我想生成一个 WSDL,我可以提供给我们的 web 开发人员.我可以补充一点,存储过程只返回一个值.

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.

这是一些示例代码:

#!/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()

我想生成一个可以提供给网络人员的 WSDL,我想知道是否可以让 SOAPpy 为我生成一个.这可能吗?

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?

推荐答案

去年我尝试编写 Python Web 服务时,我最终使用了 ZSI-2.0(类似于 SOAPpy 的继承者)和 论文它的网站.

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.

基本上我手工编写了我的 WSDL 文件,然后使用 ZSI 的东西为我的客户端和服务器代码生成存根.我不会将这种体验描述为愉快,但该应用程序确实有效.

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.

这篇关于使用 Python 和 SOAPpy 生成 WSDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆