Howdie do,
I've created a package class that sets some default values such as shipper, consignee, packages and commodities.
The issue is that when I go to call the method shippackage that is a suds client, I receive the error:
AttributeError: Fault instance has no attribute 'detail'
The first file listed below is my test file which sets the necessary dictionaries:
import ship
# Create a new package object
package1 = ship.Package('TX')
# Set consignee
package1.setconsignee('Dubs Enterprise', 'JW', '2175 14th Street', 'Troy', 'NY', '12180', 'USA')
# Set default packaging
package1.setdefaults('CUSTOM', '12/12/15', 'oktoleave')
# Add commodity description with each package
package1.addpackage('12.3 lbs', '124.00')
package1.addcommodity('This is package number 1', '23.5 lbs')
# Add commodity list to defaults dictionary
package1.setcommoditylist()
# Add package list to packages dictionary
package1.setpackagelist()
package1.shippackage()
The module that is being imported is the following:
from suds.client import Client
from suds.bindings import binding
binding.envns = ('SOAP-ENV', 'http://ift.tt/18hkEkn')
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
Within the shippackage method, I print self.packages and self.defaults and confirm that they have data within them before I call
client.service.Ship()
So I know it does have values within it before I call the client.service.Ship()
Am I missing something here? Why won't it take the defaults and packages dictionary that I've set?
Aucun commentaire:
Enregistrer un commentaire