解读webservice
WebService基于Web的服务 理解什么是服务:l? 现在的应用程序变得越来越复杂,甚至只靠单一的应用程序无法完成全部的工作。更别说只使用一种语言了。 l? 大家在写应用程序查询数据库时,并没有考虑过为什么可以将查询结果返回给上层的应用程序,甚至认为,这就是数据库应该做的,其实不然,这是数据库通过TCP/IP协议与另一个应用程序进行交流的结果,而上层是什么样的应用程序,是用什么语言,数据库本身并不知道,它只知道接收到了一份协议,这就是SQL92查询标准协议。 l? 目前的云计算、云查杀都是一种服务,现在比较流行的说法是SOA(面向服务的框架)。 l? 既然数据库可以依据某些标准对外部其他应用程序提供服务、而且不关心对方使用什么语言,那我们为什么就不能实现跨平台、跨语言的服务呢? l? 只要我们用Java写的代码,可以被任意的语言所调用,我们就实现了跨平台,跨语言的服务! 什么是WebService? 简说:如果说Java是跨平台的语言,那么WebService就是跨语言的技术。 WebService可以让多个进程之间实现数据交换,即进程间通讯。 无论某个进程运行要互联网的任何地点,无论进程是有什么语言写成的,都可以互相访问并传输数据。最后,WebService是基于HTTP和XML的技术。WebService的商业应用: 网上支付-支付宝。 银联-提供统一的WebService,实现银行之间的转账付款。 在种不同的终端设备上如手机、iPad实时查询天气预报、股票行情。
简单的网络应用: ?
??? ? ? ? 现在我们来看jdk中对于webservice的支持,并且有其工具函数的存在。 去是使用: 一:讲解的是手动怎么从外网上的wsdl上,用jdk中的工具来获取webservice代码呢? ? D:a>wsimport-s . http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx ?wsdl ? 参数帮助: C:UsersYUHUADONGDesktop>wsimport Missing WSDL_URI Usage: wsimport [options]<WSDL_URI> where [options] include: ?-b <path>????????????????specify jaxws/jaxb binding files or additional schem as ??????????????????????????? (Each <path>must have its own -b) ?-B<jaxbOption>???????????Pass this option to JAXB schema compiler ?-catalog <file>??????????specify catalog file to resolve external entity refe rences ??????????????????????????? supports TR9401,XCatalog,and OASIS XML Catalog for mat. ?-d <directory>???????????specify where to place generated output files ?-extension??????????????? allowvendor extensions - functionality not specifie d ??????????????????????????? by the specification.? Use of extensions may ??????????????????????????? result inapplications that are not portable or ??????????????????????????? may notinteroperate with other implementations ?-help???????????????????? displayhelp ?-httpproxy:<host>:<port>?specify a HTTP proxy server (port defaults to 8080) ?-keep???????????????????? keepgenerated files ?-p <pkg>?????????????????specifies the target package ?-quiet??????????????????? suppresswsimport output ?-s <directory>???????????specify where to place generated source files ?-target <version>????????generate code as per the given JAXWS spec version ??????????????????????????? e.g. 2.0 willgenerate compliant code for JAXWS 2.0 spec ?-verbose????????????????? outputmessages about what the compiler is doing ?-version????????????????? printversion information ?-wsdllocation <location>?@WebServiceClient.wsdlLocation value Extensions: ?-XadditionalHeaders???????? mapheaders not bound to request or response messa ge to ????????????????????????????? Java methodparameters ?-Xauthfile????????????????? fileto carry authorization information in the for mat ?????????????????????????????http://username:password@example.org/stock?wsdl ?-Xdebug???????????????????? printdebug information ?-Xno-addressing-databinding enable binding of W3C EndpointReferenceTypeto Jav a ?-Xnocompile???????????????? do notcompile generated Java files Examples: ?wsimport stock.wsdl -b stock.xml -b stock.xjb ?wsimport -d generated http://example.org/stock?wsdl C:UsersYUHUADONGDesktop> ----------------------------------------------------------------------------------------------------------------------------------------------- saop协议: soap=xml+post+http,tld 名词1:XML. Extensible Markup Language -扩展性标记语言 XML,用于传输格式化的数据,是Web服务的基础。 namespace-命名空间。 xmlns=“http://yhd.cn” 使用默认命名空间。 xmlns:yhd=“http://yhd.cn”使用指定名称的命名空间。 名词2:WSDL – WebService Description Language – Web服务描述语言。 通过XML形式说明服务在什么地方-地址。 通过XML形式说明服务提供什么样的方法 – 如何调用。 名词3:SOAP-Simple Object Access Protocol(简单对象访问协议) SOAP作为一个基于XML语言的协议用于有网上传输数据。 SOAP = 在HTTP的基础上+XML[Y1]?数据。 - H TTP[Y2]? SOAP是基于HTTP的。 SOAP的组成如下: Envelope – 必须的部分。以XML的根元素出现。 Headers – 可选的。 Body – 必须的。在body部分,包含要执行的服务器的方法。和发送到服务器的数据。 ? 由于xml规范。 ?[Y1]数据 ?[Y2]高速公路,介质(载体) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |