Python网页服务客户端

6 投票
1 回答
3927 浏览
提问于 2025-04-16 01:13

有没有人能用Python写一个可以调用下面这个JAX-WS API的网络服务客户端?

https://109.231.73.12:8090/API?wsdl

因为我是在一个虚拟服务器上运行这个,所以它是自签名的。用户名和密码都是'querty123'

我们在PHP中可以顺利运行,但在Python中却不行。

如果能给个能正常工作的例子,说明你是怎么做到的,那就太好了。

谢谢!

1 个回答

5

suds 这个库在 Python 中让这个过程变得非常简单:

>>> from suds.client import Client
>>> url = 'https://109.231.73.12:8090/API?wsdl'
>>> client = Client(url, username='qwerty123', password='qwerty123')
>>> client.service.addition(1, 2)
3
>>> client.service.hello('John')
HelloJohn
>>> client.service.xToThePowerOfy(2, 16)
18
>>> print client # automagic documentation

Suds ( https://fedorahosted.org/suds/ )  version: 0.4 (beta)  build: R685-20100513

Service ( BasicService ) tns="http://service.basic.com/"
   Prefixes (1)
      ns0 = "http://service.basic.com/"
   Ports (1):
      (BasicPort)
         Methods (3):
            addition(xs:int x, xs:int y, )
            hello(xs:string name, )
            xToThePowerOfy(xs:int x, xs:int y, )
         Types (6):
            addition
            additionResponse
            hello
            helloResponse
            xToThePowerOfy
            xToThePowerOfyResponse

撰写回答