Skip to content

Commit bbcc57b

Browse files
committed
Updated rate service WSDL from v8 to v16, removed default setting of RequestedShipment.RateRequestTypes (no longer in WSDL), added better error messages for WSDL validation errors by passing suds' WebFault to SchemaValidationError
1 parent 8edc332 commit bbcc57b

File tree

4 files changed

+9742
-9507
lines changed

4 files changed

+9742
-9507
lines changed

fedex/base_service.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ class SchemaValidationError(FedexBaseServiceException):
4141
"""
4242
Exception: There is probably a problem in the data you provided.
4343
"""
44-
def __init__(self):
44+
def __init__(self, fault):
4545
self.error_code = -1
4646
self.value = "suds encountered an error validating your data against this service's WSDL schema. Please double-check for missing or invalid values, filling all required fields."
47+
try:
48+
self.value += ' Details: {}'.format(fault.detail.desc)
49+
except AttributeError:
50+
pass
4751

4852
class FedexBaseService(object):
4953
"""
@@ -212,11 +216,11 @@ def send_request(self, send_function=None):
212216
else:
213217
# Default scenario, business as usual.
214218
self.response = self._assemble_and_send_request()
215-
except suds.WebFault:
219+
except suds.WebFault as fault:
216220
# When this happens, throw an informative message reminding the
217221
# user to check all required variables, making sure they are
218-
# populated and valid.
219-
raise SchemaValidationError()
222+
# populated and valid
223+
raise SchemaValidationError(fault.fault)
220224

221225
# Check the response for general Fedex errors/failures that aren't
222226
# specific to any given WSDL/request.

fedex/services/rate_service.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ def __init__(self, config_obj, *args, **kwargs):
2525
self._config_obj = config_obj
2626

2727
# Holds version info for the VersionId SOAP object.
28-
self._version_info = {'service_id': 'crs', 'major': '8',
28+
self._version_info = {'service_id': 'crs', 'major': '16',
2929
'intermediate': '0', 'minor': '0'}
3030

3131
self.RequestedShipment = None
3232
"""@ivar: Holds the RequestedShipment WSDL object."""
3333
# Call the parent FedexBaseService class for basic setup work.
3434
super(FedexRateServiceRequest, self).__init__(self._config_obj,
35-
'RateService_v8.wsdl',
35+
'RateService_v16.wsdl',
3636
*args, **kwargs)
3737
self.ClientDetail.Region = config_obj.express_region_code
3838

@@ -80,9 +80,6 @@ def _prepare_wsdl_objects(self):
8080
# Assume US.
8181
Payor.CountryCode = 'US'
8282

83-
# ACCOUNT or LIST
84-
self.RequestedShipment.RateRequestTypes = ['ACCOUNT']
85-
8683
# Start with no packages, user must add them.
8784
self.RequestedShipment.PackageCount = 0
8885
self.RequestedShipment.RequestedPackageLineItems = []

0 commit comments

Comments
 (0)