Python SoapLib with VB.NET and C#

This is a rare post. It says how to do something, and it is something that I have spent a LOT of time investigating. It is not complete thanks to one or two issues, but it is close.

Basically I wanted to write a service in Python and consume it in VB.NET. That should be easy. Well, it is, if you want to write your own Web Service code under .NET. I am lazy and do not like that idea. So you need to generate a WSDL from what I can work out. And this code does that for VB.NET and C#, at least in Visual Studio 2005. There is an issue though. Data types are not being sent correctly. I think this is an issue with SoapLib, but I cannot be sure. The GIT repository does not have any patches either. So this is CUTTING EDGE!

Sorry about the lack of indent. I am sure you can work it out!


#!/usr/bin/python
import web
from soaplib.wsgi_soap import SimpleWSGISoapApp
from soaplib.service import soapmethod
from soaplib.serializers import primitive as soap_types
from soaplib.serializers.primitive import String

urls = ("/hello", "HelloService",
"/hello.wsdl", "HelloService",
)
render = web.template.Template("$def with (var)n$:var")

class SoapService(SimpleWSGISoapApp):
"""Class for webservice """

#__tns__ = 'http://test.com'

# @soapmethod(soap_types.String,_returns=soap_types.String)
@soapmethod(String,_returns=String)
def hello(self,message):
""" Method for webservice"""
return "Hello world "+message

class HelloService(SoapService):
"""Class for web.py """
def start_response(self,status, headers):
web.ctx.status = status
for header, value in headers:
web.header(header, value)

def GET(self):
response = super(SimpleWSGISoapApp, self).__call__(web.ctx.environ, self.start_response)
return render("n".join(response))

def POST(self):
response = super(SimpleWSGISoapApp, self).__call__(web.ctx.environ, self.start_response)
return render("n".join(response))

app=web.application(urls, globals())

if __name__ == "__main__":
app.run()

2 Comments on “Python SoapLib with VB.NET and C#

  1. I found one of the issue, that you can only return primitive types in your web method to be able to be recognized by Visual Studio. I couldn’t use Array(String), only String….