你好吗
我已经创建了一个package类,它设置了一些默认值,比如shipper、receiden、packages和commodities。在
问题是,当我调用作为suds客户机的shippackage方法时,会收到错误消息:
AttributeError: Fault instance has no attribute 'detail'
下面列出的第一个文件是我的测试文件,它设置了必要的词典:
^{pr2}$正在导入的模块如下:
from suds.client import Client
from suds.bindings import binding
binding.envns = ('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope')
client = Client('http://localhost/ProgisticsAMP/amp.svc/wsdl', headers={'Content-Type': 'application/soap+xml'},
faults=False)
class Package(object):
def __init__(self, shipper):
self.commoditylist = []
self.commodityContents = {}
self.consignee = {}
self.defaults = {}
self.packagelist = []
self.packages = {}
self.defaults['shipper'] = shipper
def setconsignee(self, company, contact, address, city, state, zip, country):
self.consignee['company'] = company
self.consignee['contact'] = contact
self.consignee['address1'] = address
self.consignee['city'] = city
self.consignee['stateProvince'] = state
self.consignee['postalCode'] = zip
self.consignee['countrySymbol'] = country
self.defaults['consignee'] = self.consignee
def setdefaults(self, packaging, shipdate, deliverymethod):
self.defaults['packaging'] = packaging
self.defaults['shipdate'] = shipdate
self.defaults['deliveryMethod'] = deliverymethod
def addcommodity(self, description, unitweight):
commodity = {}
commodity['description'] = description
commodity['unitWeight'] = {'value': unitweight}
self.commoditylist.append(commodity)
def addpackage(self, weight, declarevalue):
package = {}
package['weight'] = {'value': weight}
package['declaredValueAmount'] = {'amount': declarevalue, 'currency': 'USD'}
self.packagelist.append(package)
def setcommoditylist(self):
self.commodityContents = {'item': self.commoditylist}
self.defaults['commodityContents'] = self.commodityContents
def setpackagelist(self):
self.packages = {'item': self.packagelist}
def shippackage(self):
print self.defaults
print self.packages
# print client
response = client.service.Ship('CONNECTSHIP_UPS.UPS.GND', self.defaults, self.packages, True, 'release')
result = response.result
print result
在shippackage方法中,我打印self.packages公司以及自身默认值在我打电话之前确认他们有数据
client.service.Ship()
所以在我调用客户机服务船()
我是不是少了点什么?为什么不使用我设置的默认值和包字典?在
问题是值“shipdate”
WSDL期望使用不同格式的shipdate。在
我找到这一点的唯一方法是将端点从soap1.2切换到1.1
我直接编辑了web.config文件文件
现在这是100%的工作
相关问题 更多 >
编程相关推荐