webservice学习笔记

什么是webservice

webservice 也可以叫 xml web service webservice,轻量级的独立的通讯技术。

特点:

1.基于web的服务:服务端提供的服务接口让客户端访问。

2.跨平台、跨语言的整合方案。

webservice中的概念

wsdl(web service definition language  webservice 定义语言)

webservice服务需要通过wsdl文件来说明自己有什么服务可以对外tiao调用。并且有那些方法、方法里面有那些参数

wsdl基于xml(可扩展标记语言)去定义的

1.对应一个.wsdl的文件类型

2.定义了webswebservice的服务器端和客户端应用进行交互的传递数据和响应数据格式和方式

3.一个webservice对应唯一一个wsdl文档

SOAP(simple object access protocal 简单对象访问协议)

webservice通过http协议发送和接收请求时,发送的请求报文和接收的相应报文都是采用xml格式进行封装。

这些特定的httpxian相应头和xml内容格式就是soap协议

1.一种简单、基于http和xml的协议

2.soap消息:请求和相应消息

3.http+xml报文

SEI(webservice endpoint interface webservice的终端接口)

webservice服务端用来处理请求的接口,也就是发布出去的接口。

 

分析WSDL文档

 

  • Types - 数据类型定义的容器,它使用某种类型系统(一般地使用XML Schema中的类型系统)。

schema标签

  • Message - 通信消息的数据结构的抽象类型化定义。使用Types所定义的类型来定义整个消息的数据结构。
  • PortType - 对于某个访问入口点类型所支持的操作的抽象集合,这些操作可以由一个或多个服务访问点来支持。
  • Binding - 特定端口类型的具体协议和数据格式规范的绑定。
  1. type属性: 引用porttype

<soap:binding style=”document”>

  1. operation : 指定实现方法
  2. input/output 表示输入和输出的数据类型
  • Service - 相关服务访问点的集合。

service: 服务器端的一个webservice的容器

name属性: 指定客户端的容器类

address: 当前webservice的请求地址

整体:http://localhost:8888/wz/user?wsdl

<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.wz.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service.wz.com/" name="UserServiceImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://service.wz.com/" schemaLocation="http://localhost:8888/wz/user?xsd=1"/>
</xsd:schema>
</types>
<message name="getUsers">
<part name="parameters" element="tns:getUsers"/>
</message>
<message name="getUsersResponse">
<part name="parameters" element="tns:getUsersResponse"/>
</message>
<portType name="UserServiceImpl">
<operation name="getUsers">
<input wsam:Action="http://service.wz.com/UserServiceImpl/getUsersRequest" message="tns:getUsers"/>
<output wsam:Action="http://service.wz.com/UserServiceImpl/getUsersResponse" message="tns:getUsersResponse"/>
</operation>
</portType>
<binding name="UserServiceImplPortBinding" type="tns:UserServiceImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="getUsers">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="UserServiceImplService">
<port name="UserServiceImplPort" binding="tns:UserServiceImplPortBinding">
<soap:address location="http://localhost:8888/wz/user"/>
</port>
</service>
</definitions>

http://localhost:8888/wz/user?xsd=1

<xs:schema xmlns:tns="http://service.wz.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://service.wz.com/">
<xs:element name="getUsers" type="tns:getUsers"/>
<xs:element name="getUsersResponse" type="tns:getUsersResponse"/>
<xs:complexType name="getUsers">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="getUsersResponse">
<xs:sequence>
<xs:element name="return" type="tns:user" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="user">
<xs:sequence>
<xs:element name="age" type="xs:int"/>
<xs:element name="id" type="xs:long"/>
<xs:element name="name" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值