2

When i call the canadaPost api in Coldfusion server that is giving the expected response. But when i Use the same call in Lucee server, It throws the message fail. The response header is "Oracle-iPlanet-Web-Server/7.0" for both servers. But the response mimetype is "application/octet-stream" in Lucee server and "application/vnd.cpc.ship.rate-v3+xml" in coldfusion server.

Is that the cause of the issue? Please give your suggestion about this.

Here is my code:

<cfset local.url = "https://ct.soa-gw.canadapost.ca/rs/ship/price">

<cfhttp url="#local.url#" method="post" result="httpResponse" username="#variables.username#" password="#variables.password#">
    <cfhttpparam type="header" name="Accept" value="application/vnd.cpc.ship.rate-v3+xml"/>
    <cfhttpparam type="xml" value="#trim(xmlRequest)#"/>
    <cfhttpparam type="header" name="Content-type" value="application/vnd.cpc.ship.rate-v3+xml">
</cfhttp>

Attached screenshot which is taken on Lucee server:

enter image description here

Thanks

Sathish Chelladurai
  • 670
  • 1
  • 8
  • 23

2 Answers2

1

There is a bug in Lucee (and previously Railo) whereby the username and password attributes specified in <cfhttp> are not sent when using SSL.

To work around it you can send the Authorization header using <cfhttpparam> as follows:

<cfhttp url="#local.url#" method="post" result="httpResponse">
    <cfhttpparam type="header" name="Accept" value="application/vnd.cpc.ship.rate-v3+xml"/>
    <cfhttpparam type="xml" value="#trim(xmlRequest)#"/>
    <cfhttpparam type="header" name="Content-type" value="application/vnd.cpc.ship.rate-v3+xml">
    <cfhttpparam type="header" name="Authorization" value="Basic #ToBase64( variables.username & ':' & variables.password )#">
</cfhttp>
CfSimplicity
  • 2,338
  • 15
  • 17
1

Finally I got the file content value by changed the cfhttpparam type "xml" to "body".

My Fix:

<cfset local.url = "https://ct.soa-gw.canadapost.ca/rs/ship/price">
<cfhttp url="#local.url#" method="post" result="httpResponse" username="#variables.username#" password="#variables.password#">
    <cfhttpparam type="header" name="Accept" value="application/vnd.cpc.ship.rate-v3+xml"/>
    <cfhttpparam type="body" value="#trim(xmlRequest)#"/>
    <cfhttpparam type="header" name="Content-type" value="application/vnd.cpc.ship.rate-v3+xml">
</cfhttp>

Thank you guyz..

Sathish Chelladurai
  • 670
  • 1
  • 8
  • 23