将SoapUI请求转换为CFHTTP

编程入门 行业动态 更新时间:2024-10-28 15:32:32
本文介绍了将SoapUI请求转换为CFHTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

> GET test-01.mywebsite/data_api//1.0/service/requests HTTP / 1.1 [\r] [\\\]>> Accept-Encoding:gzip,deflate [\r] [\\\]>> 授权:承载A1BEC30F7E0273059E775A6A2645E273 [\r] [\\\]>> Host:test-01.mywebsite [\r] [\\\]>> Connection:Keep-Alive [\r] [\\\]>> User-Agent:Apache-HttpClient / 4.1.1(java 1.5)[\r] [\\\]>> [\ r] [\\\]<< HTTP / 1.1 200 OK [\r] [\\\]<< Pragma:No-cache [\r] [\\\]< Cache-Control:no-cache [\ r] [\ n]< Expires:Wed,31 Dec 1969 16:00:00 PST [\r] [\\\]< Content-Type:application / json; charset = UTF-8 [\r] [\\\]< Content-Length:6796 [\r] [\\\]<< Date:Fri,13 May 2016 15:40:08 GMT [\r] [\\\]<< Server:hws [\r] [\\\]<< Set-Cookie:X-HR-ClientSessionId = 2_10.85.12.121_1463154008475; Secure; path = /; HttpOnly [\r] [\\\]< Content-Encoding:deflate [\r] [\\\]

如果我没有正确格式化授权头或什么,但任何帮助将是巨大的。

EDIT 我有一个RAW HTML输出从客户端

我的新问题:新行的字符有所不同,

b

< cfset NL =Bearer BD4DF031B24180C9338F0D9F060556A7& Chr(10)& Chr(13)/> ; cfhttp method =geturl =test-01.mywebsite/data_api//1.0/service/requestsresult =orderList> < cfhttpparam type =HEADER name =Authorizationvalue =#NL#> < cfhttpparam type =Headername =Accept-Encodingvalue =gzip,deflate> < / cfhttp> ; < cfset CurrentOrders = deserializeJSON(orderList.filecontent)> < cfdump var =#CurrentOrders#>

当我从cfhttp调用中转储所有内容时,我得到:

struct Charset UTF-8 ErrorDetail [空字符串] Filecontent连接失败 Header HTTP / 1.1 200 OK连接:close过期日期:Wed,31 Dec 1969 16:00:00 PST日期:2016年05月17日19:23:36 GMT服务器:hws Pragma:No-cache Cache-Control:no-cache Set-Cookie:X-HR-ClientSessionId = 3_12.161.115.226_1463513016026;安全; path = /; HttpOnly Content-Type:application / json; charset = UTF-8 Mimetype应用程序/ json Responseheader struct 缓存控制无缓存连接关闭 Content-Type application / json; charset = UTF-8 Date Tue,17 May 2016 19:23:36 GMT 到期星期三,1969年12月31日16:00:00 PST 说明OK Http_Version HTTP / 1.1 Pragma无缓存服务器hws Set-Cookie X-HR-ClientSessionId = 3_12.161.115.226_1463513016026;安全; path = /; HttpOnly Status_Code 200 Statuscode 200 OK Text NO

I获取200 OK状态代码,但仍然收到连接失败。

解决方案

看起来您是双重加密您的安全令牌。 我修改了您的代码,以便我可以根据 Leighs答案使用Fiddler捕获请求。要让ColdFusion通过Fiddler发送流量,我修改了http的 Dmitri Pisarenko 答案,并将其添加到我的JVM参数。 p>

< cfhttp method =geturl =http://localhost/data_api/1.0/service/requestsresult = orderList> < cfhttpparam type =HEADERname =Authorizationvalue =Basic#ToBase64(Bearer 6EDC52118E164AE659EA2C772F3B9804)#> < cfhttpparam type =Headername =Accept-Encodingvalue =gzip,deflate> < / cfhttp>

我离开了 cfhttp 是:

GET http://localhost/data_api/1.0/service/requests HTTP / 1.1 用户代理:Mozilla / 5.0(Windows NT 6.3; WOW64; Trident / 7.0; rv:11.0)like Gecko Accept-Encoding:gzip,deflate Connection:close 授权:基本QmVhcmVyIDZFREM1MjExOEUxNjRBRTY1OUVBMkM3NzJGM0I5ODA0 Host:localhost Connection:Keep-Alive

我将授权参数的值修改为:Bearer 6EDC52118E164AE659EA2C772F3B9804我得到一个头,其中包含与来自SoapUI的原始头匹配的认证头:

GET http:// localhost / data_api / 1.0 / service / requests HTTP / 1.1 用户代理:Mozilla / 5.0(Windows NT 6.3; WOW64; Trident / 7.0; rv:11.0)like Gecko Accept-Encoding:gzip,deflate 连接:close 授权:承载6EDC52118E164AE659EA2C772F3B9804 主机:localhost 连接:Keep-Alive

I am looking at a request in SoapUI that is sending header info to a specific endpoint but I am having a hard time recreating it in ColdFusion.

Below is what the RAW request looks like in SoapUI:

>> "GET test-01.mywebsite/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[\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]"

I am not sure if I am not formatting the Authorization header correctly or what but any help would be great.

EDIT I got a RAW HTML output from the client which I have updated above. I am still trying to recreate that header in ColdFusion.

My New question(s): Do the "New Line" characters make a difference in the header values? Should I also add a parameter for the content type?

I did try the following:

<cfset NL="Bearer BD4DF031B24180C9338F0D9F060556A7" & Chr(10) & Chr(13)/> <cfhttp method="get" url="test-01.mywebsite/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#">

When I dump everything from the cfhttp call I get:

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

I am getting a 200 OK status code but still getting a Connection Failure.

解决方案

It looks like you're double encrypting your security token. I modified your code so I could capture the request with Fiddler as per Leighs Answer. To get ColdFusion to send the traffic through Fiddler I modified Dmitri Pisarenko answer for http and added it to my JVM Arguments.

<cfhttp method="get" url="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>

The head I get leaving the cfhttp request is:

GET 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

As you can see, the Authorization header isn't the same as what SoapUI created.

I modified the value of the Authorization param to : "Bearer 6EDC52118E164AE659EA2C772F3B9804" and I get a header with an authentication header that matches the raw header from SoapUI:

GET 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

更多推荐

将SoapUI请求转换为CFHTTP

本文发布于:2023-11-26 19:46:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634953.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   SoapUI   CFHTTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!