gpt4 book ai didi

coldfusion - 将 SoapUI 请求转换为 CFHTTP

转载 作者:行者123 更新时间:2023-12-01 13:43:59 26 4
gpt4 key购买 nike

我在 SoapUI 中查看将 header 信息发送到特定端点的请求,但我很难在 ColdFusion 中重新创建它。

下面是原始请求在 SoapUI 中的样子:

>> "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 header 或什么,但任何帮助都会很棒。

编辑 我从上面更新的客户端获得了 RAW HTML 输出。我仍在尝试在 ColdFusion 中重新创建该 header 。

我的新问题:“换行”字符对标题值有影响吗?我还应该为内容类型添加一个参数吗?

我确实尝试了以下操作:

<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 状态代码,但仍然收到连接失败。

最佳答案

看起来您正在对您的安全 token 进行双重加密。我修改了您的代码,以便我可以根据 Leighs Answer 使用 Fiddler 捕获请求.为了让 ColdFusion 通过 Fiddler 发送流量,我修改了 Dmitri Pisarenko回答 http 并将其添加到我的 JVM 参数中。

<cfhttp method="get" url="http://localhost/data_api/1.0/service/requests" result="orderList">
<cfhttpparam type="HEADER" name="Authorization" value="Basic #ToBase64("Bearer 6EDC52118E164AE659EA2C772F3B9804")#">
<cfhttpparam type="Header" name="Accept-Encoding" value="gzip,deflate">
</cfhttp>

我离开 cfhttp 请求的头部是:

GET http://localhost/data_api/1.0/service/requests HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip,deflate
Connection: close
Authorization: Basic QmVhcmVyIDZFREM1MjExOEUxNjRBRTY1OUVBMkM3NzJGM0I5ODA0
Host: localhost
Connection: Keep-Alive

如您所见,授权 header 与 SoapUI 创建的不同。

我将 Authorization 参数的值修改为:"Bearer 6EDC52118E164AE659EA2C772F3B9804" 并且我得到一个 header ,其中的身份验证 header 与来自 SoapUI 的原始 header 相匹配:

GET http://localhost/data_api/1.0/service/requests HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip,deflate
Connection: close
Authorization: Bearer 6EDC52118E164AE659EA2C772F3B9804
Host: localhost
Connection: Keep-Alive

关于coldfusion - 将 SoapUI 请求转换为 CFHTTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37192079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com