珍惜现在的每一分钟,全力以赴自己的梦想。 Jump for the sun, at least you land on the moon.

[StepbyStep]: Notes for SOAP 2 - SOAP元素:Header

上一篇 / 下一篇  2008-12-24 13:57:24 / 个人分类:测试技术

SOAP Header 元素

O3yzoCq0

可选的 SOAP Header 元素可包含有关 SOAP 消息的应用程序专用信息(比如认证、支付等)。如果 Header 元素被提供,则它必须是 Envelope 元素的第一个子元素51Testing软件测试网qYZ&Vg^&|

 51Testing软件测试网o8i#ob e8vMe

注释:所有 Header 元素的直接子元素必须是合格的命名空间。51Testing软件测试网-]CISC)[

 51Testing软件测试网TEHr5CmR I M

<?xml version="1.0"?>51Testing软件测试网/Zs&L ]Z*R4V$U$^

<soap:Envelope

&@F)EJ+WFZ!e0

xmlns:soap="http://www.w3.org/2001/12/soap-envelope"51Testing软件测试网_2A M4z#GT(x6v

soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">51Testing软件测试网$F;I#P(mrA6Hi

 

D4Fd9WP\(a0

<soap:Header>51Testing软件测试网 W+P } ]9E+R

<m:Trans51Testing软件测试网J?)C/Y.VM6k i1p

xmlns:m="http://www.w3school.com.cn/transaction/"

wlv4k7Nxb0

soap:mustUnderstand="1">234</m:Trans>

/`QM}i;m)q9x;K C0

</soap:Header>51Testing软件测试网^nH/aY6g8D

 

._-_k3w.V0

...51Testing软件测试网/Hl d&Y*Yx$\!m

...

6_ H*G{1Pm5U0

 

T$_ s5g0Bb*x0

</soap:Envelope>上面的例子包含了一个带有一个 "Trans" 元素的头部,它的值是 234,此元素的 "mustUnderstand" 属性的值是 "1"51Testing软件测试网?FO7j~8L,K

 

G(_ oLB L\ f0

SOAP 在默认的命名空间中 ("http://www.w3.org/2001/12/soap-envelope") 定义了三个属性。这三个属性是:actor mustUnderstand 以及 encodingStyle。这些被定义在 SOAP 头部的属性可定义容器如何对 SOAP 消息进行处理。51Testing软件测试网E^Q)W7u+v^N

 51Testing软件测试网*Myo `u:I[R%A

actor 属性51Testing软件测试网Nc2M2`c$e)e-DL

 

;S QV8prG*n5m6gQmS0

通过沿着消息路径经过不同的端点,SOAP 消息可从某个发送者传播到某个接收者。并非 SOAP 消息的所有部分均打算传送到 SOAP 消息的最终端点,不过,另一个方面,也许打算传送给消息路径上的一个或多个端点。

q5yK7q}w0

 51Testing软件测试网0c'E*B [{Ni:bx_

SOAP actor 属性可被用于将 Header 元素寻址到一个特定的端点。51Testing软件测试网"^ dQz s$h-_N:H

 51Testing软件测试网f4L"Amhs G

语法

q+h6[K dzq1y2c&s0

 

!EUW hi[y9F0

soap:actor="URI" 51Testing软件测试网V8k$]/F3]XY_

 51Testing软件测试网b M {P:S2Jhp

实例

YLi9K)Z(Y*r0

 51Testing软件测试网N f N6\ l T&xHj

<?xml version="1.0"?>51Testing软件测试网 ^i'g P,G*I;f_~

<soap:Envelope51Testing软件测试网F3H dxnB

xmlns:soap="http://www.w3.org/2001/12/soap-envelope"51Testing软件测试网7T4DK6g*bB }{G/h

soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

"XG6]7?U@0

 51Testing软件测试网xq9lY\9S|9N

<soap:Header>51Testing软件测试网3D&eNd1R%k0j`j

<m:Trans

3Wi7HO ^Y[0

xmlns:m="http://www.w3school.com.cn/transaction/"51Testing软件测试网:v(} {G2{6^s;|

soap:actor="http://www.w3school.com.cn/appml/">51Testing软件测试网_VA5D ^9O

23451Testing软件测试网'b-|dr C5Wv7w|

</m:Trans>

GEM2|gW)z"H0

</soap:Header>51Testing软件测试网7eg/z]^V*qjJ

 51Testing软件测试网'[^/DO1xw3r3J

...

3pf2Bv'FSU0

...51Testing软件测试网!`CtJBrF

 

J;dN0]0Vg0

</soap:Envelope>

7V9E q$SK%Tm(`/[0

 

?I:~$D%_9{%a,E0

mustUnderstand 属性51Testing软件测试网wX1D jg

 

S2pu9A&A4o(_0

SOAP mustUnderstand 属性可用于标识标题项对于要对其进行处理的接收者来说是强制的还是可选的。

0[L&k"\tK7xaY0

 

'v;K2lw"z [5F)a}_9Y0

假如您向 Header 元素的某个子元素添加了 "mustUnderstand="1",则它可指示处理此头部的接收者必须认可此元素。假如此接收者无法认可此元素,则在处理此头部时必须失效。

k Z~ GMW0

 

1o}mz:v._SR0

语法51Testing软件测试网T K:]'i#?te5U6oS;^

 

,C'FqH.Z3|)b/S&w0

soap:mustUnderstand="0|1"51Testing软件测试网 CX'Ey6c;zB^[O

 

l2B7\7i#ckF$j@0

实例

dhcL1Qgf/s0

 

A7uig9wz&T1ff0

<?xml version="1.0"?>51Testing软件测试网j J`t8w

<soap:Envelope51Testing软件测试网cx k)b6C x

xmlns:soap="http://www.w3.org/2001/12/soap-envelope"

!|6X i I3E%?J8Dc C0

soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">51Testing软件测试网pu(yYM&F

 51Testing软件测试网!VDHS2Po1WP

<soap:Header>

k9KK9` I)]0a0

<m:Trans51Testing软件测试网:b.Qq:hlM A Dt

xmlns:m="http://www.w3school.com.cn/transaction/"

q(U7v$dO%U4L0

soap:mustUnderstand="1">

y"G??1D7q;gq0

234

GH j;aL Wx/I bj0

</m:Trans>

"TOZ;Hu]|rC!F0

</soap:Header>

&I3m lWK7^D0

 

;}+J2^ i:M(@T2J0

...

s#m&yV,B0

...51Testing软件测试网;}.wJ'QI5pa-F

 51Testing软件测试网pv R$GD k

</soap:Envelope>51Testing软件测试网5wU|A2ON"U P's)e[


TAG: 测试技术

 

评分:0

我来说两句

Open Toolbar