Webservice 1

WebService学习,开发总结

一, 基本概念:

1, 什么是 Web 服务?

Web 是使应用程序可以以与平台和编程语言无关的方式进行相互通信的一项技术。Web服务是一个软件接口,它描述了一组可以在网络上通过标准化的XML 消息传递访问的操作。它使用基于 XML 语言的协议来描述要执行的操作或者要与另一个 Web 服务交换的数据。一组以这种方式交互的 Web 服务在面向服务的体系结构(Service-OrientedArchitecture,SOA)中定义了特殊的 Web 服务应用程序。

2, 什么是SOAP?

SOAP(SimpleObject Access Protocol )简单对象访问协议是在分散或分布式的环境中交换信息并执行远程过程调用的轻量级协议,是一个基于XML的协议。使用SOAP,不用考虑任何特定的传输协议(最常用的还是HTTP协议),可以允许任何类型的对象或代码,在任何平台上,以任何一种语言相互通信。

SOAP包括四个部分:SOAP封装(envelop),封装定义了一个描述消息中的内容是什么,是谁发送的,谁应当接受并处理它以及如何处理它们的框架;SOAP编码规则(encoding rules),用于表示应用程序需要使用的数据类型的实例;SOAP RPC表示(RPC representation),表示远程过程调用和应答的协定;SOAP绑定(binding),使用底层协议交换信息。

应用中比较关注的是envelop,由一个或多个Header和一个Body组成。

SOAP在可互操作的基础 Web 服务协议栈中的位置:

3, 什么是Axis?

Axis本质上就是一个SOAP引擎(Apache Axis is animplementation of the SOAP),提供创建服务器端、客户端和网关SOAP操作的基本框架。但Axis并不完全是一个SOAP引擎,它还包括:

是一个独立的SOAP服务器。

是一个嵌入Servlet引擎(例如Tomcat)的服务器。

支持WSDL。

提供转化WSDL为Java类的工具。

提供例子程序。

提供TCP/IP数据包监视工具。

4, Axis相比Soap v2的优点:

Axis是第三代ApacheSOAP的实现,从2000年起,SOAP v2开发小组开始讨论如何让Axis更加灵活、可配置,以及能够处理SOAP和来自W3C的各种XML标准。通过不断地讨论和代码编写,Axis目前相比SOAP V2取得了如下成果:

速度提高。 Axis通过基于事件的SAX对XML文档进行处理,从而在速度和效率上比ApacheSOAP有所提高。

灵活性提高。

稳定性提高。

提供面向组件的部署。

提供一个简洁的传输抽象框架。其核心引擎完全于传输方式独立。从而使基于何种协议传输的选择更加灵活。

支持WSDL。包括WSDL和客户端代码生成等。

5, 什么是WSDL?

WSDL(Web ServiceDescription Language)Web服务器描述语言是用XML文档来描述Web服务的标准,是Web服务的接口定义语言,由Ariba、Intel、IBM、MS等共同提出,通过WSDL,可描述Web服务的三个基本属性:

·服务做些什么——服务所提供的操作(方法)

·如何访问服务——和服务交互的数据格式以及必要协议

·服务位于何处——协议相关的地址,如URL

WSDL文档以端口集合的形式来描述Web服务,WSDL 服务描述包含对一组操作和消息的一个抽象定义,绑定到这些操作和消息的一个具体协议,和这个绑定的一个网络端点规范。

WSDL在Web 服务概念性协议栈中的位置:

6, 什么是WSDD?

WSDD就是WEB服务分布描述(Web Service DeploymentDescriptor), 它定义了WEB服务的接口,如服务名、提供的方法、方法的参数等信息。

7, 什么是UDDI?

UDDI就是统一描述、发现和集成(UniversalDescription, Discovery, and Integration)。UDDI用于集中存放和查找WSDL描述文件,起着目录服务器的作用。

Web 服务中的角色、操作和构件:

服务提供者。从企业的角度看,这是服务的所有者。从体系结构的角度看,这是托管访问服务的平台。

服务请求者。从企业的角度看,这是要求满足特定功能的企业。从体系结构的角度看,这是寻找并调用服务,或启动与服务的交互的应用程序。服务请求者角色可以由浏览器来担当,由人或无用户界面的程序(例如,另外一个Web 服务)来控制它。

服务注册中心。这是可搜索的服务描述注册中心,服务提供者在此发布他们的服务描述。在静态绑定开发或动态绑定执行期间,服务请求者查找服务并获得服务的绑定信息(在服务描述中)。对于静态绑定的服务请求者,服务注册中心是体系结构中的可选角色,因为服务提供者可以把描述直接发送给服务请求者。同样,服务请求者可以从服务注册中心以外的其它来源得到服务描述,例如本地文件、FTP站点、Web 站点、广告和服务发现(Advertisement and Discovery of Services,ADS)或发现 Web 服务(Discoveryof Web Services,DISCO)。

8, AXIS的几种服务类型:

AXIS有四种servicestyles,分别是:RPC, Document, Wrapped, 和Message。最常用的就是RPC和Message。

RPC:在AXIS中是一个默认选项。当你部署的时候使用下列两种方式: 或则 ,它遵循SOAP RPC和编码规则。每个RPC都包括一个表示名称的外部接点和一些表示参数的内部接点。AXIS会根据规则将一个XML(WSDL文件)文件转化成一个JAVA对象,并对对想赋上在文件中描述的值。也可以根据规则将一个JAVA对象转化成XML文件。

Document

适合于老的XMLschema。

Wrapped

和DOCUMENT一样,适合于老的XML schema。

在大多书情况下,你不许要担心是DOCUMENT服务还是WRAPPED服务。

Message

以这种方式部署的话,会使AXIS失去意义,它使你的代码真正的用XML形式,而不需要转化成JAVA对象。以这种方式部署的有以下四种服务方法:

public Element [] method(Element [] bodies);

public SOAPBodyElement [] method (SOAPBodyElement []bodies);

public Document method(Document body);

public void method(SOAPEnvelope req, SOAPEnvelope resp);

几种服务类型的主要区别:

基于RPC(远程过程调用)方式,这也是Web服务最常用的方式。面向消息/文档的的类型跟RPC不同的是它提供了一个更底层的抽象,要求更多的编程工作。客户端可以传入任何的XML文档,得到的响应不一定是SOAPEnvelope,可以返回任何它所需要的东西,甚至不返回。虽然这对开发者来说非常的灵活,但是这种通讯类型在实际的应用中并不常见。面向消息/文档的Web服务主要适合于下面几种情况,比如批量处理,基于表单的数据导入,有需要返回非XML数据时,Web服务器实现中要求直接访问传输层等等

二, 开发,部署Web服务:

首先下载并安装tomcat4.x.及以上版本

然后到Axis主页下载,现在最新版本是1.3 final,我们使用的是1.2.1final版,将解压的axis中的webapps目录下的axis拷贝到tomcat安装路径下的webapp下,将解压的axis下lib下的jar文件拷贝到tomcat安装目录下commonlib下,并把他们加入到你的系统路径中。

然后启动tomcat,

打开IE,输入:http://localhost:8080/axis,如果出现axis主页,说明安装axis成功。

部署web服务 在axis下部署web服务有以下两种方式:

1. 即时部署(InstanceDeployment)利用JWS文件

只需要将.java文件拷贝到axis目录下,并将文件后缀改为.jws即可。

访问部署后的wsdl文件只需键入: http://localhost:8080/axis/filename.jws?wsdl

以下是WSDL的一个例子:

<?xml version="1.0"encoding="UTF-8"?>

<wsdl:definitionstargetNamespace="http://service.kernel.gamebase.com" xmlns:apachesoap="http://xml.apache.org/xml-soap"xmlns:impl="http://service.kernel.gamebase.com"xmlns:intf="http://service.kernel.gamebase.com"xmlns:tns1="http://vo.service.kernel.gamebase.com"xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<wsdl:types> //描述消息中复杂数据类型的使用

<schematargetNamespace="http://vo.service.kernel.gamebase.com"xmlns="http://www.w3.org/2001/XMLSchema">

<importnamespace="http://service.kernel.gamebase.com"/>

<importnamespace="http://schemas.xmlsoap.org/soap/encoding/"/>

<complexType name="UserGameGrade">//定义复杂类型

<sequence>

<element name="MClassID"nillable="true" type="xsd:string"/>

<element name="gameID"nillable="true" type="xsd:string"/>

<element name="gradeType"type="xsd:int"/>

......

</sequence>

</complexType>

</schema>

......

</wsdl:types>

<wsdl:messagename="getGameGradeRankResponse"> //定义操作的输出参数

<wsdl:part name="getGameGradeRankReturn"type="tns1:GameGradeRank"/>

</wsdl:message>

<wsdl:messagename="getGameGradeRankRequest"> //定义操作的输入参数

<wsdl:part name="in0" type="xsd:string"/>

<wsdl:part name="in1"type="xsd:int"/>

<wsdl:part name="in2"type="xsd:int"/>

</wsdl:message>

......

<wsdl:portType name="GameGradeService"> //WSDL: portType 元素中定义了 Web 服务的操作。

<wsdl:operation name="getGameGradeRank"parameterOrder="in0 in1 in2"> //操作定义了输入和输出数据流中可以出现的XML 消息

<wsdl:inputmessage="impl:getGameGradeRankRequest"name="getGameGradeRankRequest"/>

<wsdl:outputmessage="impl:getGameGradeRankResponse"name="getGameGradeRankResponse"/>

</wsdl:operation>

<wsdl:operation name="getUserGameGradeRank"parameterOrder="in0 in1 in2 in3 in4">

<wsdl:inputmessage="impl:getUserGameGradeRankRequest"name="getUserGameGradeRankRequest"/>

<wsdl:outputmessage="impl:getUserGameGradeRankResponse"name="getUserGameGradeRankResponse"/>

</wsdl:operation>

......

</wsdl:portType>

<wsdl:bindingname="GameGradeServiceSoapBinding"type="impl:GameGradeService">//描述特定服务接口(WSDL:portType)的协议、数据格式、安全性和其它属性

<wsdlsoap:binding style="rpc"transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="getGameGradeRank">

<wsdlsoap:operation soapAction=""/>

<wsdl:input name="getGameGradeRankRequest">

<wsdlsoap:bodynamespace="http://service.kernel.gamebase.com"use="literal"/>

</wsdl:input>

<wsdl:outputname="getGameGradeRankResponse">

<wsdlsoap:bodynamespace="http://service.kernel.gamebase.com"use="literal"/>

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:servicename="GameGradeServiceService">//定义服务:名字,访问点,位置

<wsdl:portbinding="impl:GameGradeServiceSoapBinding"name="GameGradeService">

<wsdlsoap:addresslocation="http://localhost:8080/gamebase/services/GameGradeService"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>2.定制部署(CustomDeployment)利用部署描述符wsdd

以下是部署描述符的一个例子: <deploymentxmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="GameGradeService" type=""provider="java:RPC"

style="rpc" use="encoded"> //服务名字,服务类型及服务提供者

<parameter name="scope"value="Request"/>

<parameter name="className"value="com.gamebase.kernel.service.ServiceImpl"/> //实现该服务的具体类

<parameter name="allowedMethods"value="*"/>

<namespace>http://service.kernel.gamebase.com</namespace>

<typeMapping xmlns:ns1="http://vo.service.kernel.gamebase.com"//类型映射

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"

qname="ns1:GameGradeRank"//Qualified Name(特定名字)

languageSpecificType="java:com.gamebase.kernel.service.vo.GameGradeRank"

serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"//指定序列化工厂

deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"//反序列化工厂name="GameGradeRank"/>

………
</service>
</deployment>

访问部署后的wsdl文件只需键入

http://localhost:8080/axis/services/GameGradeService

三, 在IDE下开发Web服务:

1,在Jubilder下开发WebService:

使用Jbuilder集成开发环境,能够根据服务接口类生成web服务描述文件,web服务部署描述文件及客户端代码,这样能够节省我们大部分时间(开发,配置),且减少出错机率。

Jbuilder在以前的版本,如jbuilder8(可能更低版本)就支持Axis,我用的是Jbuilder2006,不过大体步骤都是相同。

在开始前,我们有个服务接口GameGradeService类,服务接口实现类ServiceImpl类及相关附属类。我们要实现该服务接口。

2.1,打开Jbuilder,新建一个工程,如testWebService

2.2,新建一个名为webService的WebService Server (file>new:WebServices:AxisWebServices Server Configuration)

2.3, 在出现的WebServices Designers可视化界面,点击“createService”,选择“java Service”

2.4,配置新创建的javaService,点击JavaService1,配置Service Name为GameGradeService,服务接口为我们有的那个服务接口GameGradeService,实现类为我们实现改接口的类ServiceImpl。

2.5,然后编译该工程,能够生成web服务部署文件,web服务描述文件,如果你选择了生成客户端代码的话,它也能生成相应的客户端代码。

2.6,启动该服务,访问:http://localhost:8080/webService/services/GameGradeService?wsdl,如果出现该服务的描述文档,说明发布成功。

2.7,执行自动生成的客户端代码进行测试,发现测试成功。

2.8,你可以用webService的webServices Client来根据wsdl只生成客户端代码。

a,新建一个名为webServiceClient的WebService Client(file>new:WebServices:AxisWebServices Client Configuration)

b,在出现的WebServices Designers可视化界面,点击“createService”,选择“import from url”

c,配置新创建的javaService,点击JavaService1,配置Service Name为GameGradeService,Input WSDL file 为给定的wsdl。

d,然后编译该工程

2,在eclipse下开发WebService:

Eclipse3.1及相关插件已经能够很好的支持webService开发。

右键点击wsdl文件,选择webServices,有以下功能:发布wsdl文件,生成客户端代码等。

右键点击服务接口文件,选择webServices,有以下功能:生成web Service等。

同时eclipse提供了友好的界面操作,如测试的时候,提供界面让你输入参数,而不必该改程序。

四, 开发过程中的问题:

在使用AXIS开发WEB服务的时候,会遇到很多问题。比如:XML解析器出现的异常、客户端程序找不到可用的Web服务、序列化/反序列化等。

XML解析器出现的异常主要是由于类型映射的问题导致的,用到那个Bean就把那个bean映射进去就可以避免该问题。

客户端程序找不到可用的Web服务主要是由于客户端对服务提供者的url及服务名字输入有错,这一般是由于手写客户端代码造成的。

序列化/反序列化问题,没有对传输中的某个Bean类型映射相应的序列化/反序列化工厂,或者是复杂类型中,没有实现自定义的序列化/反序列化工厂。

以上是开发过程中主要遇到的几类问题,在以后的开发过程中,一定还会需要遇到更多的问题。

五, 其他相关知识:

1,java类与wsdl相互生成工具:

Axis提供了”WSDL2Java”工具,可以利用wsdl描述来产生服务的Java代理和框架(proxyand skeletons)。

Axis提供了”Java2WSDL”工具,可以由java类生成wsdl文件。

2,序列化与反序列化:

序列化/反序列化器在英文中的对应翻译是Serializer/Deserializer,一个序列化器的功能是遵循一定的映射规则和编码风格,将一种类型的JAVA对象通过某种特定的机制,转换成为XML描述的形式;反序列化器的功能是序列化器所做工作的逆操作,两者相辅相成,成对出现。Axis中的序列化/反序列化器采用设计范式中的工厂模式,每一个Serializer唯一对应一个SerializerFactory;每一个Deserializer唯一对应一个DeserializerFactory。

Axis已经为开发者提供了丰富的序列化/反序列化器,对于java的基本数据类型,绝大部分常用的容器类(比如数组类型,Vector类型等)都提供了实现,特别是提供了对W3C的DOM对象(比如Document,Element等)和符合Bean规范的JAVA对象提供了功能完善的序列化/反序列化器,但对于一些特殊类型的对象,需要通过Web服务进行传递,我们不得不开发自己的序列化/反序列化器。

3,Axis与Spring的结合:

Axis与spring结合,需要提供一些额外工作,即将实现web服务接口的Bean与web服务部署中服务类如何关联。 如下:

<service name="GameService" type=""provider="Handler" style="rpc">

<parameter name="handlerClass"value="com.workingmouse.webservice.axis.SpringBeanRPCProvider"/>

<parameter name="springBean"value="gameInfoService"/>

<parameter name="springBeanClass"value="com.gamebase.kernel.service.GameService"/>

<parameter name="scope"value="Request"/>

<parameter name="allowedMethods"value="*"/>

.......

</service>

参数handlerClass的值是处理Bean与wsdd文件中服务类的关联。

参数springBean的值表示实现接口GameService注册的Bean的名字。

参数springBeanClass的值表示接口GameService的类。

 

 

 

============================================

 

10:39 | 添加评论 | 发送消息 | 固定链接 | 查看引用通告 (0) | 写入日志 | Computers and Internet

5月30日

java clientfor .Net webservice

 

http://pgsdev3.americas.hpqcorp.net/PGSMessagingBus/MessagingService.asmx?WSDL

 

  <?xml version="1.0"encoding="utf-8" ?>

-<wsdl:definitionsxmlns:http="http://schemas.xmlsoap.org/wsdl/http/"xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:s="http://www.w3.org/2001/XMLSchema"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"xmlns:tns="http://www.hp.com/eCommerce/PaymentGateway/MessageBus/"xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"targetNamespace="http://www.hp.com/eCommerce/PaymentGateway/MessageBus/"xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

-<wsdl:types>

-<s:schema elementFormDefault="qualified"targetNamespace="http://www.hp.com/eCommerce/PaymentGateway/MessageBus/">

-<s:element name="TakeMessageBus">

-<s:complexType>

-<s:sequence>

-<s:element minOccurs="0" maxOccurs="1"name="doc">

-<s:complexType mixed="true">

-<s:sequence>

  <s:any />

  </s:sequence>

  </s:complexType>

  </s:element>

  </s:sequence>

  </s:complexType>

  </s:element>

-<s:element name="TakeMessageBusResponse">

-<s:complexType>

-<s:sequence>

-<s:element minOccurs="0" maxOccurs="1"name="TakeMessageBusResult">

-<s:complexType mixed="true">

-<s:sequence>

  <s:any />

  </s:sequence>

  </s:complexType>

  </s:element>

  </s:sequence>

  </s:complexType>

  </s:element>

  </s:schema>

  </wsdl:types>

-<wsdl:message name="TakeMessageBusSoapIn">

  <wsdl:part name="parameters"element="tns:TakeMessageBus" />

  </wsdl:message>

-<wsdl:message name="TakeMessageBusSoapOut">

  <wsdl:part name="parameters" element="tns:TakeMessageBusResponse"/>

  </wsdl:message>

-<wsdl:portType name="MessagingServiceSoap">

-<wsdl:operation name="TakeMessageBus">

  <documentationxmlns="http://schemas.xmlsoap.org/wsdl/">This is a generic messageservice PGS provide. It requires client to pass in an xmldocument.</documentation>

  <wsdl:inputmessage="tns:TakeMessageBusSoapIn" />

  <wsdl:output message="tns:TakeMessageBusSoapOut"/>

  </wsdl:operation>

  </wsdl:portType>

-<wsdl:binding name="MessagingServiceSoap"type="tns:MessagingServiceSoap">

  <soap:bindingtransport="http://schemas.xmlsoap.org/soap/http"style="document" />

-<wsdl:operation name="TakeMessageBus">

  <soap:operationsoapAction="http://www.hp.com/eCommerce/PaymentGateway/MessageBus/TakeMessageBus"style="document" />

-<wsdl:input>

  <soap:body use="literal" />

  </wsdl:input>

-<wsdl:output>

  <soap:body use="literal" />

  </wsdl:output>

  </wsdl:operation>

  </wsdl:binding>

-<wsdl:service name="MessagingService">

-<wsdl:port name="MessagingServiceSoap"binding="tns:MessagingServiceSoap">

  <soap:addresslocation="http://pgsdev3.americas.hpqcorp.net/PGSMessagingBus/MessagingService.asmx"/>

  </wsdl:port>

  </wsdl:service>

  </wsdl:definitions>

 

========================================================

java client

 

import com.hp.www.eCommerce.PaymentGateway.MessageBus.*;
import java.net.URL;

public class test {
    public static void main(String[] args) throws Exception{
        String wsdlUrl ="http://pgsdev3.americas.hpqcorp.net/PGSMessagingBus/MessagingService.asmx?WSDL";
        URL url=new URL(wsdlUrl);

         MessagingServiceSoapStub  binding =(com.hp.www.eCommerce.PaymentGateway.MessageBus.MessagingServiceSoapStub)
                              newcom.hp.www.eCommerce.PaymentGateway.MessageBus.MessagingServiceLocator().getMessagingServiceSoap(url);

        __TakeMessageBus_doc  doc= new __TakeMessageBus_doc();

        org.apache.axis.message.MessageElement [] messageElement=new org.apache.axis.message.MessageElement[1];

            messageElement[0]=new org.apache.axis.message.MessageElement("http://www.hp.com/eCommerce/PaymentGateway/MessageBus/","TakeMessageBus");
            messageElement[0].addChildElement("Msg").addTextNode("hello");
            doc.set_any(messageElement);


        __TakeMessageBusResponse_TakeMessageBusResult value =binding.takeMessageBus(doc);

        org.apache.axis.message.MessageElement[] result=value.get_any();
       System.out.print(result[0].toString());
    }
}

 

 

============================  run  ==========================

 

result

<Error xmlns="">did on purpose or xml schemanot match.</Error>

 

============================  run  ========================== 

External Service Request

Submitted at 2006年5月30日 星期二 下午02时39分49秒 CST

<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<SOAP-ENV:Body>

<ns:TakeMessageBus xmlns:ns="http://www.hp.com/eCommerce/PaymentGateway/MessageBus/">

<ns:doc>

<msg xmlns="http://www.openuri.org/">hello</msg>

</ns:doc>

</ns:TakeMessageBus>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

============================  run   ==========================

 

External Service Response

Submitted at 2006年5月30日 星期二 下午02时39分50秒 CST

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soap:Body>

<TakeMessageBusResponse xmlns="http://www.hp.com/eCommerce/PaymentGateway/MessageBus/">

<TakeMessageBusResult>

<Error xmlns="">did on purpose or xml schema not match.</Error>

</TakeMessageBusResult>

</TakeMessageBusResponse>

</soap:Body>

</soap:Envelope>

7:37 | 添加评论 | 发送消息 | 固定链接 | 查看引用通告 (0) | 写入日志

3月14日

Web Serviceswith JBuilder / WebLogic

http://www.developer.com/java/web/print.php/3485321

 

Developing Web Services with Borland JBuilder Enterprise andBEA WebLogic Server
By Vlad Kofman
February 24, 2005

At the present, most of the corporate world is eitherentertaining an idea of Web service infrastructure or is actively developingit. Honestly, it is not that difficult to leverage previously written businesslogic and expose it as a Web service. Web service standards have gained a lotof momentum in the past years and now have come to the point where they arereliable and robust; even different development toolkits will producestandardized results across different platforms.

There are several advantages to adding a Web serviceinfrastructure to any business process. First, an existing source code (PC ormainframe based) and all the investment that went into its development will notvanish, but in fact will continue to serve its purpose from behind a new Webinterface. Second, new business transactions will be easy to conduct over theWeb and they will interact with any new or legacy system that is also exposedas a standard Web service. Third, business transactions become meaningful,thanks in part to the SOAP and XML standards. Fourth, if a Web service is welldesigned, process control should become minimized. Fifth, the session is doneover HTTP connection and therefore potentially may not be limited by firewalls.There are of course other benefits for implementing Web services and they aretherefore a very good ROI for any corporation.

In this article, I will explain how to create a simple Webservice from an existing Java application using enterprise-level tools, such asJBuilder X or JBuilder 2005 Enterprise and BEA WebLogic Application Server. Iwill describe the structure, standards, and logic of a Web service and theplatforms involved. To demonstrate a Web service in action, a project with aserver and a client will be created. The client will initiate a real Webservice session to the server. I will also briefly describe how to accomplishthe same, by using freely available tools such as Eclipse IDE and Axis Toolkit.

Hosting Environment

To have a working Web service, an Application Server capableof hosting it to the world is required. A,Web service also may be optionallyregistered with any public UDDI (Universal Description, Discovery, andIntegration) registry or with a local UDDI registry hosted on an application server.The UDDI provides address book functionality to the potential business clients;it allows the client to locate a particular service and describes what kind ofAPIs are available. Without the UDDI registry, business clients can (and oftenwill) go directly to a Web service URL and request a WSDL (Web ServiceDefinition Language) document that also will contain a detailed description ofwhat APIs are provided. The WSDL is an XML document that is hosted by theApplication Server.

In a true business environment, WSDL should define not onlyall methods that are available but also a schema for all transactions. WSDL isdesigned to be understood by Web Service programs to help them create objectstubs with methods to call on the client-side; a WSDL file is therefore autogenerated by the toolkit that will be used to create a Web service.

A Web Service will be hosted as a Web application, inside ofa web service container on an Application Server. Any interested client willinitiate a regular HTTP session to interact with it. To set up Web service, BeaWebLogic Application server will be used, which is one of the industry leadingplatforms. It is available for free for development purposes, but for aproduction environment it will require a license. As an alternative, a freeTomcat application server and Axis toolkit or Jetty application server and Axistoolkit can be used. There are other Application Servers, notably JBoss, SunOnefrom Sun Microsystems, and WebSphere from IBM, but they are beyond the scope ofthis article. Any of these Web platforms are capable of hosting a Webapplication and services. For the development side, JBuilder X or 2005Enterprise provides tremendous flexibility and ease in creating Web services. Ialso highly recommend the free Eclipse IDE with WebSphere or IBM WSAD tool forcreating Web services hosted on WebSphere application server, but they arebeyond the scope of this article.

Installation of BEA Weblogic is very straightforward, butJBuilder needs to be configured to hook into the Application server. Directionsare as follows: In JBuilder, under the Tools menu, click Configure Servers toset up an application server setting.




Click here for a larger image.

Figure 1: Set up Custom parameters for the server.




Click here for a larger image.

Figure 2

Creating a Legacy Project

Create a new project in JBuilder. Create a new"beanexport" package in that project and add one class called Bean1.Another class called Tuple (see Listing 1, at the end of this article) can becreated as well. The tuple class holds a pair of strings and is used todemonstrate a more complex object sent via a Web service. It is completelyoptional and does not need to be used.

 

Go to page: 1  2  3  4  Next  

----------------------------------------------------------------------------------------------------

Developing Web Services with Borland JBuilder Enterprise andBEA WebLogic Server
By Vlad Kofman
February 24, 2005

Exposing Code as a Web Service

For the demonstration purposes of wrapping existing"legacy" APIs and turning them into a fully functional Web service,consider an extremely simple Java class called Bean1 that has only threemethods. One method always returns a random number, another a "Hello"string, and another a more complex object.

The class exposes a public API of just three methods, but areal-world application will contain a much more complex API. An enterpriseapplication can have hundreds of methods returning values from databases, EJBs,or Mainframe call wrappers. Some methods will be taking parameters, others initiatinga business transaction dialogue. But, it will be just as easy to convert anycomplex API into a Web Service API, as it is this sample class.

package beanexport;

import java.io.Serializable;

 

public class Bean1 implements Serializable {

   public doublegetDouble(){

      returnMath.random();

   }

 

   public StringgetText(){

      return"Hello";

   }

 

   public TuplegetHeader(){

      Tuple t = newTuple("Vlad","Kofman");

      return t;

   }

 

}

Please see Listing 1 for the Tuple object source.

Creating a Web Service

Assuming that the Bean1 Java project in JBuilder is set upand can be compiled successfully, and BEA Weblogic Server is up and running,the Bean1 class can now be exposed as a Web service. JBuilder truly simplifiesthe creation and deployment of any Web service. With the Bean1 project opened,follow these steps:

Click Project -> Project Properties -> Server.

Weblogic should be listed as one of the choices; choose it.

Note: Web services can also be developed with JBuilder fordeployment on a free Tomcat server; it appears here as a choice also.

Additional configuration of services: A project will host onthe chosen allocation server such as EJB. Servlets and JSPs can be selected aswell, but for now, click OK.




Click here for a larger image.

Figure 3

Click File -> New -> Web Services.

Click New Web Service Configuration (JBuilder X).

Choose Weblogic as toolkit, default is Axis (used withTomcat server).

Choose server and client modules.

Create new Web Module; accept all defaults for now.

Create new application module; also take all default values.




Click here for a larger image.

Figure 4

In the next screen, name the server Bean1Server and save.

JBuilder automatically creates all necessary J2EE (Java 2Enterprise Edition) standard folders and files structures. It should open a WebServices Designer view after the initial configuration is saved.

Now, for the easy part. The Bean1 project should have thefollowing structure (left panel):

Package "beanexport"

ApplicationModule1 module

Web-services module

Web-services designers

Take the Bean1 class and drag-and-drop it on to theWeb-services designers Area. Or, click the Create Service drop-down and chooseJava Service.

Re-build the Bean1 project; more files should beauto-created in the different subfolder of the project. That is it; the Webservice is done. All that remains is to deploy it!

Consider what JBuilder did.

After getting a class to expose, JBuilder will inspect all public APIs of the class and automatically generate a WSDL definition file and all SOAP stabs and proxies, package them into WAR and EAR files (more on these later), and prepare deployment descriptors specific to the application server selected.

Similarly, if Axis was to be chosen as a toolkit and Tomcat as a server, generated files would be specific for it also.

 

-----------------------------------------------------------------Developing Web Services with Borland JBuilder Enterprise and BEA WebLogicServer
By Vlad Kofman
February 24, 2005

Any Web service communicates over a HTTP (or HTTPS)protocol, The Client sends a SOAP—Simple Object Access Protocol—request andwaits for the SOAP response. SOAP is basically XML in a special format thatdescribes the communication. Behind the scenes, both server and client have XMLparsers and encoders communicating over an HTTP socket. After the request isreceived, it is decoded into the specific method to call, with what parameters,and after that method is invoked, its return value (if any) is enclosed intoXML-SOAP envelope and pushed back.

According to the J2EE specification, a very specificapplication structure must exist to be used as a Web application. WAR—WebARchive—files contain deployment descriptors and code and are packed in toEAR—Enterprise ARchive—files for final installation on the application server.Because this specification is the same for all platforms, any code in WAR andEAR packages developed with any toolkit should work on any application server;however, most application server vendors will probably be different in theirdeployment descriptor files.

Thankfully, JBuilder takes the complexity out of making Webapplications, but a standalone Axis Java2WSDL tool can always be used and manualpackaging of code into an EAR file is possible. Please see the referencesection for more Axis documentation.

Sample Server

Now, the project is complete and is ready to be deployed on an application server and run as a Web service server. Here is what it should look like (see right panel):

Deployment with JBuilder is also as easy as the creation of a Web service. Make sure BEA Weblogic is running. Right-click on ApplicationModule1 (the name of your service application module) and select -> Deploy Options -> Deploy.




Click here for a larger image.

Figure 7

JBuilder will indicate something like this:

Initiated Task: [0] [Deployer:149026]Deploy application

               ApplicationModule1 on myserver.

Task 0 running: [Deployer:149026]Deploy application

               ApplicationModule1 on myserver.

Deployment completed on Server myserver

That is it! Your new Web service is now hosted and ready tobe used by the world!

It also can be undeployed and redeployed in the same way. Allcurrent deployments also can be listed from the same menu.

To test, either open JBuilder -> Tools-> Web ServicesConsole or point your Web browser to http://localhost:7001/web-services/Bean1.

A Web-based test client provided by Weblogic of the newservice should appear, invoking SOAP communication behind the scenes to callBean1's methods. It can even show the XML being sent around.

For example, clicking on the getText() method will result inthe following:

Parameter Name

Parameter Value

Return Value

Hello

Request sent to the server:

<!--REQUEST.................-->

<env:Envelopexmlns:env="http://schemas.xmlsoap.org/soap/envelope/"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"

             xmlns:xsd="http://www.w3.org/2001/XMLSchema">

   <env:Bodyenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

   <m:getTextxmlns:m="http://beanws">

   </m:getText>

   </env:Body>

</env:Envelope>

Response from the server:

<!--RESPONSE.................-->

<env:Envelopexmlns:env="http://schemas.xmlsoap.org/soap/envelope/"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"

             xmlns:xsd="http://www.w3.org/2001/XMLSchema">

   <env:Bodyenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

     <m:getTextResponse xmlns:m="http://beanws">

         <resultxsi:type="xsd:string">Hello</result>

     </m:getTextResponse>

   </env:Body>

</env:Envelope>

The whole WSDL file can be viewed by appending"?WSDL" to the URL:

http://localhost:7001/web-services/Bean1?WSDL

The production server deployment would be of course not withJBuilder, but its equally easy-to-use, Web-based administration Console,usually running on same port as the Weblogic server, for example http://localhost:7001/console, to deployEAR files.

Please read the Weblogic documentation on how to use theirserver administration; the ApplicationModule.EAR file can be found in theJBuilder project directory.
---------------------------------------------  

www.developer.com/java/web/article.php/3485321

Back toArticle

Featured Resources from the
Sterling Commerce B2B Data Management Resource Center

WHITEPAPER
Gain Competitive Edge through Optimized B2B File Transfer.
Explore how you can increase your competitive edge and profits

ASSESSMENT TOOL
Growth Readiness Assessment
Ready for your business to grow? Is your business prepared to handle it?

CASE STUDY
Wachovia Bank
See how Wachovia lowered costs and increased security for external and internal data transmissions.

 

 

Developing Web Services with Borland JBuilder Enterprise and BEA WebLogic Server
By Vlad Kofman
February 24, 2005

Simple Client

The Weblogic test client is not very useful for business; other clients will want to use this Web service with their own implementations. The general mechanism for creating a client is to point the Web service toolkit to the WSDL file and have it generate the client object stubs. The stubs then will be used to open a port to the server and call its methods. They also hide all the complexity of marshaling and un-marshaling of SOAP that is occurring behind the scenes. But, because the client module was added to the project, JBuilder intuitively added a GeneratedWebServicesClient folder to the project and created Bean1_client.jar.

The jar contains all the necessary files to make a fully functional client for the Bean1 service.

Here is how to create a simple test client:

Create a new package called "test", and add the new Test class.

Then, import package beanexport.generated.*; it should already be in the class path because it is in the project.

Create a connection to the service via gerenated stubs:

String wsdlUrl = "http://localhost:7001/web-services/Bean1?WSDL";

Bean1 service = new Bean1_Impl(wsdlUrl);    //bind to service

Bean1Port port = service.getBean1Port();    //get port

And call any method. Here is the complete listing:

package test;

 

import beanexport.generated.*;

 

public class Test {

   public static void main(String[] args) {

      try {

         String wsdlUrl = "http://localhost:9501/web-services/Bean1?WSDL";

         Bean1 service = new Bean1_Impl(wsdlUrl);

         Bean1Port port = service.getBean1Port();

 

         int result = port.getInt();

         System.out.println("Int is: " + result);

 

         Tuple[] tuple = port.getHeader();

 

         System.out.println("1st tuple: " + tuple[0]);

         System.out.println("2nd tuple: " + tuple[1]);

 

         }

         catch (Exception e) {

         e.printStackTrace();

      }

 

   }

}

The result would be an executable program that uses a Web service for communication with the server, calling APIs that were just legacy Java methods, but are now Web service calls.

Conclusion

This article has covered the basics of Web services. It created a simple Java class and turned it into a fully functional Web service. Also, this article discussed how to produce a client to talk to the server and invoke SOAP communication.

Packaging "legacy" code as a Web service mostly involved an understanding of the tools at hand. By hiding all the "plumbing" and complexities of marshaling SOAP and XML parsing, current application servers and toolkits make it very easy to create new or expose existing code as new Web services. This also lets developers concentrate on the business transactions and logic instead of dealing with low-level protocols and communications.

Listing 1

Tuple Class

 

package beanexport;

 

import java.io.Serializable;

 

public class Tuple

   implements Serializable {

      private String key;

      private String value;

 

      public Tuple() {

      }

 

   public Tuple(String key, String value) {

      this.key = key;

      this.value = value;

   }

 

   public Tuple(Object key, Object value) {

      this.key = key.toString();

      this.value = value.toString();

   }

 

   public String getValue() {

      return value;

   }

 

   public String getKey() {

      return key;

   }

 

   public String toString() {

      return key + " : " + value;

   }

 

   public void setKey(String key) {

      this.key = key;

   }

 

   public void setValue(String value) {

      this.value = value;

   }

}

About the Author

Vlad Kofman is a system architect working on projects under government defense contracts. He has also been involved with enterprise-level projects for major Wall Street firms and the U.S. government. His main interests are object-oriented programming methodologies and design patterns.

Sources

Download the accompanying source code here.

Online Reference Materials and Books

http://www.uddi.org/

The Universal Description, Discovery, and Integration (UDDI) protocol is one of the major building blocks required for successful Web services. UDDI creates a standard interoperable platform that enables companies and applications to quickly, easily, and dynamically find and use Web services over the Internet. UDDI also allows operational registries to be maintained for different purposes in different contexts. UDDI is a cross-industry effort driven by major platform and software providers, as well as marketplace operators and e-business leaders within the OASIS standards consortium. http://www.uddi.org/.

www.w3.org/TR/wsdl

WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate, however, the only bindings described in this document describe how to use WSDL in conjunction with SOAP 1.1, HTTP GET/POST, and MIME.

Borland Software Corporation

http://info.borland.com/techpubs/jbuilder/

Developing Web Services with JBuilder X Enterprise

Developing Web Services with JBuilder 2005 Enterprise

http://info.borland.com/techpubs/jbuilder/jbuilder2005/websvcs/contents.html

2:05 | 添加评论 | 阅读评论 (2) | 发送消息 | 固定链接 | 查看引用通告 (0) | 写入日志 | Computers and Internet

3月9日

webserviceDev Ex and java config

http://www.iyuanma.com/info/27/26416_20051021191349.htm

 

 

摘自csdn

简单的webservice开发例子

Axis支持三种web  service的部署和开发,分别为:  
 
1、Dynamic  Invocation  Interface  (  DII)  
 
2、Stubs方式  
 
3、Dynamic  Proxy方式  
 
二、编写DII(Dynamic  Invocation  Interface  )方式web服务  
 
1.编写服务端程序HelloClient  
 
 
public  class  HelloClient  
{  
       public  String  getName(String  name)  
       {  
               return  "hello  "+name;  
       }  
}  
   
 
 
 
2、将源码拷贝到Axis_HOME下,重命名为  HelloClient.jws    
 
3、访问连接http://localhost:8080/Axis/HelloClient.jws?wsdl,页面显示Axis自动生成的wsdl    
 
4、编写访问服务的客户端  TestHelloClient.java    
 
 
import  org.apache.Axis.client.Call;  
import  org.apache.Axis.client.Service;  
import  javax.xml.namespace.QName;  
import  javax.xml.rpc.ServiceException;  
import  java.net.MalformedURLException;  
import  java.rmi.RemoteException;  
 
public  class  SayHelloClient2  
{  
       public  static  void  main(String[]  args)  
           {  
               try  
                       {  
   String  endpoint  =  
   "http://localhost:8080/Axis/HelloClient.jws";  
 
       Service  service  =  new  Service();  
                       Call  call  =  null;  
 
                       call  =  (Call)  service.createCall();  
 
                       call.setOperationName(new  QName(  
                             "http://localhost:8080/Axis/HelloClient.jws",    
                                         "getName"));  
                       call.setTargetEndpointAddress  
                                   (new  java.net.URL(endpoint));  
 
                       String  ret  =  (String)  call.invoke(new  Object[]    
                                   {"zhangsan"});  
                       System.out.println("return  value  is  "  +  ret);  
               }    
                       catch  (Exception  ex)  
                       {  
             ex.printStackTrace();  
               }  
       }  
}  
   
 
 
 
三、编写Dynamic  Proxy方式访问服务    
 
1、编写部署服务端程序,同上边DII方式,本次仍使用上边部署的HelloClient    
 
2、编写代理接口    
 
 
public  interface  HelloClientInterface  
extends  java.rmi.Remote  
{  
       public  String  getName(String  name)  
           throws  java.rmi.RemoteException;  
}  
   
 
 
 
3、编写并执行客户端程序TestHelloClient.java    
 
 
import  javax.xml.rpc.Service;  
import  javax.xml.rpc.ServiceFactory;  
import  java.net.URL;  
import  javax.xml.namespace.QName;  
 
public  class  TestHelloClient    
{  
       public  static  void  main(String[]  args)  
           {  
               try  
               {  
                       String  wsdlUrl  =    
                                   "http://localhost:8080/Axis/HelloClient.jws?wsdl";  
                       String  nameSpaceUri  =    
                                   "http://localhost:8080/Axis/HelloClient.jws";  
                       String  serviceName  =  "HelloClientService";  
                       String  portName  =  "HelloClient";  
 
                       ServiceFactory  serviceFactory  =    
                                   ServiceFactory.newInstance();  
                       Service  afService  =  
                                   serviceFactory.createService(new  URL(wsdlUrl),  
                 new  QName(nameSpaceUri,  serviceName));  
                       HelloClientInterface  proxy  =  (HelloClientInterface)  
               afService.getPort(new  QName(  
                                       nameSpaceUri,  portName),    
                                                           HelloClientInterface.class);  
                       System.out.println  
                                   ("return  value  is  "+proxy.getName("john")  )  ;  
               }catch(Exception  ex)  
               {  
                       ex.printStackTrace()  ;  
               }  
       }  
}  
   
 
 
 
四、编写wsdd发布web服务,编写stub  client访问web服务    
 
1、编写服务端程序server,SayHello.java,编译server.SayHello.java    
 
 
package  server;  
public  class  SayHello  
{  
       public  String  getName(String  name)  
       {  
               return  "hello  "+name;  
       }  
}  
2.编写LogHandler.java  
import  org.apache.Axis.AxisFault;  
import  org.apache.Axis.Handler;  
import  org.apache.Axis.MessageContext;  
import  org.apache.Axis.handlers.BasicHandler;  
 
import  java.util.Date;  
 
public  class  LogHandler    
extends  BasicHandler    
{  
 public  void  invoke  
(MessageContext  msgContext)    
throws  AxisFault  
       {  
               /**  Log  an  access  each  time    
                       we  get  invoked.  
                 */  
               try  {  
                       Handler  serviceHandler  
                                   =  msgContext.getService();  
 
                       Integer  numAccesses  =  
   (Integer)serviceHandler.getOption("accesses");  
                       if  (numAccesses  ==  null)  
                               numAccesses  =  new  Integer(0);  
numAccesses  =  new  Integer  
(numAccesses.intValue()  +  1);  
Date  date  =  new  Date();  
 String  result  =    
 date  +  ":  service  "  +  
msgContext.getTargetService()  +  
"  accessed  "  +  numAccesses  +  "  time(s).";  
serviceHandler.setOption  
("accesses",  numAccesses);  
System.out.println(result);  
               }  catch  (Exception  e)  
                       {  
                       throw  AxisFault.makeFault(e);  
               }  
       }  
}  
   
 
 
 
3、编写wsdd文件    
 
 
deploy.wsdd  
<deployment  xmlns=  
"http://xml.apache.org/Axis/wsdd/"  
   xmlns:java=  
                                   "http://xml.apache.org/Axis/wsdd/providers/java">                        
     <handler  name="print"  type="java:LogHandler"/>    
 <service  name="sayhello"  
 provider="java:RPC">  
     <requestFlow>  
         <handler  type="print"/>  
     </requestFlow>  
   <parameter  name="className"    
   value="server.SayHello"/>  
   <parameter  name="allowedMethods"  
   value="*"/>      
 </service>  
</deployment>  
   
 
 
 
3、将编译后的文件拷贝到Axis_HOME/WEB-INF/classes下,如:D:\tomcat\webapps\Axis\WEB-INF\classes    
 
4、发布服务:    
 
java  org.apache.Axis.client.AdminClient  deploy.wsdd    
 
5、生成client  stub文件    
 
a:方式1    
 
将SayHello.java拷贝到Axis_HOME/下,重命名为SayHello.jws,    
 
执行下面的命令生存client  stub    
 
 
java  org.apache.Axis.wsdl.WSDL2Java    
-p  client    http://localhost:8080  
/Axis/services/SayHello.jws?wsdl  
   
 
 
 
b:方式2    
 
执行如下命令生成SayHello.wsdl    
 
 
java  org.apache.Axis.wsdl.Java2WSDL  
-oSayHello.wsdl  -lhttp://localhost:8080  
/Axis/services/SayHello  -nsayhello  server.SayHello  
   
 
 
 
执行如下命令生成client  stub    
 
 
java  org.apache.Axis.wsdl.WSDL2Java    
SayHello.wsdl    -p  client  
   
 
 
 
生成的stub  client文件列表为:    
 
1.SayHello.java    
 
2.SayHelloService.java。    
 
3.SayHelloServiceLocator.java    
 
4.SayHelloSoapBindingStub.java    
 
6、编写客户端程序,编译并执行    
 
 
public  class  SayHelloClient  
{  
       public  static  void  main(String[]  args)  
           {  
               try  
                       {  
       SayHelloService  service  =  new  client.  
             SayHelloServiceLocator();  
                   client.SayHello_PortType    
                           client  =  service.getSayHello();  
                       String  retValue=client.getName("zhangsan");  
                       System.out.println(retValue);  
}    
catch  (Exception  e)  
{  
 System.err.println  
 ("Execution  failed.  Exception:  "  +  e);  
               }  
       }  
}  

 /------------------------------------------------------------------------------------/

JAVA开发工具安装配置心得 
安装 
一、J2SE安装方法 
1、首先下载J2SE(本人这里为版本J2SE1.5.0,内核版本5.0 update6)到本地机 
下载地址:http://java.sun.com/j2se/1.5.0/download.jsp 
2、点击开始安装(傻瓜安装方式,只要下一步就可以了),这里说一下安装路径,JDK我一般习惯用D:\J2SE(D为你要安装的盘符);JRE就让它用自己的默认路径就好了。 
二、J2EE安装方法 
1、首先下载J2EE(本人这里版本为J2EE1.4)到本地机 
下载地址:http://java.sun.com/j2ee/1.4/download.html#sdk 
2、点击开始安装(傻瓜安装方式,只要下一步就可以了),这里说一下安装路径,我一般习惯用D:\J2EE(D为你要安装的盘符),需要注意的是,它会提醒你有个访问端口,建议不要使用它默认的8080端口(原因很简单,我们要留给下面的Tomcat)。管理员密码自己记住一个8位的就可以了。 
三、J2ME安装方法(如果对手机、无线开发没有兴趣,这里可以跳过,有兴趣的朋友可以跟我具体研究一下,吼吼) 
1、首先下载J2ME(本人这里版本为J2ME2.2)到本地机,这里还要下载MIDP与CLDC开发包(版本分别为MIDP2.0与CLDC1.1)。 
下载地址:http://java.sun.com/j2me/download.html 
2、点击开始安装,(傻瓜安装方式,只要下一步就可以了),安装之前它会找到默认的JDK安装盘符,不用管它,下一步就可,这里说一下安装路径,我一般习惯用D:\J2ME(D为你要安装的盘符)。 
3、将MIDP与CLDC解压缩到安装目录 
四、安装TOMCAT(基本上学习都用这个了,IBM WebSphere与Bea WebLogic的安装与配置方法我会在以后的帖子中发表出来) 
1、首先下载TOMCAT(本人这里版本为TOMCAT5.5),具体网址未知,去官方网站吧,不知道还能不能下载了。 
2、点击开始安装,建议用Full方式全部安装,它会提示一个JRE的安装路径,默认不用管它,这里说一下安装路径,我一般习惯用D:\TOMCAT(D为你要安装的盘符)。 
3、端口号默认8080,管理员密码可以为空。 
4,比较重要一点,安装完毕以后,点击开始——程序——管理工具——服务——选中该服务,将该服务设置为手动启动模式。 

配置 
这里只针对Window 2000以上版本配置,本人版本为WindowXP Sp2 
右键点击我的电脑——属性——高级——环境变量。 
配置如下 
PATH=:\J2SE\bin;D:\J2EE\bin;D:\J2ME\bin;D:\J2ME\MIDP\bin;D:\J2ME\MIDP\build\win32\tools.jar;D:\TOMCAT\bin;C:\WINDOWS;C:\WINDOWS\COMMAND; 

CLASSPATH=.;D:\J2SE\lib;D:\J2SE\lib\tools.jar;D:\J2SE\lib\dt.jar;D:\J2EE\lib;D:\J2EE\lib\j2ee.jar;D:\J2ME\CLDC\classes;D:\TOCMAT\bin; 

JAVA_HOME=D:\J2SE 
J2EE_HOME=D:\J2EE 
MIDP_HOME=D:\J2ME\MIDP 
CATALINA_HOME=D:\TOMCAT 

DEPTH_SCREEN=8(这个不知道现在还需要不需要了,有经验的朋友告诉我一下,谢谢) 

OK,到此安装配置就全部结束了,本人水平有限,恐有疏漏,望各位朋友指正,谢谢 

 

 


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值