如果有一个 Soap Fault在交易过程中错误,错误会显示在屏幕上。如何向用户隐藏这些错误?我使用异常块捕获它们,但它们仍然出现在输出中。如果我有这个代码:
try:
print "A"
self.client.service.something()
print "B"
except suds.WebFault as (err):
print "C"
self.handleError(err)
Run Code Online (Sandbox Code Playgroud)
输出将是
A
ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?> [..]
C
Run Code Online (Sandbox Code Playgroud)
我不想在A和之间输出任何东西C
未找到类型:'(ArrayOfint,http://schemas.microsoft.com/2003/10/Serialization/Arrays,)'是suds 解析器引发的.在... 2003/10/Serialization/Arrays中定义了ArrayOfInt,所以我猜linux的区分大小写就是问题所在.任何想法我怎么能解决这个问题?
from suds.client import Client
c = Client("https://developer-api.affili.net/V2.0/Logon.svc?wsdl")
Run Code Online (Sandbox Code Playgroud)
过去常常回来
Type not found: '(ArrayOfint, http://schemas.microsoft.com/2003/10/Serialization/Arrays, )'
Run Code Online (Sandbox Code Playgroud)
现在几天以后我甚至都没有去那里,而是我得到了一个
TypeNotFound: Type not found: '(Logon, http://affilinet.framework.webservices/types, )'
Run Code Online (Sandbox Code Playgroud) 尝试使用 Python Suds 进行 SOAP 调用。它可以很好地导入 WSDL,并且它生成的客户端看起来格式良好,但我无法访问这些方法。
该泡沫文档描述了方法调用是这样的:
client.service.Company.GetQueue()
但我从这一切的变化中得到的只是:
suds.MethodNotFound:找不到方法:'OmnitureWebService.OmnitureWebServicePort.Company'
这是我创建的客户端的变量转储。你可以看到方法在那里,但我如何访问它们?我试过指定端口,指定前缀,但似乎没有任何效果。感谢您对此的任何帮助。
> obj._ServiceSelector__client = Suds (
> https://fedorahosted.org/suds/ )
> version: 0.4 GA build: R699-20100913
>
> Service ( OmnitureWebService )
> tns="http://www.omniture.com/"
> Prefixes (2)
> ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
> ns1 = "http://www.omniture.com/" Ports (1):
> (OmnitureWebServicePort)
> Methods (173):
> CodeManager.DeleteCodeArchive(xs:int
> archive_id, )
> CodeManager.GenerateCode(xs:string
> char_set, xs:string code_type, xs:int
> cookie_domain_periods, xs:string
> currency_code, xs:string rsid, xs:int
> secure, )
> CodeManager.GetCodeArchives(int_array
> …Run Code Online (Sandbox Code Playgroud) 我正在使用 python suds(版本:0.3.9 GA build:R659-20100219)与具有以下结构的 SOAP 服务交互:
服务 (DPWSService) tns="http://ejb.revitalization.services.ndg/" 前缀 (1) ns0 = "http://ejb.revitalization.services.ndg/" 端口 (1): (DPWS端口) 方法(13): addTimer(请求请求,) deleteProvider(请求请求,) deleteTimer(请求请求,) doHarvest(请求请求,) doIngest(请求请求,) doNewUpdateProvider(请求请求,) getHarvestHistory(GetHistoryRequest 请求, ) getIngestHistory(GetHistoryRequest 请求,) getList(GetListType 请求,) 获取列表名称() getProviderDetails(请求请求,) getProviderStatistic(请求请求,) getStatusProcess(请求请求,) 类型 (63): 添加定时器响应 CSWProviderDetailsType 确认类型 联系人类型 数据范围类型 删除提供者响应 删除定时器响应 收获响应 摄取响应 DoNewUpdateProviderResponse 电子邮件联系人类型 获取HarvestHistoryResponse 获取历史请求 获取摄取历史响应 获取列表名称响应 获取列表响应 获取列表类型 获取进程状态响应 获取提供者详细信息响应 获取提供者统计响应 收获历史类型 HarvestProvider 类型 收获类型 摄取历史类型 列表名称 OAI提供者详细信息类型 进程ID类型 ProviderCommonType ProviderContactType 提供者详细信息 提供者详细信息类型 提供者ID类型 提供者统计 响应类型 定时器信息通用类型 定时器信息详细信息 定时器信息日志详细信息 添加定时器 添加定时器响应 删除提供者 删除提供者响应 …
我有这个代码:
yestest.py
#!/usr/bin/env python
import os
from suds.client import Client as abo
WSDL = 'DirectConnect.production.wsdl'
def test_api():
url = 'file://' + os.path.join(os.path.abspath(os.path.dirname(__file__)), WSDL)
print url
client = abo('file:///home/agileone/workspace/surebooked/surebooked/DirectConnect.production.wsdl')
data = {
'MerchantCode': 'HELLOWORLD',
'MerchantReference': '3252',
'TransactionType': 20,
'Amount': 10,
'CurrencyCode': 'USD',
'CardHolderName': 'RAUL O REVECHE',
'CardNumber': 4005550000000001,
'ExpiryMonth': 5,
'ExpiryYear': 2013,
'CardID': 0,
'CardSecurityCode': 400,
'CustomerAccountNumber': '',
'BillNumber': 0,
'CardHolderEmail': 'development@yespayments.com.ph',
'ClientIPAddress': 'http://127.0.0.1/',
'Notes': 'This is test',
}
print data
result = client.service.OnlineTransaction(**data)
print result.ResponseDescription
if __name__ == '__main__':
test_api() …Run Code Online (Sandbox Code Playgroud) 我是SOAP和SUD的菜鸟.我需要在Windows 7机器上安装SUD,我有Python 3.2.
我还没有听说过有人在Python 3+中安装SUD.
我应该安装Python 2.7吗?或者我需要更早出发吗?
我试图调用一个需要Null(None)属性的服务,但是suds会删除它们.我需要发..
<ns1:Body>
<ns0:QueryIntersection>
<ns0:intersectingRoad>
<ns2:RoadName xsi:nil="true"/>
<ns2:RoadType xsi:nil="true"/>
</ns0:intersectingRoad>
<ns0:subjectRoad>
<ns2:RoadName>BURKE</ns2:RoadName>
<ns2:RoadType>ROAD</ns2:RoadType>
</ns0:subjectRoad>
</ns0:QueryIntersection>
Run Code Online (Sandbox Code Playgroud)
但suds删除了IntersectingRoad对象并仅发送
<ns1:Body>
<ns0:QueryIntersection>
<ns0:subjectRoad>
<ns2:RoadName>BURKE</ns2:RoadName>
<ns2:RoadType>ROAD</ns2:RoadType>
</ns0:subjectRoad>
</ns0:QueryIntersection>
Run Code Online (Sandbox Code Playgroud)
如果我在IntersectingRoad对象中设置其中一个值,它将发送它并正常工作,但None也是一个有效的请求.这是我正在使用的代码的摘录...
Int1 = client.factory.create('ns2:IntersectingRoad')
Int1.RoadName = None
Int1.RoadType = None
Int2 = client.factory.create('ns2:SubjectRoad')
Int2.RoadName = "BURKE"
Int2.RoadType = "ROAD"
try:
Ints = client.service.QueryIntersection(Int1,Int2, )
except Exception as e:
print e.message
Run Code Online (Sandbox Code Playgroud)
请帮忙!
我有一个简单的suds webservice客户端,一直工作正常.然而,无论什么时候我运行它,我现在得到"urllib2.URLError:".请注意,我可以成功ping远程主机,也可以远程主机端口上telnet.我可以检查哪些事情来解决这个问题?以下是我的代码片段:
from suds.client import Client
from suds.wsse import *
security = Security()
token = UsernameToken('user', 'pass')
token.setnonce()
token.setcreated()
security.tokens.append(token)
def func():
someVar = '2222222'
try:
url ='http://IP:Port/SomeWebServices/service?wsdl'
client = Client(url)
return client.service.SomeMeth(someVat)
except Exception,x:
raise x
if __name__ == '__main__':
response = func()
print response['responseCode']
print response['balance']
Run Code Online (Sandbox Code Playgroud) 我使用库"suds"与SOAP服务器进行通信.请求成功完成后,我收到回答:
answer = client.invoke('RetrieveBLABLAObject', modelthings)
Run Code Online (Sandbox Code Playgroud)
这个答案是所请求对象的许多不同领域的结构.每个字段都是由"字符串"参数"_type"和参数"value"组成的结构,它们可以具有不同的类型.
answer [key] [value] - 返回参数"value"的值.但是在调试模式下(我使用Python 2.7.6和PyCharm),它告诉我该值的类型为"Text".不是"str",不是"unicode",而是"Text".
如果我检查一下
isinstance(obj[cur_key]['value'], unicode)
Run Code Online (Sandbox Code Playgroud)
它告诉我,它将此文本视为"unicode".但是,如果我将它与具有相同主体的unicode进行比较,则返回false:
if obj[cur_key]['value'] != u'String that I know is there':
print("true") #it is printing, but it shouldn't
Run Code Online (Sandbox Code Playgroud)
为什么会这样?如何将"Text"转换为unicode?我试过了
obj[cur_key]['value'].decode('utf-8')
Run Code Online (Sandbox Code Playgroud)
它除外.我该如何处理这种"文字"类型?
我在 python 2.7 中运行波纹管代码它运行良好:
from suds.client import client
client = Client(self.service_address)
rid = client.service.bpPayRequest(terminalId=self.terminalId,
userName=self.userName,
userPassword=self.userPassword,
orderId=order_id,
amount=price,
localDate=local_date,
localTime=local_time,
additionalData=additional_data,
callBackUrl=call_back_address,
payerId=0)
Run Code Online (Sandbox Code Playgroud)
但是当我在 python 3.6.2 中运行时,它不起作用。我猜客户端是为 python 2.How 在 python 3.6.2 中使用 suds.client 库并在 python 3.6.2 中运行顶级代码?
python ×10
suds ×10
soap ×2
wsdl ×2
attributes ×1
django ×1
namespaces ×1
python-2.7 ×1
python-3.x ×1
windows-7 ×1