利用RAD开发JAX-RPC标准的Webservice

基于 XML 的远程过程调用的 JAVA API =JAVA API(Java APIs for XML-based Remote Procedure Call(JAX-RPC))是一个标准(standard specification),它是基于SOAP与WSDL的。它提供了简化的开发模型来开发Webservice。

JAX-RPC has been developed as a standard specification under the Java Community process as the JSR-101. The JAX-RPC specification is a result of collaboration of multiple vendors under the JCP expert group. Multiple vendors provide compatible implementations of the JAX-RPC standard. JAX-RPC enables portability of Web services across these multiple compatibility implementations. This gives you a huge benefit as a developer.

JAX-RPC is for Web services interoperability across heterogeneous platforms and languages. This makes JAX-RPC a key technology for Web services integration.

You can use the standard JAX-RPC programming model to develop Web service clients and endpoints based on SOAP 1.1. A Web service endpoint is described using a Web Services Description Language (WSDL) document. JAX-RPC enables JAX-RPC clients to invoke Web services developed across heterogeneous platforms. In a similar manner, JAX-RPC Web service endpoints can be invoked by heterogeneous clients. JAX-RPC requires SOAP and WSDL standards for this cross-platform interoperability.

JAX-RPC provides an easy to develop programming model for development of SOAP based Web services. You can use the RPC programming model to develop Web service clients and endpoints. For typical scenarios, you are not exposed to the complexity of the underlying runtime mechanisms (for example, SOAP protocol level mechanisms, marshalling and unmarshalling). A JAX-RPC runtime system (a library) abstracts these runtime mechanisms for the Web services programming model. This simplifies Web service development.

JAX-RPC provides support for WSDL-to-Java(自顶向下) and Java-to-WSDL(自下到上) mapping as part of the development of Web service clients and endpoints. In a typical development environment, tools provide these mapping functionality. This further simplifies the application development.

JAX-RPC enables a Web service endpoint to be developed using either a Java Servlet or Enterprise JavaBeans (EJB) component model. A Web service endpoint is deployed on either the Web container or EJB container based on the corresponding component model. These endpoints are described using a WSDL document. This WSDL document can be published in public or private registry, though this is not required. A client uses this WSDL document and invokes the Web service endpoint. A JAX-RPC client can use stubs-based, dynamic proxy or dynamic invocation interface (DII) programming models to invoke a heterogeneous Web service endpoint.

Web 服务已经出现很久了。首先是 SOAP,但 SOAP 仅描述消息的情况,然后是 WSDL,WSDL 并不会告诉您如何使用 Java™ 编写 Web 服务。在这种情况下,JAX-RPC 1.0 应运而生。经过数月使用之后,编写此规范的 Java Community Process (JCP) 人员认识到需要对其进行一些调整,调整的结果就是 JAX-RPC 1.1 。该规范使用大约一年之后,JCP 人员希望构建一个更好的版本:JAX-RPC 2.0。其主要目标是与行业方向保持一致,但行业中不仅只使用 RPC Web 服务,还使用面向消息的 Web 服务。因此从名称中去掉了“RPC”,取而代之的是“WS”(当然表示的是 Web 服务)。因此 JAX-RPC 1.1 的后续版本是 JAX-WS 2.0——Java API for XML-based Web services。

利用RAD开发Webservice

1. 首先系统要安装好WAS61(或者WAS70)和RAD75。

2. 编辑实现类。

Public class SoapResultParser{
 
publicQueryResults poll(Poll parms) throws …Exeption{ 
 
 //业务处理逻辑
 
}
 
}

3. 编辑请求与响应的Javabean

请求Bean :Poll (必须符合JAX-RPC标准的类型)

publicclass Poll {
 
private String type;
 
private String testmachine;
 
private String path;
 
// Getter 和 Setter 方法
 
}

响应Bean:QueryResults (必须符合JAX-RPC标准的类型)

import javax.xml.soap.SOAPElement;
 
public class QueryResults {
 
private String logType;
 
private String testMachine;
 
private SOAPElement resultsBody;
 
private SOAPElement extension;
 
private SOAPElement[] _any;
 
//geter 和 setter方法
 
}

4.Right Click SoapResultParser 类,webservice,选择“Generate Webservice”

5.根据下图选择参数。

请忽略JAX-RPC类型不匹配的警告。

6. Next then finish

一个以实现类名+SEI的java文件生成了。

public interface SoapResultParser_SEI extends java.rmi.Remote
 
{
 
public com.ibm.cdl.skel.QueryResults poll(com.ibm.cdl.skel.Poll parms) throws …Exeption;
 
}

现在就可以利用SOAPUI等Webservice Client工具来测试新开发的WS了,WSDL文件可以在WEB-INF中找到。

Leave a Comment.