WebService学习:SOPA与WSDL基本语法

来源:互联网 发布:电子施工图软件 编辑:程序博客网 时间:2024/05/09 12:54

转载自:http://blog.csdn.net/lissdy/article/details/8219659


在WebService学习中,发现SOPA和WSDL的语法比较繁琐,故将以下几点记下,以备查看。

 

SOPA基本语法:

SOAP消息基于XML文档构建,一条SOAP消息就是一份特定的XML文档,SOAP消息包含如下3个主要元素:

1、  必需的<Envelope  />根元素,SOAP消息对应的XML文档以该元素作为根元素;

2、  可选的<Header/>元素,包含SOAP消息的头信息;

3、  必需的<Body/>元素,包含所有的调用和相应信息(实际需要传送的信息)。

 

WSDL基本语法:

portType元素

<portType />元素用于描述一个webservice所有可以被调用的操作,以及该操作相关的消息。每个<portType />元素可以包含多个<operation />子元素,每个<operation />子元素定义一个允许被远程调用的操作。

例:

[html] view plaincopy
  1. <wsdl:portType name="XXXPortType">  
  2. <wsdl:operation  name="geta">  
  3. <wsdl:input name="getaRequest" message="tns:getaRequest"/>  
  4. <wsdl:output name="getaResponse" message="tns:getaResponse"/>  
  5. </wsdl:operation>  
  6. <wsdl:operation name="getb">  
  7. <wsdl:input name="getbRequest" message="tns:getbRequest"/>  
  8. <wsdl:output name="getbResponse" message="tns:getbResponse"/>  
  9. </wsdl:operation>  
  10. </wsdl:portType>  

binding元素

<binding />元素用于定义webservice与某个具体网络传输协议或消息传输协议之间的绑定。<binding />元素有如下两个常用属性:

name属性:指定<binding />元素的名称

type属性:指定为哪个<portType />元素定义的web service进行绑定。该属性值必须等于前面定义的<portType />元素的name属性值。

 

Service元素

<service />元素用于为web services提供的访问入口指定详细的部署细节。每个<service />元素可以包含多个<port />子元素,

每个<port />子元素定义一个服务访问入口。

<service /> 元素内部的<port />子元素需要指定如下属性:

Name属性:指定<port />子元素的名称

Type属性:指定为哪个<binding />元素绑定服务访问入口。

<soap:address />服务访问入口的网络地址。


原创粉丝点击