ColdFusion CFHTTP Post 到远程表单不返回结果页面,它只返回输入表单

发布于 2024-07-22 19:35:25 字数 1314 浏览 11 评论 0原文

我正在使用 ColdFusion 8。我尝试使用 CFHTTP Post 在此页面提交表单,而无需用户输入号码并单击“提交”。 https://testefile.boe.ca.gov/boewebservices/verification。 jsp?action=SALES

我以前用过其他表单,这通常不是问题。

这是我的代码:

<cfhttp url="https://testefile.boe.ca.gov/boewebservices/servlet/BOEVerification" method="POST" port="443" resolveurl="yes" redirect="yes">
<cfhttpparam type="FORMFIELD" name="type" value="SALES">
<cfhttpparam type="FORMFIELD" name="account" value="10003">
<cfhttpparam type="FORMFIELD" name="Submit" value="Submit+Request">
</cfhttp>

<Cfoutput>#cfhttp.fileContent#</CFOUTPUT>

<cfdump var="#cfhttp#">

如果您手动尝试该表单,并输入帐号 10003,它将返回结果页面 https://testefile.boe.ca.gov/boewebservices/verification_results.jsp

但是当我使用CFHTTP Post时,它只返回输入页面https://testefile.boe.ca.gov/boewebservices/verification.jsp?action=SALES

他们的一位开发人员做了一个Java页面来做我想做的同样的事情,而且它成功了。 不幸的是,我不懂Java。

谢谢,

里奇

I am using ColdFusion 8. I am trying to use CFHTTP Post to submit the form at this page without a user having to enter the number and click Submit. https://testefile.boe.ca.gov/boewebservices/verification.jsp?action=SALES

I've done with before with other forms, it's usually not a problem.

Here's my code:

<cfhttp url="https://testefile.boe.ca.gov/boewebservices/servlet/BOEVerification" method="POST" port="443" resolveurl="yes" redirect="yes">
<cfhttpparam type="FORMFIELD" name="type" value="SALES">
<cfhttpparam type="FORMFIELD" name="account" value="10003">
<cfhttpparam type="FORMFIELD" name="Submit" value="Submit+Request">
</cfhttp>

<Cfoutput>#cfhttp.fileContent#</CFOUTPUT>

<cfdump var="#cfhttp#">

If you try the form manually, and enter account number 10003, it returns a results page https://testefile.boe.ca.gov/boewebservices/verification_results.jsp

But when I use CFHTTP Post, it just returns the input page https://testefile.boe.ca.gov/boewebservices/verification.jsp?action=SALES

One of their developers made a Java page to do the same thing I'm trying to do, and it worked. Unfortunately, I don't know Java.

thanks,

Rich

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

你怎么敢 2024-07-29 19:35:25

嘿,Rich,之所以向您显示表单而不是预期结果,是因为“verification.jsp”模板希望您在点击它查看结果时拥有一个有效的会话。本身并不维护状态,因此像 Ben Nadel 的 CFHttpSession.cfc 可能有帮助。 CFHttpSession 将在之间管理 cookie(以及会话)。 通过解释 Set-Cookie 标头结果并将其添加回后续调用来进行调用。

在查看服务器的响应标头时我注意到的另一件事是会话 cookie (jsessionId) 被设置为“安全”。 这意味着 cookie 只能由安全连接使用。 我的测试环境中没有设置 SSL,因此我尝试使用 Ben 的对象失败了,但我认为如果您可以在 SSL 连接下进行测试,它很有可能会起作用。

这是我使用 Ben 的项目所做的简单测试:

<!--- CFHttpSession does not follow redirects, this is why two calls are needed --->
<cfset objHttpSession = CreateObject("component","CFHTTPSession").Init() />

<cfset objResponse = objHttpSession.NewRequest( "https://testefile.boe.ca.gov/boewebservices/servlet/BOEVerification" )
 .AddFormField( "type", "SALES" )
 .AddFormField( "account", 10003 )
 .AddFormField( "Submit", "Submit+Request" )
 .Post()/>

<cfset objResponse = objHttpSession
 .NewRequest( "https://testefile.boe.ca.gov/boewebservices/verification.jsp" )
 .get() />

<cfoutput>#objResponse.filecontent#</cfoutput>

** 可能还需要在其他调用之前进行另一个 http 调用,以便在发布之前建立会话。

Hey Rich, the reason why you are being shown the form instead of your expected results is because the "verification.jsp" template expects you to have a valid session when you hit it to view the results. <cfhttp> does not maintain state on it's own, so a project like Ben Nadel's CFHttpSession.cfc might help. CFHttpSession will manage cookies (and thus session) inbetween <cfhttp> calls by interpreting Set-Cookie header results and adding them back in on subsequent calls.

One other thing that I noticed when looking at the server's response headers was that the session cookie (jsessionId) was being set to 'secure'. This means that the cookie can only be used by secured connections. I don't have SSL set up in my test environment so my attempts in using Ben's object failed, but I would think that there is a good chance for it work if you can test under an SSL connection.

Here is the simple test I did using Ben's project:

<!--- CFHttpSession does not follow redirects, this is why two calls are needed --->
<cfset objHttpSession = CreateObject("component","CFHTTPSession").Init() />

<cfset objResponse = objHttpSession.NewRequest( "https://testefile.boe.ca.gov/boewebservices/servlet/BOEVerification" )
 .AddFormField( "type", "SALES" )
 .AddFormField( "account", 10003 )
 .AddFormField( "Submit", "Submit+Request" )
 .Post()/>

<cfset objResponse = objHttpSession
 .NewRequest( "https://testefile.boe.ca.gov/boewebservices/verification.jsp" )
 .get() />

<cfoutput>#objResponse.filecontent#</cfoutput>

** It might also be necessary to make a another http call prior to the others to establish the session before your post.

神经大条 2024-07-29 19:35:25

这可能是由于 https 地址造成的。 您可能需要将证书导入 java 密钥库才能成功连接。 尝试这篇文章来了解添加证书的过程: http://www .coldfusionmuse.com/index.cfm/2005/1/29/keystore

It could be due to the https address. You will probably need to import the certificate into the java keystore to successfully connect. Try this post for the process to add the certificate: http://www.coldfusionmuse.com/index.cfm/2005/1/29/keystore

我的痛♀有谁懂 2024-07-29 19:35:25

我猜您正在获取输入页面,因为服务器正在重定向您。 如果将重定向设置为“no”,cfhttp.errordetail 有什么用处吗?

I'm guessing you're getting the input page because the server is redirecting you. Is there anything useful in cfhttp.errordetail if you set redirect to "no" ?

热血少△年 2024-07-29 19:35:25

那么数据是否真的被提交到 BOEVerification 页面,还是永远不会提交到那么远?

So is the data actually being submitted to the BOEVerification page, or does it never get that far?

沫尐诺 2024-07-29 19:35:25

我遇到了同样的问题,并将 CFID 和令牌添加到请求中:

并使我的代码正常工作。

I was having the same issue, and added the CFID and Token to the request:

and got my code to work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文