使用HTTP POST时在URL中传递params [英] Passing params in the URL when using HTTP POST

查看:4844
本文介绍了使用HTTP POST时在URL中传递params的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用POST方法时,是否允许通过URL(问号后)将参数传递给网页?我知道它有效(大多数情况下,反正)因为我公司的webapp经常这样做,但我不知道它是否真的支持标准,或者我是否可以依赖这种行为。我正在考虑实现一个SOAP请求处理程序,它在问号后面使用一个参数来表明它是一个SOAP请求,而不是一个普通的HTTP请求。这样做的原因是webapp是一个IIS扩展,因此所有内容都通过相同的URL访问(例如:example.com/myisapi.dll?command),因此为了处理SOAP请求,我需要指定命令参数。 SOAP将有一个通用命令,而不是每个SOAP操作的特定命令 - 这些命令将在SOAP请求本身中指定。



基本上,我正在尝试通过让webapp处理HTTP请求将Apache Axis2 / C库集成到我的webapp中,然后将传入的SOAP XML传递给Axis2,以便在它是SOAP请求时进行处理。直觉上,我看不出有什么理由不起作用,因为你发布的URL只是一个任意的URL,就所有各种组件而言......它是赋予特殊含义的服务器问号后的部分。



感谢您提供的任何帮助/见解。

解决方案

让我们从简单的东西开始。 HTTP GET请求变量来自URI。 URI是一个请求的资源,因此任何webserver 应该(和apache确实)将整个URI存储在某个变量中,这些变量可用于在webserver中运行的模块或appserver组件。



与http GET不同的http POST是对Web服务器的单独逻辑调用,但它仍然定义了应该处理帖子的URI。一个好的网络服务器(apache是​​一个)将再次使URI可用于其中运行的任何模块或应用程序服务器,然后将另外提供在POST标头中发送的变量。



在POST期间,您的应用程序从apache获取控制权时,您应该可以访问GET和POST变量,并且能够执行您希望的任何控制逻辑,包括使用SOAP协议而不是HTML进行回复。 / p>

Is it allowable to pass parameters to a web page through the URL (after the question mark) when using the POST method? I know that it works (most of the time, anyways) because my company's webapp does it often, but I don't know if it's actually supported in the standard or if I can rely on this behavior. I'm considering implementing a SOAP request handler that uses a parameter after the question mark to indicate that it is a SOAP request and not a normal HTTP request. The reason for this that the webapp is an IIS extension, so everything is accessed via the same URL (ex: example.com/myisapi.dll?command), so to get the SOAP request to be processed, I need to specify that "command" parameter. There would be one generic command for SOAP, not a specific command for each SOAP action -- those would be specified in the SOAP request itself.

Basically, I'm trying to integrate the Apache Axis2/C library into my webapp by letting the webapp handle the HTTP request and then pass off the incoming SOAP XML to Axis2 for handling if it's a SOAP request. Intuitively, I can't see any reason why this wouldn't work, since the URL you're posting to is just an arbitrary URL, as far as all the various components are concerned... it's the server that gives special meaning to the parts after the question mark.

Thanks for any help/insight you can provide.

解决方案

Lets start with the simple stuff. HTTP GET request variables come from the URI. The URI is a requested resource, and so any webserver should (and apache does) have the entire URI stored in some variable available to the modules or appserver components running within the webserver.

An http POST which is different from an http GET is a separate logical call to the webserver, but it still defines a URI that should process the post. A good webserver (apache being one) will again make the URI available to whatever module or appserver is running within it, then will additionally make available the variables which were sent in the POST headers.

At the point where your application takes control from apache during a POST you should have access to both the GET and POST variables and be able to do whatever control logic you wish, including replying with a SOAP protocol instead of HTML.

这篇关于使用HTTP POST时在URL中传递params的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆