是否有任何公开可用的SOAP 1.2/WSDL 2.0兼容免费Web服务来测试基于Python的soap客户端库(例如Zolera SOAP Infrastructure)?
到目前为止,在我看来,Google Web API可能是唯一的选择.
否则,如何测试符合SOAP 1.2的客户端库?
首先,我承认我是Web服务的新手,虽然我熟悉HTML和基本Web内容.我使用Python创建了一个快速而肮脏的Web服务,该服务调用MySQL数据库中的存储过程,该服务只返回BIGINT值.我想在Web服务中返回此值,并且我想生成一个我可以为Web开发人员提供的WSDL.我可以补充一点,存储过程只返回一个值.
这是一些示例代码:
#!/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()
Run Code Online (Sandbox Code Playgroud)
我想生成一个我可以给网络人员的WSDL,我想知道是否可以让SOAPpy为我生成一个.这可能吗?
我试图使用Zeep来描述给定WSDL中的操作和类型,以便程序知道操作名称,它们的参数名称,参数类型和参数属性.
此信息将用于动态生成给定WSDL的UI.
到目前为止我所获得的仅仅是操作和类型的字符串表示.使用与此答案中的代码类似的代码.
这是一个例子:
from zeep import Client
import operator
wsdl = 'http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl'
client = Client(wsdl)
# get each operation signature
for service in client.wsdl.services.values():
print("service:", service.name)
for port in service.ports.values():
operations = sorted(
port.binding._operations.values(),
key=operator.attrgetter('name'))
for operation in operations:
print("method :", operation.name)
print(" input :", operation.input.signature())
print()
print()
# get a specific type signature by name
complextype = client.get_type('ns0:CartGetRequest')
print(complextype.name)
print(complextype.signature())
Run Code Online (Sandbox Code Playgroud)
这给出了如下输出(为简洁起见缩短)
[...]
method : CartCreate
input : MarketplaceDomain: xsd:string, AWSAccessKeyId: xsd:string, AssociateTag: xsd:string, Validate: xsd:string, XMLEscaping: …
Run Code Online (Sandbox Code Playgroud) 我正在使用PHP和Python测试Web服务.比方说,Web服务的地址是http://my.domain.com/my/webservice
.当我使用该URL测试PHP中的Web服务时,一切正常.但是,当我使用相同的位置但在使用SOAPpy的Python中我得到了一个错误.
下面是我用来与Web服务(Python)通信的代码:
from SOAPpy import WSDL
server = SOAPProxy('http://my.domain.com/my/webservice', namespace)
server.myFunction()
Run Code Online (Sandbox Code Playgroud)
我从服务器得到的回复:
HTTPError: <HTTPError 301 Moved Permanently>
Run Code Online (Sandbox Code Playgroud)
我发现如果我在Web服务位置添加一个尾部斜杠就可以了!
from SOAPpy import WSDL
server = SOAPProxy('http://my.domain.com/my/webservice/', namespace)
server.myFunction()
Run Code Online (Sandbox Code Playgroud)
为什么缺少尾部斜杠会导致错误?
我想用suds或soap.py替换应用程序当前(严重破坏和狡猾)基于cURL(基于cURL 命令行!)的SOAP客户端.麻烦的是,我们必须联系MS CRM服务,因此必须使用NTLM.由于各种原因,NTLM代理使用起来有点痛苦,所以我正在研究python-ntlm来提供这种支持.
可以使用suds或soap.py来使用此身份验证方法吗?如果是这样,怎么样?如果没有,任何其他建议都会很棒.
编辑
如下所述,suds已经开箱即用支持python-ntlm.
我试图通过在Python 2.7上使用SOAPpy来调用使用SOAP请求的方法.该方法被调用GetCursOnDate
并返回汇率.它需要一个日期参数.
我正在使用以下代码:
from SOAPpy import SOAPProxy
import datetime
date=datetime.datetime.now()
namespace ="http://web.cbr.ru/"
url = "http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx"
server = SOAPProxy(url,namespace)
print (date)
server.GetCursOnDate(date)
Run Code Online (Sandbox Code Playgroud)
但是我收到了一个错误:
Fault soap:Client:Server无法识别HTTP Header SOAPAction的值:GetCursOnDate.
为什么我会收到此错误?
我正在使用SOAPpy进行soap wsdl服务.我跟着这个toturail.我的代码如下
from SOAPpy import WSDL
wsdlfile = 'http://track.tcs.com.pk/trackingaccount/track.asmx?WSDL'
server = WSDL.Proxy(wsdlfile)
Run Code Online (Sandbox Code Playgroud)
我在代码的最后一行收到此错误
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/adil/Code/mezino/RoyalTag/royalenv/local/lib/python2.7/site-packages/SOAPpy/WSDL.py", line 85, in __init__
self.wsdl = reader.loadFromString(str(wsdlsource))
File "/home/adil/Code/mezino/RoyalTag/royalenv/local/lib/python2.7/site-packages/wstools/WSDLTools.py", line 52, in loadFromString
return self.loadFromStream(StringIO(data))
TypeError: initial_value must be unicode or None, not str
Run Code Online (Sandbox Code Playgroud)
我尝试将字符串转换为utf使用
wsdlFile = unicode('http://track.tcs.com.pk/trackingaccount/track.asmx?WSDL, "utf-8")
Run Code Online (Sandbox Code Playgroud)
但仍然有同样的错误.这里缺少什么?
我正在构建一个脚本来访问HTTPS/TLS TCP站点,该站点需要一个X.509证书,我将其作为.pfx文件.
我正在使用SOAPpy 0.12.5和Python 2.7并开始使用以下代码,
import SOAPpy
url = "192.168.0.1:5001"
server = SOAPpy.SOAPProxy(url)
# I think I need to pass the cert to server here...
server.callSoapRPC(xxxx)
Run Code Online (Sandbox Code Playgroud)
如果我尝试运行它,则会失败并显示以下消息
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it
Run Code Online (Sandbox Code Playgroud)
任何sugestions如何将.pfx证书绑定到SOAPproxy?
谢谢
我正在使用SOAPpy访问SOAP Web服务.这个函数findPathwaysByText的调用工作得很好:
server.findPathwaysByText (query= 'WP619', species = 'Mus musculus')
Run Code Online (Sandbox Code Playgroud)
但是,对函数登录的调用不会:
server.login (user='amarillion', pass='*****')
Run Code Online (Sandbox Code Playgroud)
因为pass是一个保留字,所以python不会运行它.有解决方法吗?
我试着打电话给肥皂服务.我的调用是成功但它返回空值.我附上我的soap请求和响应模式.它需要1d数组作为输入并返回该数组.
请求架构
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CalculateWeb1D xmlns="http://tempuri.org/">
<HCID>string</HCID>
<jaggedobjDataMICRO>
<string>string</string>
<string>string</string>
</jaggedobjDataMICRO>
<numeratorID>int</numeratorID>
</CalculateWeb1D>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
响应模式
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CalculateWeb1DResponse xmlns="http://tempuri.org/">
<CalculateWeb1DResult>
<string>string</string>
<string>string</string>
</CalculateWeb1DResult>
</CalculateWeb1DResponse>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
我的代码叫肥皂服务
from SOAPpy import WSDL
import warnings
warnings.simplefilter('ignore',DeprecationWarning)
import SOAPpy
wsdlFile = 'http://204.9.76.243/nuCast.DataFeedService/Service1.asmx?WSDL'
server = WSDL.Proxy(wsdlFile)
server.soapproxy.config.dumpSOAPOut = 1
server.soapproxy.config.dumpSOAPIn = 1
print server.CalculateWeb1D(str(1073757),[1,2],99)
Run Code Online (Sandbox Code Playgroud)
和我的输出
*** Outgoing SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<CalculateWeb1D …
Run Code Online (Sandbox Code Playgroud) python ×10
soappy ×10
soap ×8
wsdl ×3
web-services ×2
zsi ×2
ntlm ×1
php ×1
python-2.7 ×1
soap-client ×1
ssl ×1
suds ×1
unicode ×1
x509 ×1
zeep ×1