rates error

22 views
Skip to first unread message

Brian Pokosh

unread,
Aug 8, 2009, 5:29:34 PM8/8/09
to Shippinglogic
I'm getting an error when trying the fedex.rate call:

Shippinglogic::FedEx::Error: Schema validation failed for request.,
Expected element 'CountryCode@http://fedex.com/ws/rate/v6' instead of
'Residential@http://fedex.com/ws/rate/v6' here in element
Address@http://fedex.com/ws/rate/v6, and Expected element
'CountryCode@http://fedex.com/ws/rate/v6' before the end of the
content in element Address@http://fedex.com/ws/rate/v6

I'm using the example in the code:
rates = fedex.rate(
:shipper_postal_code => "10007",
:shipper_country => "US",
:recipient_postal_code => "75201",
:recipient_country_code => "US",
:package_weight => 24,
:package_length => 12,
:package_width => 12,
:package_height => 12
)

It might be a good idea to save the XML request and response so that
they can be viewed later.

Ben Johnson

unread,
Aug 8, 2009, 5:36:19 PM8/8/09
to shippi...@googlegroups.com
Hey Brian,

Use country, not country_code.

I don't do any validation on my end because that is fedex's job. More
importantly, I dont want to keep up with their validation changes, etc
because they don't document that.

Anyways country refers to the element they want.

Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

Ben Johnson

unread,
Aug 8, 2009, 5:40:14 PM8/8/09
to shippi...@googlegroups.com
Also, the response is saved in the error object

rescue Shippinglogic::FedEx::Error => e
e.response
end

Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

On Aug 8, 2009, at 5:29 PM, Brian Pokosh wrote:

Brian Pokosh

unread,
Aug 8, 2009, 5:46:37 PM8/8/09
to Shippinglogic
I'm still getting the error. Here's the code I'm using, it's the same
an in your example but I removed the _code:

rates = fedex.rate(
:shipper_postal_code => "10007",
:shipper_country => "US",
:recipient_postal_code => "75201",
:recipient_country => "US",
:package_weight => 24,
:package_length => 12,
:package_width => 12,
:package_height => 12
)

Any ideas?

On Aug 8, 5:36 pm, Ben Johnson <bjohn...@binarylogic.com> wrote:
> Hey Brian,
>
> Use country, not country_code.
>
> I don't do any validation on my end because that is fedex's job. More  
> importantly, I dont want to keep up with their validation changes, etc  
> because they don't document that.
>
> Anyways country refers to the element they want.
>
> Ben Johnson
> Binary Logic
>
> W:www.binarylogic.com
> E: bjohn...@binarylogic.com

Ben Johnson

unread,
Aug 8, 2009, 5:55:42 PM8/8/09
to shippi...@googlegroups.com
Your request looks good to me. I just released a new version for you.
Update to that version and do this:

begin
# your fedex code here


rescue Shippinglogic::FedEx::Error => e

raise e.request.inspect
end

That should show your raw request. Be sure and mask your fedex
credentials. But that should tell us whats going on. All of my tests
are passing and I'm currently rating packages in my app right now. So
it's probably something dumb.


Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

Brian Pokosh

unread,
Aug 8, 2009, 6:38:06 PM8/8/09
to Shippinglogic
I haven't looked at what you changed yet, but whatever it was fixed
it. I'll do some more testing later.

Something I noticed is when I make a change to the request - say I
change the weight and call fedex.rate again - it returns the cached
result. Is it assumed that I will create a new fedex object for each
request?

On Aug 8, 5:55 pm, Ben Johnson <bjohn...@binarylogic.com> wrote:
> Your request looks good to me. I just released a new version for you.  
> Update to that version and do this:
>
> begin
>         # your fedex code here
> rescue Shippinglogic::FedEx::Error => e
>         raise e.request.inspect
> end
>
> That should show your raw request. Be sure and mask your fedex  
> credentials. But that should tell us whats going on. All of my tests  
> are passing and I'm currently rating packages in my app right now. So  
> it's probably something dumb.
>
> Ben Johnson
> Binary Logic
>
> W:www.binarylogic.com
> >>> 'Residential@http://fedex.com/ws/rate/v6'herein element
> >>> Address@http://fedex.com/ws/rate/v6, and Expected element
> >>> 'CountryCode@http://fedex.com/ws/rate/v6'beforethe end of the

Ben Johnson

unread,
Aug 8, 2009, 7:23:14 PM8/8/09
to shippi...@googlegroups.com
No, I haven't really thought about doing that, but no you should not
have to create a new object for each request. Let me write some tests
for that and come up with a solution. What I am trying to avoid with
the caching is this:

rates = fedex.rate
rates.first
rates.last

The 2 last lines should not make 2 requests, but what I think I'll do
is clear the cache if any attributes are changed.

Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

Ben Johnson

unread,
Aug 9, 2009, 2:23:43 PM8/9/09
to shippi...@googlegroups.com
Ok, this is fixed, just update the gem.

Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

Reply all
Reply to author
Forward
0 new messages