尽管可以使用许多技术来实现面向服务体系结构(soa),不过最常用的还是使用 web 服务,这意味着要使用 xml。soap 和 rest 是实现 web 服务最流行的两种方法,这两者都基于 xml。
一个例子
比如说,通过将这个 soap 文档作为 web 请求发送,可以向 google web 服务提
尽管可以使用许多技术来实现面向服务体系结构(soa),不过最常用的还是使用 web 服务,这意味着要使用 xml。soap 和 rest 是实现 web 服务最流行的两种方法,这两者都基于 xml。
一个例子
比如说,通过将这个 soap 文档作为 web 请求发送,可以向 google web 服务提出请求。(如清单 2 所示)
清单 2. 通过发送 soap 文档向 google web 服务提出请求
<?xml version='1.0' encoding='utf-8'?>
<soap-env:envelope xmlns:soap-env=
"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/xmlschema-instance"
xmlns:xsd="http://www.w3.org/1999/xmlschema">
<soap-env:body>
<ns1:dogooglesearch xmlns:ns1="urn:googlesearch"
soap-env:encodingstyle=
"http://schemas.xmlsoap.org/soap/encoding/">
<key xsi:type="xsd:string">00000000000000000000000000000000</key>
<q xsi:type="xsd:string">death star trash compactor</q>
<start xsi:type="xsd:int">0</start>
<maxresults xsi:type="xsd:int">10</maxresults>
<filter xsi:type="xsd:boolean">true</filter>
<restrict xsi:type="xsd:string"></restrict>
<safesearch xsi:type="xsd:boolean">false</safesearch>
<lr xsi:type="xsd:string"></lr>
<ie xsi:type="xsd:string">latin1</ie>
<oe xsi:type="xsd:string">latin1</oe>
</ns1:dogooglesearch>
</soap-env:body>
</soap-env:envelope>
此处我们可以看到 soap 信封(envelope),它是 web 服务引擎能够理解的标准格式。这个消息的内容(在本例中为 dogooglesearch 元素)被认作是 有效载荷(payload),由即将被 web 服务处理的信息所组成。
以上就是具体介绍xml与web服务和soa有何关联?的详细内容。