FedEx provides an API for requesting rates and shipments by sending XML requests to their server. On their end they are using a Netscape-Enterprise/4.1 server and a SAX parser, all well and good. Seems however that their response is not standards compliant.

Response Issues

The response from their server indicates a Content-Type of image/gif, when infact the type should be application/xml. Below is an example. What this means to developers is this: don't listen to what FedEx says.

HTTP/1.1 200 OK
Server: Netscape-Enterprise/4.1
Date: Wed, 10 May 2006 19:43:01 GMT
Content-length: 808
Content-Type: image/gif

[ 808 bytes of UTF-8 XML Here ]

We were coding a FedEx interface for one of our clients and were expecting to see a proper HTTP header. Caused a little issue but switching curl to verbose output assisted with solving that issue real quick.

Resolution

All responses, including errors, are properly formatted XML, not like the FHA who sometimes gives XML and sometimes HTML3.2. We can disregard the HTTP resonse headers from FedEx as they are worthless.

We made an attempt to contact FedEx on this issue but were given incomplete and inaccurate responses. We were told that the examples don't specify a MIME type (not our question). So we tried again and were told this time that it's left over from some old templates and that anyways the response should be text/plain.

Ok so, firstly it's an incorrect MIME type, secondly the question was completely mis-understood, third text/plain != application/xml. Below is a transcript, with cruft removed.

[ Edoceo to FedEx ]
Were you aware that your web server response is not accurate?

The response headers are:

HTTP/1.1 200 OK
Server: Netscape-Enterprise/4.1
Date: Wed, 10 May 2006 15:19:07 GMT
Content-length: 808
Content-Type: image/gif

But the content is not a GIF file, it's XML.  Whats going on there?

[ FedEx to Edoceo ]
The example HTTP posts in the FSM Direct manual do not specify any MIME type as you
are stating but he image/gif that you mention is correct for the HTTP post.  The
response transaction is returned in plain text in the XML format described in the
XML transaction guide.

[ Edoceo to FedEx ]
Clearly you do not understand my question.

  The MIME type of image/gif is only acceptable if the content of the HTTP
message is a GIF image file, which neither the Request or Reply message
are.  Both the Request and Reply are text/xml MIME types.  I fully
understand that.  My question to you is: "Why does your
Netscape-Enterprise/4.1 server respond with a content type of image/gif
when it should be saying text/xml in the HTTP response header
Content-Type field."

  I'm not asking about the content, or the request, or spec, or documents
or any of that other stuff.  I know what the spec says, I've seen the
HTTP request and response on the wire.  I see the response content is
XML.  The question is simply why is your server responding with the
incorrect MIME type? Why does it say image/gif but give me text/xml?  If
you're giving me text/xml should you also tell me its text/xml?  That
would only make sense wouldn't it?

[ FedEx to Edoceo ]
The MIME type is being returned as image\gif since we are still using a template
that was used when GIF images were returned in transactions.  This is no longer the
case but as the template still functions the MIME type of image\gif being returned
should not be a concern.  Also the transaction itself would fall under the
text\plain type.

[ Edoceo to FedEx ]
text/plain is not correct, please read the standards and pay specific 
attention to application/xml and text/xml.  Perhaps RFC2616 would help too.

http://www.w3.org/TR/xhtml-media-types/#application-xml

I've worked around the bugs in your system, no response is necessary.

/djb

See Also

ChangeLog

  • 10 May 2006 - Created /djb