使用 Python 和 SOAPpy 生成 WSDL
首先,我承认我是 Web 服务的新手,尽管我熟悉 HTML 和基本的 Web 内容。 我使用 Python 创建了一个快速而肮脏的 Web 服务,该服务调用 MySQL 数据库中的存储过程,仅返回一个 BIGINT 值。 我想要在 Web 服务中返回这个值,并且想要生成一个 WSDL,以便提供给我们的 Web 开发人员。 我可能会补充一点,存储过程仅返回一个值。
下面是一些示例代码:
#!/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 为我生成一个。 这可能吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
去年,当我尝试编写 Python Web 服务时,我最终使用了 ZSI-2.0 (类似于继承人) SOAPpy)和其网络上提供的论文。
基本上,我手动编写了 WSDL 文件,然后使用 ZSI 内容为我的客户端和服务器代码生成存根。 我不会将这种体验描述为令人愉快,但该应用程序确实有效。
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.
您可以尝试 soaplib 。 它具有按需 WSDL 生成功能。
You can try soaplib. It has on-demand WSDL generation.
抱歉前几天问过这个问题。 现在我可以成功调用服务器了。 提供了一个演示:
Sorry for the question few days ago. Now I can invoke the server successfully. A demo is provided: