J2EE构造web service
在这篇文章,我向java程序开发者介绍service-oriented architecture (SOA),我将解释怎么使用J2EE 1.4去建立一个web 服务使其能操作和方便的通过J2EE1.4来适应应用服务(例如: Oracle Application Server)。 Web Services Architecture
让我们在学习web services部署J2EE platform之前,我们先了解web service 的主要结构。
通过网络我们可以找到一些关于 web services的定义、发布、和调用。一个web service,如图一

图一
现在有两种web services:“RPC style and document style”,RPC-style web services是在最初受欢迎的。但在近几年是document-style是首选的web services。
RPC-style web services是远程程序调用,代表相互交互。RPC-style web services在交互信息中调用和返回必须先符合明确的签名,在应用中非常不方便。相反,document-style web services 通过用xml,来改变发送和接收应用。
许多的开发者觉得web services是一个有活力的技术,他继承SOA。因为它提供一个相互作用在不同的平台和轻便的技术。例如xml,soap,and http。
What Are Web Services Made of?
在web service首先要先定义A Web Services Definition Language (WSDL; pronounced "wizdle") 文档。
这个WSDL提供一个完全的描述web service,包括端口、操作、信息类型等。
Here is a simple example of a WSDL document that describes a HelloWorld web service:
<definitions
name="HelloService"
targetNamespace="http://oracle.j2ee.ws/ejb/Hello"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://oracle.j2ee.ws/ejb/Hello"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:ns1="http://oracle.j2ee.ws/ejb/Hello/types"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<schema elementFormDefault="qualified"
targetNamespace="http://oracle.j2ee.ws/ejb/Hello/types"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://oracle.j2ee.ws/ejb/Hello/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<complexType name="sayHello">
<message name="HelloServiceInf_sayHello">
<part name="parameters"
element="ns1:sayHelloElement"/>
</message>
<message name="HelloServiceInf_sayHelloResponse">
<part name="parameters"
element="ns1:sayHelloResponseElement"/>
</message>
<portType name="HelloServiceInf">
<operation name="sayHello">
<input message="tns:HelloServiceInf_sayHello"/>
<output message="tns:HelloServiceInf_sayHelloResponse"/>
</operation>
</portType>
<sequence>
<element name="String_1" nillable="true" type="string"/>
</sequence>
</complexType>
<complexType name="sayHelloResponse">
<sequence>
<element name="result" nillable="true" type="string"/>
</sequence>
</complexType>
<element name="sayHelloElement" type="tns:sayHello"/>
<element name="sayHelloResponseElement"
type="tns:sayHelloResponse"/>
</schema>
</types>
<binding name="HttpSoap11Binding" type="tns:HelloServiceInf">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sayHello">
<soap:operation
soapAction="http://oracle.j2ee.ws/ejb/Hello:sayHello"/>
<input>
<soap:body use="literal" parts="parameters"/>
</input>
<output>
<soap:body use="literal" parts="parameters"/>
</output>
</operation>
</binding>
<service name="HelloService">
<port name="HttpSoap11" binding="tns:HttpSoap11Binding">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
</port>
</service>
</definitions>
在这个WSDL,你需要注意HelloService ,包括他的包括端口、操作、信息类型等。这个WSDL 使web service 和客户端,能够自动的产生客户端代理。
在这个web services有两个主要的技术,一个是SOAP,它是调用web service,一个是UDDI它提供web service的本地注册。
未完待续
- · J2EE架构的6个最佳实践
- · J2EE的13种核心技术(一)
- · 使用EJB3.O简化EJB开发(二)
- · 一个经典的JAVA APPLET程序(二)
- · J2EE编程起步(一)
- · j2ee-j2me tips
- · Java中的类反射机制
- · 使用sitemesh建立复合视图 - 2.装饰器 decorator
- · J2EE1.4中的Servlet部署
- · J2EE项目危机【翻译】 -避免这10项J2EE危机来确保你的企业JAVA项目成功
- · J2EE应用中与Oracle数据库的连接
- · J2ME Polish学习心得(一)----Device Optimization
- · J2EE框架标准OpenSource大战拉开序幕!
- · J2EE学习过程
- · J2EE的13种核心技术(二)
- · J2EE项目中开发团队的组建
- · J2EE开发过程中的异常处理
- · 谈谈J2SE中的序列化(三)
- · J2EE初学者需要理解的问题
- · J2EE deployment files(web.xml)
- · J2EE deployment files (ejb-jar.xml)
- · j2sdk 与 Tomcat5配置方法与注意事项
- · J2ME学习笔记(七)
- · 开发J2EE应用应遵循的几点原则
- · [J2EE]项目艰辛笔记
- · J2EE程序中使用oracle数据库LOB字段的总结(elathen)
- · J2EE编程起步(一)
- · 走向J2EE,漫长的道路
- · [J2SE 5.0专题][3]虚拟机
- · J2EE clustering 1---有些老了
- · [J2SE 5.0专题][2.7]注解
- · [J2SE 5.0专题][2.1]泛型
- · J2EE 探险者:持久数据管理,第 2 部分
- · J2EE 探索者:使用 Java Servlets 2.4 来执行过滤
- · J2EE 探险者:持久数据管理,第 2 部分
- · 用J2EE开发N层应用
- · Oracle9iAS Containers for J2EE独立版指南--(部署servlet和JSP的方法)
- · Oracle9iAS Containers for J2EE独立版指南--(简介、安装、启动、关闭和帮助)
- · J2EE项目10大风险
- · J2EE全面介绍(一)
- · J2EE设计模式:CMP到BMP模式(一)
- · Spring Framework标记库初学指南
- · j2ee程序员应该掌握的linux知识
- · J2ME打包--解决移动平台api 问题
- · J2EE平台介绍

