SOAP 标头与 HTTP 标头 [英] SOAP headers versus HTTP headers

查看:44
本文介绍了SOAP 标头与 HTTP 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 Web 服务的程序,为此我需要将一些数据包装为消息的标头.

I am working on a program using web services and for that I need to wrap some data as headers for the message.

我想问一下,把这个数据作为SOAP头或者HTTP头是等效的吗?

I want to ask if it is equivalent to place this data as SOAP headers or as HTTP headers?

推荐答案

SOAP 标头 包含与 SOAP 消息相关的应用程序特定信息.它们通常包含路由信息,身份验证信息、事务语义等.这些特定于 SOAP 消息并且与 SOAP 使用的传输无关(在这篇文章的范围内:HTTP).

The SOAP headers contain application specific information related to the SOAP message. They typically contain routing information, authentication information, transaction semantics etc. These are specific to the SOAP message and are independent of the transport that SOAP uses (in the scope of this post: HTTP).

HTTP headers 定义了HTTP 事务,例如传输内容的内容类型、内容长度、客户端或代理的缓存指令等.这些是特定于 HTTP 的,独立于 HTTP 实际传输的内容(在本例中为 SOAP XML).

HTTP headers define the operating parameters of the HTTP transaction, like the content type of what's getting transmitted, the content length of it, cache directives for clients or proxies etc. These are specific to HTTP and are independent on what actually gets transmitted with HTTP (in this case the SOAP XML).

当然,您可以同时使用 HTTP 标头或 SOAP 标头来提供有关 SOAP 消息的特定于应用程序的信息.SOAPAction HTTP 标头是 SOAP 朝着这个方向迈出的一步1.1.尽管服务器无需查看内部信息即可有效地路由消息很有用SOAP XML(如果消息是加密的并且只有最终接收者知道如何解密,则有时不可能)它主要引起混淆,后来在SOAP 1.2(取而代之的是 上的可选 action 参数>application/soap+xml media 类型,这也是 HTTP 标头中的一个值......哦...... :D).

You could, of course, use both HTTP headers or SOAP headers to provide application specific information about the SOAP message. The SOAPAction HTTP header was a move in this direction for SOAP 1.1. Although it was useful for servers to efficiently route the messages without the need to look inside the SOAP XML (sometimes impossible if the message is encrypted and only the final receiver knows how to decrypt it) it mostly caused confusion and was later removed in SOAP 1.2 (and in its place is an optional action parameter on the application/soap+xml media type, which again is a value in the HTTP headers... oh well... :D).

总而言之,SOAP 标头和 HTTP 标头不同.尽管在某种程度上,您可以用用户定义的自定义 HTTP 标头替换 SOAP 标头,但大多数情况下这是个坏主意.

As a conclusion, SOAP headers and HTTP headers are not the same. Although to some extent you might substitute SOAP headers with user defined custom HTTP headers, it is most of the times a bad idea.

如果数据用于 Web 服务,则应将其放置在 SOAP 标头内.HTTP 标头通常在 Web 服务器处停止,而整个 SOAP 消息将向下游传递到需要数据的最终接收方(甚至可能通过更多可能也需要数据的中介).

If the data is for the web service then it should be placed inside the SOAP headers. HTTP headers usually stop at the web server while the SOAP message in it's entirety will be passed downstream to the ultimate receiver who needs the data (maybe even passing through more intermediaries who they might also need it).

这篇关于SOAP 标头与 HTTP 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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