在 c# 中使用 python webservice 时遇到问题
Having issues using python webservice in c#
我已经使用 saoplib
编写了 python 网络服务
我的 python 网络服务代码:
import soaplib
from soaplib.core.service import rpc, DefinitionBase,soap
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array
class HelloWorldService(DefinitionBase):
@soap(String,_returns=String)
def say_hello(self,name):
f=open("/tmp/f.txt","w+")
f.write(name)
f.close()
return name
if __name__=='__main__':
try:
from wsgiref.simple_server import make_server
soap_application = soaplib.core.Application([HelloWorldService], 'tns')
wsgi_application = wsgi.Application(soap_application)
server = make_server('46.36.119.230', 7789, wsgi_application)
server.serve_forever()
except ImportError:
print "Error: example server code requires Python >= 2.5"
我想从我的 C# 中调用它 application.So 我如何调用它 say_hello
方法?
首先使用此地址将您的网络服务添加到 C#
http://46.36.119.230:7789/?wsdl
然后你可以这样调用say_hello
方法:
ServiceReference1.ApplicationClient h = new ApplicationClient();
say_hello ss = new say_hello();
ss.name = "saeed";
say_helloResponse rs = h.say_hello(ss);
MessageBox.Show(rs.say_helloResult);
我已经使用 saoplib
我的 python 网络服务代码:
import soaplib
from soaplib.core.service import rpc, DefinitionBase,soap
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array
class HelloWorldService(DefinitionBase):
@soap(String,_returns=String)
def say_hello(self,name):
f=open("/tmp/f.txt","w+")
f.write(name)
f.close()
return name
if __name__=='__main__':
try:
from wsgiref.simple_server import make_server
soap_application = soaplib.core.Application([HelloWorldService], 'tns')
wsgi_application = wsgi.Application(soap_application)
server = make_server('46.36.119.230', 7789, wsgi_application)
server.serve_forever()
except ImportError:
print "Error: example server code requires Python >= 2.5"
我想从我的 C# 中调用它 application.So 我如何调用它 say_hello
方法?
首先使用此地址将您的网络服务添加到 C#
http://46.36.119.230:7789/?wsdl
然后你可以这样调用say_hello
方法:
ServiceReference1.ApplicationClient h = new ApplicationClient();
say_hello ss = new say_hello();
ss.name = "saeed";
say_helloResponse rs = h.say_hello(ss);
MessageBox.Show(rs.say_helloResult);