【发布时间】:2016-05-12 16:01:21
【问题描述】:
我正在查看 SoapUI 中的请求,该请求将标头信息发送到特定端点,但我很难在 ColdFusion 中重新创建它。
以下是 SoapUI 中 RAW 请求的样子:
>> "GET https://test-01.mywebsite.com/data_api//1.0/service/requests HTTP/1.1[\r][\n]"
>> "Accept-Encoding: gzip,deflate[\r][\n]"
>> "Authorization: Bearer A1BEC30F7E0273059E775A6A2645E273[\r][\n]"
>> "Host: test-01.mywebsite.com[\r][\n]"
>> "Connection: Keep-Alive[\r][\n]"
>> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"
>> "[\r][\n]"
<< "HTTP/1.1 200 OK[\r][\n]"
<< "Pragma: No-cache[\r][\n]"
<< "Cache-Control: no-cache[\r][\n]"
<< "Expires: Wed, 31 Dec 1969 16:00:00 PST[\r][\n]"
<< "Content-Type: application/json;charset=UTF-8[\r][\n]"
<< "Content-Length: 6796[\r][\n]"
<< "Date: Fri, 13 May 2016 15:40:08 GMT[\r][\n]"
<< "Server: hws[\r][\n]"
<< "Set-Cookie: X-HR-ClientSessionId=2_10.85.12.121_1463154008475;Secure; path=/; HttpOnly[\r][\n]"
<< "Content-Encoding: deflate[\r][\n]”
我不确定我是否没有正确格式化 Authorization 标头,或者任何帮助都会很好。
EDIT 我从上面更新的客户端得到了一个 RAW HTML 输出。我仍在尝试在 ColdFusion 中重新创建该标题。
我的新问题:“换行”字符是否会影响标题值?我还应该为内容类型添加一个参数吗?
我确实尝试了以下方法:
<cfset NL="Bearer BD4DF031B24180C9338F0D9F060556A7" & Chr(10) & Chr(13)/>
<cfhttp method="get" url="https://test-01.mywebsite.com/data_api//1.0/service/requests" result="orderList">
<cfhttpparam type="HEADER" name="Authorization" value="#NL#">
<cfhttpparam type="Header" name="Accept-Encoding" value="gzip,deflate">
</cfhttp>
<cfset CurrentOrders = deserializeJSON(orderList.filecontent)>
<cfdump var="#CurrentOrders#">
当我从 cfhttp 调用中转储所有内容时,我得到:
struct
Charset UTF-8
ErrorDetail [empty string]
Filecontent Connection Failure
Header HTTP/1.1 200 OK Connection: close Expires: Wed, 31 Dec 1969 16:00:00 PST Date: Tue, 17 May 2016 19:23:36 GMT Server: hws Pragma: No-cache Cache-Control: no-cache Set-Cookie: X-HR-ClientSessionId=3_12.161.115.226_1463513016026;Secure; path=/; HttpOnly Content-Type: application/json;charset=UTF-8
Mimetype application/json
Responseheader
struct
Cache-Control no-cache
Connection close
Content-Type application/json;charset=UTF-8
Date Tue, 17 May 2016 19:23:36 GMT
Expires Wed, 31 Dec 1969 16:00:00 PST
Explanation OK
Http_Version HTTP/1.1
Pragma No-cache
Server hws
Set-Cookie X-HR-ClientSessionId=3_12.161.115.226_1463513016026;Secure; path=/; HttpOnly
Status_Code 200
Statuscode 200 OK
Text NO
我收到 200 OK 状态代码,但仍然收到连接失败。
【问题讨论】:
-
不确定我是否遵循了某些问题之外的确切问题;-) 1) 首先,首先从 cfhttp 转储完整响应。什么是完整的错误信息? 2)为了澄清你说的是来自 SoapUI succeeds 的“原始请求”,但 cfhttp 没有? 3)cfhttp“RAW request”长什么样子,两者有什么不同?
-
我会用你上面提到的信息更新我的问题。谢谢。\
-
我已经从 cfhttp 请求中添加了 orderList 的完整输出。我很难在最后查看原始标头,因为当我将请求发送到本地文件时,授权标头会将其丢弃,因为我必须添加本地用户名和密码才能访问测试页面。是的,SoapUI 确实成功了,上面是 Raw html。 CFHTTP 请求不成功。如果有什么具体的我可以运行和输出,请告诉我。
-
必须添加我的本地用户名和密码才能访问测试页面。您是使用 Fiddler 调试 CFHTTP 请求(最好)还是只是将请求发送到测试页面你的本地服务器?
-
NTLM,还有另一个问题可能是什么。 NTLM 身份验证与基本身份验证不同。
标签: coldfusion http-headers cfhttp