Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Evan_at_RM #1
Trouble with CFHTTP Post XML to FedEx
I am developing a ColdFusion application to request shipment information from
FedEx. Their FSM Direct guidelines specify the format of the XML Request to
submit, as well as the format of the XML Reply that I should expect to receive.
However, when I run the code, I get an "Error 500 - Internal Server Error".
The code below is listed at the end of this posting. Since this Forum Posting
content is published via Usenet, Google, etc. , personal info has been removed.
But even when the personal info was there, I got the 500 error.
The server I use has port 443 open because I can use simpler code just to
reach a different HTTPS site.
I looked at the topic "CFHTTP / XML POST wierd Errors", which looked similar,
but still had no success when I tried adjusting the CFHTTPPARAMs similarly.
(That topic was for UPS, not FedEx, but I thought maybe its system would be
similar.)
Thank you for any suggestions.
-- Evan
(Start of Code (below) )
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Generate SubscriptionRequest</title>
</head>
<body>
<!--- This is the code from MakeSubscriptionRequest.cfm, with
PersonalInfoRemoved. --->
<!--- Fields to pass via SubscriptionRequest XML.
Note that some of the other fields (LanguageCode, ReturnLetterFormat, etc.)
are hard-coded because their values will not vary for our work. --->
<cfset vCustomerTransID = "MyOwnIDHere032205"> <!--- On USA Airbill, Your
Internal Billing Reference --->
<cfset vAcctNumber = "123456789"> <!--- (Real acct number not shown) --->
<!---
<cfset vMeterNumber = "">
MeterNumber will be returned as a result of the one-time SubscriptionRequest.
It is not needed as a parameter, and should not be supplied.
However, if the purpose of the SubscriptionRequest was to UPDATE EXISTING
meter info,
then it would be required.
--->
<cfset vContact_PersonName = "My Name">
<cfset vContact_CompanyName = "My Company Name">
<cfset vContact_Department = "My Dept Name">
<cfset vContact_PhoneNumber = "7775551212">
<cfset vContact_FaxNumber = "7775551313">
<cfset vContact_EmailAddress = "myemail@mycompany.com">
<cfset vAddress_AddrLine1 = "123 Main Street">
<cfset vAddress_AddrLine2 = "2nd Floor">
<cfset vAddress_City = "Anytown">
<cfset vAddress_StateOrProvinceCode = "NY">
<cfset vAddress_PostalCode = "12345">
<cfset vAddress_CountryCode = "US">
<!--- Build XML from variables --->
<cfoutput>
<cfprocessingdirective SUPPRESSWHITESPACE="yes">
<cfsavecontent variable="vSubscriptionRequest">
<?xml version="1.0" encoding="UTF-8" ?>
<FDXSubscriptionRequest
xmlns:api="http://www.fedex.com/fsmapi"
xmlns:xsi="http://www.w3.org/2001/XML-Schema-instance"
xsi:noNamespaceSchemaLocation="FDXSubscriptionRequ est.xsd">
<RequestHeader>
<CustomerTransactionIdentifier>#vCustomerTransID #</CustomerTransactionIdentifie
r>
<AccountNumber>#vAcctNumber#</AccountNumber>
</RequestHeader>
<Contact>
<PersonName>#vContact_PersonName#</PersonName>
<CompanyName>#vContact_CompanyName#</CompanyName>
<Department>#vContact_Department#</Department>
<PhoneNumber>#vContact_PhoneNumber#</PhoneNumber>
<FaxNumber>#vContact_FaxNumber#</FaxNumber>
<E-mailAddress>#vContact_EmailAddress#</E-mailAddress>
</Contact>
<Address>
<Line1>#vAddress_AddrLine1#</Line1>
<Line2>#vAddress_AddrLine2#</Line2>
<City>#vAddress_City#</City>
<StateOrProvinceCode>#vAddress_StateOrProvinceCode #</StateOrProvinceCode>
<PostalCode>#vAddress_PostalCode#</PostalCode>
<CountryCode>#vAddress_CountryCode#</CountryCode>
</Address>
</FDXSubscriptionRequest><!--- --->
</cfsavecontent>
</cfprocessingdirective>
</cfoutput>
<cfset vContentLen = #len(vSubscriptionRequest)#>
<cfoutput>
<cfsavecontent variable="vFedExHTTPPOST">
POST /GatewayDC HTTP/1.0
Referer: Redi-Mail Direct Marketing
Host: gatewaybeta.fedex.com:443
Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*
Content-Type: image/gif
Content-length: #vContentLen#
#vSubscriptionRequest#
</cfsavecontent>
</cfoutput>
<cfoutput>
<cfhttp method="POST" url="https://gatewaybeta.fedex.com/GatewayDC"
port="443">
<cfhttpparam name="Content-Type" type="HEADER" value="content-type: text/xml;
charset='UTF-8';">
<cfhttpparam type="body" value="#vFedExHTTPPOST#">
</cfhttp>
</cfoutput>
<cfoutput>#cfhttp.filecontent#</cfoutput>
</body>
</html>
(End of Code (above) )
-- Evan
Evan_at_RM Guest
-
How to post xml with cfhttp error?! HELP
<cfhttp url = "http://10.1.6.211/ProposalGenerator.aspx" METHOD="POST" throwOnError = "yes" > <cfhttpparam name="propxml" TYPE="FORMFIELD"... -
Sending an xml doc via cfhttp post
I am receiveing the following error when trying to send xml via cfhttp - Connection Failure: Status code unavailable The xml code works fine... -
need help with perl api for Fedex shipping charge
Hi Does any know any good perl modules can connect to Fedex system and retrieve the shipping charge. I work on a online shopping cart system and... -
Redirecting from Get to Post (maybe via CFHTTP??)
Hey all, looking for some advice. Here is the situation... I have a website with links that go to a redirection script (to track clicks and... -
fedex calculate shipping rate
hi folks: Does anyone know how to calculate the shipping rate on Fedex? There was a web module to handle the web query for rate at... -
Defuse #2
Re: Trouble with CFHTTP Post XML to FedEx
Okay, I know that this was posted several months ago, but I think I figured out
your 500 ISE problem. Of course, by now, you may have figured it out as well.
Where you have:
<cfoutput>
<cfsavecontent variable="vFedExHTTPPOST">
POST /GatewayDC HTTP/1.0
Referer: 300 Apparel
Host: gatewaybeta.fedex.com:443
Accept: "image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*"
Content-Type: "image/gif"
Content-length: #vContentLen#
#vSubscriptionRequest#
</cfsavecontent>
</cfoutput>
I changed it to:
<cfhttp method="POST" url="https://gatewaybeta.fedex.com/GatewayDC" port="443">
<cfhttpparam name="Referer" type="HEADER" value="300 Apparel" />
<cfhttpparam name="Host" type="HEADER"
value="https://gatewaybeta.fedex.com:443" />
<cfhttpparam name="Accept" type="HEADER" value="image/gif, image/jpeg,
image/pjpeg, text/plain, text/html, */*" />
<cfhttpparam name="Content-Type" type="HEADER" value="content-type:
text/xml; charset='UTF-8';" />
<cfhttpparam name="Content-Length" type="HEADER" value="#vContentLen#" />
<!---<cfhttpparam type="body" value="#vFedExHTTPPOST#" />--->
</cfhttp>
It still throws an error, but at least it's a different error so you can start
to narrow it down.
This is the error I get, but then I didn't change any of the other information.
Error 405--Transaction data not found.
Anyway, hope this helps. And if you found a solution, would you mind sharing
it?
Thanks!
Defuse Guest
-
Scooby Doobie Doo #3
Re: Trouble with CFHTTP Post XML to FedEx
yes, please post a solution if you've gotten this to work,I'm having a simliar problem and can't find any info on this subject.
Scooby Doobie Doo Guest
-
Defuse #4
Re: Trouble with CFHTTP Post XML to FedEx
Hey Scooby,
I'm actually right in the middle of working with FedEx on an ecommerce app. As soon as I get finished, I'll post what I have as a solution so that others can use my example.
Defuse Guest



Reply With Quote

