[WebService Test]: 3. SOAP
1. 什么是SOAP ? SOAP :(simple object access protocol,简单对象访问协议),它是简单,轻量级的信息交换协议。 作用是:数据交换。 语言:基于XML的WSDL语言。它可以描述方法名,参数类型,返回值,调用WebService地址,接口,协议和复杂数据结构(如,数组,结构体,集合等)。通过这些,使用者可以判断出这个web服务都有哪些函数接口,每个函数的参数是什么,返回值是什么等。有了这些,才能够构造SOAP报文来调用该Web服务的某个函数接口。 优点:SOAP不需HTTP的GET和POST,它不受“名称/值”对的限制,我们可以使用它来发送复杂的对象,包括DataSet(缓存中的数据库)、类和其他对象。 缺点: 由于SOAP消息十分冗长,因此如果存在带宽或者传输性能的问题,会导致接收和发送的消息遗失,在此情况下,建议使用POST或GET。 结构:?消息内容和一个或多个头模块组成,封装在SOAP envelope中。 下面是一个SOAP报文的例子: <?xml version="1.0" encoding="utf-8"?>
-
<
wsdl:definitions name
="
HPFlights_Service
"
targetNamespace
="
HP.SOAQ.SampleApp
"
xmlns:wsdl
="
http://schemas.xmlsoap.org/wsdl/
"
xmlns:soap
="
http://schemas.xmlsoap.org/wsdl/soap/
"
xmlns:wsu
="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
"
xmlns:soapenc
="
http://schemas.xmlsoap.org/soap/encoding/
"
xmlns:wsam
="
http://www.w3.org/2007/05/addressing/metadata
"
xmlns:tns
="
HP.SOAQ.SampleApp
"
xmlns:wsa
="
http://schemas.xmlsoap.org/ws/2004/08/addressing
"
xmlns:wsp
="
http://schemas.xmlsoap.org/ws/2004/09/policy
"
xmlns:wsap
="
http://schemas.xmlsoap.org/ws/2004/08/addressing/policy
"
xmlns:xsd
="
http://www.w3.org/2001/XMLSchema
"
xmlns:msc
="
http://schemas.microsoft.com/ws/2005/12/wsdl/contract
"
xmlns:wsaw
="
http://www.w3.org/2006/05/addressing/wsdl
"
xmlns:soap12
="
http://schemas.xmlsoap.org/wsdl/soap12/
"
xmlns:wsa10
="
http://www.w3.org/2005/08/addressing
"
xmlns:wsx
="
http://schemas.xmlsoap.org/ws/2004/09/mex
">
-
<
wsdl:types
>
-
<
xsd:schema targetNamespace
="
HP.SOAQ.SampleApp/Imports
">
?
<
xsd:import
schemaLocation
="
http://yaweijun1:24240/HPFlights_SOAP?xsd=xsd0
"
namespace
="
HP.SOAQ.SampleApp
" />
?
<
xsd:import
schemaLocation
="
http://yaweijun1:24240/HPFlights_SOAP?xsd=xsd1
"
namespace
="
http://schemas.microsoft.com/2003/10/Serialization/
" />
?
</
xsd:schema
>
?
</
wsdl:types
>
-
<
wsdl:message name
="
IHPFlights_Service_CreateFlightOrder_InputMessage
">
?
<
wsdl:part
name
="
parameters
"
element
="
tns:CreateFlightOrder
" />
?
</
wsdl:message
>
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |