FedEx SOAP error : Schema validation failed for request Thursday, July 2, 2009

This issue is a bit tricky ! why does FedEx SOAP raises a Schema validation error ?

It seams that FedEx service is expecting you to perform a complete SOAP message including all elements even if you don't need on your service call.

Have a look on this C# code which performs a "valid" SOAP call :


PackageMovementInformationService svc = new PackageMovementInformationService();
var request = new PostalCodeInquiryRequest();
request.CarrierCode = CarrierCodeType.FDXE;
request.ClientDetail = new ClientDetail
{
AccountNumber = "ACCOUNT_NO",
Localization = new Localization
{
LanguageCode = "EN",
LocaleCode = "US-EN"
},
MeterNumber = "METER_NO"
};
request.CountryCode = "US";
request.PostalCode = "38017";
request.WebAuthenticationDetail = new WebAuthenticationDetail
{
UserCredential = new WebAuthenticationCredential
{
Key = "__KEY__",
Password = "_Password_"
}
};
request.Version = new VersionId ();
request.TransactionDetail = new TransactionDetail
{
CustomerTransactionId = "23",
Localization = new Localization { LocaleCode="US-EN", LanguageCode="EN" }
};

PostalCodeInquiryReply reply = svc.postalCodeInquiry(request);



This code didn't generate any validation errors because i simply did not leave any of PostalCodeInquiryRequest class members not instantiated.

if are using Ruby,Python or PHP just check you fill all the SOAP request elements.


UPDATE : for a comprehensive details of what elements are missing check an element named "detail" of the SOAP exception response.

0 comments: