2015-11-03 122 views
2

当我在给出预期响应的Coldfusion服务器中调用canadaPost api时。但是当我在Lucee服务器中使用相同的调用时,它会引发消息失败。这两个服务器的响应标题为“Oracle-iPlanet-Web-Server/7.0”。但是在Lucee服务器中,响应mimetype是“application/octet-stream”,在coldfusion服务器中是“application/vnd.cpc.ship.rate-v3 + xml”。API响应文件内容在Lucee服务器上为空

这是问题的原因吗?请给出你的建议。

这里是我的代码:

<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> 

附截图被采取Lucee服务器上:

enter image description here

感谢

+0

是否调用成功,即200 OK或者你得到一个错误?你可以发布回复的转储吗? – Leigh

+0

@Leigh附上lucee服务器响应截图。 –

+0

作为cfSimplicity提到的SSL调用吗? (转储建议否..) – Leigh

回答

1

最后我被改变了cfhttpparam类型“XML”文件内容价值“身体”。

我修复:

<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> 

感谢您guyz ..

+0

这是没有授权头cfhttparam工作? – CfSimplicity

+0

是CfSimplicity。它没有授权标题cfhttpparam。 –

+0

这个特定的API调用是否确实需要授权(即用户名和密码)? – CfSimplicity

1

有一个在Lucee(以前Railo)中的错误从而在使用SSL时不会发送在<cfhttp>中指定的用户名和密码属性。

要解决它,你可以按以下方式发送使用<cfhttpparam> Authorization头:

<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> 
+0

但我在使用中的授权标题时遇到同样的问题。 –

相关问题