The important thing in life is to have a great aim , and the determination

          常用鏈接

          統(tǒng)計(jì)

          IT技術(shù)鏈接

          保險(xiǎn)相關(guān)

          友情鏈接

          基金知識

          生活相關(guān)

          最新評論

          Web Service學(xué)習(xí)筆記之----JAX-RPC (轉(zhuǎn)載CN-JAVA)

          導(dǎo)讀
          本文是我對學(xué)習(xí)jwsdp-1.2時(shí)所做筆記的整理,其中主要是一些指導(dǎo)性的內(nèi)容,并沒有多少概念以及原理的介紹,讀者可能覺得略顯簡單,如果想要學(xué)習(xí)基本概念可以參考網(wǎng)上有關(guān)Web Service的資料。本文例子所使用的開發(fā)環(huán)境是WindowXP+JWSDP-1.2。

          一.Web Service簡介
          1.定義
          由兩部分組成
          ·SOAP--Web Service之間的基本通信協(xié)議。
          ·WSDL--Web Service描述語言,它定義了Web Service做什么,怎么做和查詢的信息。
          2.簡單的Web Service實(shí)現(xiàn)
          包含四個(gè)基本步驟
          ·創(chuàng)建Web Service的商業(yè)邏輯(通常是一些Java類)
          ·將這些Java類部署到一個(gè)SOAP服務(wù)器上
          ·生成客戶訪問代碼
          ·部署客戶應(yīng)用
          注意:WSDL等文件的生成通常是利用廠商提供的工具來完成
          3.WSDL解析
          WSDL描述語言一般包含三部分
          ·What部分--包括了type、message和portType元素
          Type:定義了Web Service使用的數(shù)據(jù)結(jié)構(gòu)(使用XML Schema定義)
          Message:一個(gè)Message是SOAP的基本通信元素。每個(gè)Message可以有一個(gè)或多個(gè)Part,每個(gè)Part代表一個(gè)參數(shù)。
          PortType:消息匯總為不同的操作并歸入到一個(gè)被稱為portType的實(shí)體中。一個(gè)portType代表一個(gè)接口(Web Service支 持的操作集合),每個(gè)Web Service可以有多個(gè)接口,它們都使用portType表示。每個(gè)操作又包含了input和 output部分。
          ·How部分--包含binding元素
          binding元素將portType綁定到特定的通信協(xié)議上(如HTTP上的SOAP協(xié)議)
          ·Where部分--由service元素組成
          它將portType,binding以及Web Service實(shí)際的位置(URI)放在一起描述
          4.客戶端
          通常Web Service可以有三種類型的客戶
          ·商業(yè)伙伴(Business Partner)--包括分發(fā)商,零售商以及大型消費(fèi)者)
          此類客戶通過SOAP、WSDL、ebXML、UDDI等XML技術(shù)與Web Service連接
          ·瘦客戶--包括Web瀏覽器、PDA以及無線設(shè)備
          該類客戶通常經(jīng)由輕量協(xié)議(如HTTP)與Web Service連接
          ·肥客戶--包括Applet、各類應(yīng)用以及現(xiàn)存系統(tǒng)
          通常使用重量級協(xié)議(如IIOP)連接Web Service

          二.使用JAX-RPC開發(fā)Web Service
          1.JAX-RPC支持的數(shù)據(jù)類型
          JAX-RPC除了支持Java的基本數(shù)據(jù)類型外還支持一些自定義對象,但這些對象有一些條件限制
          ·有缺省構(gòu)造函數(shù)的對象
          ·沒有實(shí)現(xiàn)java.rmi.Remote接口
          ·字段必須是JAX-RPC支持的類型
          ·公有字段不能聲明為final或transient
          ·非公有字段必須有對應(yīng)的setter和getter方法
          2.使用JAX-RPC創(chuàng)建Web Service
          ·基本步驟
          A. 編寫服務(wù)端接口并實(shí)現(xiàn)
          一個(gè)服務(wù)的end-point有一些規(guī)定:必須實(shí)現(xiàn)java.rmi.Remot接口而且每個(gè)方法需要拋出RemoteException異常。
          B. 編譯、生成并且將所有服務(wù)需要的類和文件打包成WAR文件
          C. 部署包含服務(wù)的WAR文件
          ·如何創(chuàng)建服務(wù)
          A. 編譯服務(wù)所需的類文件
          B. 生成服務(wù)所需文件
          可以使用wscompile工具生成model.gz文件,它包含了描述服務(wù)的內(nèi)部數(shù)據(jù)結(jié)構(gòu)命令如下
          wscompile -define -d build -nd build -classpath build config.xml
          -model build/model.gz
          define標(biāo)志告訴工具讀取服務(wù)的 endpoint接口并且創(chuàng)建WSDL文件。-d和-nd標(biāo)志告訴工具將輸出文件寫入指定的目錄build。工具需要讀以下的config.xml文件
          <?xml version=”1.0” encoding=”UTF-8”?>
          <configuration xmlns=”http://java.sun.com/xml/ns/jax-rpc/ri/config”>
          <service
          name=”HelloService”
          targetNamespace=”urn:Star”
          typeNamespace=”urn:Star”
          packageName=”helloservice”>
          <interface name=”helloservice.HelloIF”/>
          </service>
          </configuration>
          該文件告訴wscompile創(chuàng)建model文件所需的信息
          ·服務(wù)名稱:MyHelloService
          ·WSDL名字空間:urn:Star
          ·HelloService的所有類在包helloservice中
          ·服務(wù)的端點(diǎn)(endpoint)接口:helloservice.HelloIF
          C. 將服務(wù)打包為WAR文件
          WEB-INF/classes/hello/HelloIF.class
          WEB-INF/classes/hello/HelloImpl.class
          WEB-INF/jaxrpc-ri.xml
          WEB-INF/model.gz
          WEB-INF/web.xml
          jaxrpc-ri.xml文件如下所述
          <?xml version=”1.0” encoding=”UTF-8”?>
          <webServices xmlns=”http://java.sun.com/xml/ns/jax-rpc/ri/dd”
          version=”1.0”
          targetNamespaceBase=”urn:Star”
          typeNamespaceBase=”urn:Star”
          urlPatternBase=”webservice”>
          <endpoint name=”Hello”
          displayName=”HelloWorld Service”
          description=”A simple web service”
          interface=”helloservice.HelloIF”
          model=”/WEB-INF/model.gz”
          implementation=”helloservice.HelloImpl”/>
          <endpointMapping endpointName=”Hello” urlPattern=”/hello”/>
          </webServices>
          D. 處理WAR文件
          使用命令行
          wsdeploy -o hello-jaxrpc.war hello-jaxrpc-original.war
          wsdeploy工具完成以下幾個(gè)任務(wù)
          ·讀 hello-jaxrpc-original.war作為輸入
          ·從jaxrpc-ri.xml文件中獲得信息
          ·為服務(wù)生成tie classes
          ·生成名為HelloService.wsdl的WSDL文件
          ·將tie classes和HelloService.wsdl文件打包到新的war文件中
          E. 在服務(wù)器上部署服務(wù)
          如果你使用的是TOMCAT,你可以將WAR文件拷貝到webapps目錄下,然后可以在
          <http://localhost:8080/[context]/[servicename>上看是否配置成功
          ·如何使用JAX-RPC創(chuàng)建Web Service客戶端
          通常有三種類型的客戶:Static Stub、Dynamic Proxy和Dynamic Invocation Interface(DII)
          Static Stub客戶
          ·生成Stub
          通過使用config-wsdl.xml和wscompile工具,可以生成stub
          wscompile -gen:client -d build -classpath build config-wsdl.xml
          config-wsdl.xml文件如下
          <?xml version="1.0" encoding="UTF-8"?>
          <configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
          <wsdl location="http://localhost:8080/helloWS/hello?WSDL"
          packageName="staticstub"/>
          </configuration>
          wscompile工具讀取服務(wù)器上的WSDL文件并生成stub
          ·編寫靜態(tài)客戶代碼
          Stub stub=(Stub)(new HelloService_Impl().getHelloIFPort());
          HelloIF hello=(HelloIF)stub;
          Hello.sayHello(“starchu”);
          注意:HelloService_Impl類由wscompile生成
          ·編譯代碼
          ·運(yùn)行客戶端(需要包含saaj API和JAX-RPC API運(yùn)行)
          Dynamic Proxy客戶
          ·生成接口
          通過使用config-wsdl.xml文件和wscompile工具,可以生成客戶所需的接口
          wscompile -import -d build -classpath build config-wsdl.xml
          config-wsdl.xml和前面列出的文件內(nèi)容相同。
          ·編寫動態(tài)客戶代碼
          ServiceFactory factory=ServiceFactory.newInstance();
          URL wsdlUrl=new URL(“<your web service wsdl url>”);
          Service service=factory.createService(wsdlUrl,
          new QName(“urn:Star”,”HelloService”));
          HelloIF hello=(HelloIF)service.getPort(
          new QName(“urn:Star”,”HelloIFPort”),HelloIF.class);
          Hello.sayHello(“starchu”);
          注意:這里不再需要靜態(tài)客戶代碼的HelloService_Impl類
          ·編譯代碼
          ·運(yùn)行客戶端(需要包含saaj API和JAX-RPC API運(yùn)行)
          Dynamic Invocation Interface客戶
          這個(gè)方法為我們提供了更有彈性的客戶調(diào)用方式,客戶代碼不在需要由wscompile工具生成的運(yùn)行時(shí)類,當(dāng)然這種代碼更加復(fù)雜。具體步驟如下:
          ·創(chuàng)建ServiceFactory實(shí)例
          ServiceFactory factory=ServiceFactory.newInstance();

          ·創(chuàng)建Service(利用服務(wù)名的Qname)
          Service service=factory.createService(new QName(“HelloService”));

          ·創(chuàng)建Call對象(使用端點(diǎn)接口的Qname)
          Call call=service.createCall(new QName(“HelloIF”));

          ·設(shè)置端點(diǎn)的地址和一些Call對象屬性
          call.setTargetEndpointAddress(args[0]);
          call.setProperty(Call.SOAPACTION_USE_PROPERTY,new Boolean(true));
          call.setProperty(Call.SOAPACTION_URI_PROPERTY,””);
          call.setProperty(“javax.xml.rpc.encodingstyle.namespace.uri”,
          “http://schemas.xmlsoap.org/soap/encoding/”);

          ·設(shè)置遠(yuǎn)程調(diào)用的返回類型、操作名和參數(shù)
          QName stringType=new Qname(“http://www.w3.org/2001/XMLSchema”,”string”)
          call.setReturnType(stringType);
          call.setOperationName(new Qname(“urn:Star”,”sayHello”));
          call.addParameter(“String_1”,stringType,ParameterMode.IN);

          ·調(diào)用call的invoke方法
          String [] param={ “ starchu “ };
          String retValue=call.invoke(param);

          ·編譯代碼并對Main方法設(shè)置<http://localhost:8080/helloWS/hello參數(shù)(服務(wù)器需有效>)

          3.SOAP Message Handler的例子
          通常使用JAX-RPC建立的Web Service并不需要開發(fā)人員自己處理SOAP消息,但是JAX-RPC提供了一種機(jī)制可以使程序員獲得這種處理能力,這就是所謂的消息處理器。總的來說,像日志和加解密功能可以通過SOAP消息處理器實(shí)現(xiàn),除此之外,你根本不需要處理SOAP消息。
          ·基本Handler處理過程
          SOAP請求
          ·客戶端處理器在請求消息發(fā)送到服務(wù)器前被調(diào)用
          ·服務(wù)端處理器在請求消息分發(fā)到端點(diǎn)前被調(diào)用
          SOAP應(yīng)答
          ·服務(wù)端處理器在應(yīng)答消息發(fā)送回客戶前被調(diào)用
          ·客戶端處理器在應(yīng)答消息轉(zhuǎn)換成Java方法返回前被調(diào)用
          SOAP錯(cuò)誤
          處理過程與SOAP應(yīng)答的方式一樣
          注意:處理器可以在任意端組成處理器鏈
          A.Handler基本編程模型
          服務(wù)端
          ·編寫服務(wù)端點(diǎn)接口代碼、實(shí)現(xiàn)服務(wù)并且實(shí)現(xiàn)服務(wù)端處理器類
          ·創(chuàng)建jaxrpc-ri.xml文件,以便wscompile使用,其中包含了Handler的信息
          ·創(chuàng)建web.xml文件
          ·編譯所有代碼
          ·將文件打包為WAR文件
          ·用wsdeploy工具將原始war文件替換為完整可部署的war文件
          ·在服務(wù)器上部署war文件
          客戶端
          ·編寫客戶程序以及客戶端處理器代碼
          ·創(chuàng)建config.xml文件以便wscompile使用,它包含了客戶端處理器的信息
          ·編譯代碼
          ·運(yùn)行wscompile生成服務(wù)端點(diǎn)接口和客戶類
          ·編譯所有代碼,并運(yùn)行客戶應(yīng)用

          B.建立客戶端處理器
          處理器必須擴(kuò)展javax.xml.rpc.handler.GenericHandler類并且提供至少兩個(gè)方法的實(shí)現(xiàn)init和getHandlers。此外,你可以利用handleXXX方法處理請求、應(yīng)答和錯(cuò)誤SOAP消息。基本步驟如下
          ·編寫客戶端處理器代碼
          Public class ClientHandler extends GenericHandler{
          Public void init(HandlerInfo info){
          This.info=info;
          }
          public QName[] getHeaders(){
          return info.getHeaders();
          }
          public boolean handleRequest(MessageContext context){
          SOAPMessageContext smc=(SOAPMessageContext)context;
          SOAPMessage message=smc.getMessage();
          file://You can use SOAP API to implement your own logic
          file://such as logging and encrypt
          ……
          file://Set a logger element in the SOAPHeader
          SOAPHeaderElement loggerElement=
          header.addHeaderElement(envelope.createName(“loginfo”,
          “ns1”,”urn:Star:headprops”));
          loggerElement.setMustUnderstand(true);
          loggerElement.setValue(“10”);
          file://Set a name element in the SOAP Header
          SOAPHeaderElement nameElement=
          Header.addHeaderElement(envelope.createName(“client”,
          “ns1”,”urn:Star:headprops”));
          nameElement.addTextNode(“Star chu”);
          }
          }
          ·編輯config.xml文件
          <?xml version=”1.0” encoding=”UTF-8”?>
          <configuration xmlns=”http://java.sun.com/xml/ns/jax-rpc/ri/config”?>
          <wsdl location=”http://localhost:8080/handlerWS/handler?WSDL
          packageName=”client”>
          <handlerChains>
          <chain runAt=”client”>
          <handler className=”client.ClientHandler”>
          <property name=”name” value=”client handler”/>
          </handler>
          </chain>
          </handlerChains></wsdl></configuration>
          ·編寫靜態(tài)客戶
          C.建立服務(wù)端處理器
          ·編寫服務(wù)端處理器(與客戶端結(jié)構(gòu)類似)
          Public boolean handleRequest(MessageContext context){
          SOAPMessageContext smc=(SOAPMessageContext)context;
          ……
          Iterator it=header.examineAllHeaderElements();
          While(it.hasNext()){
          SOAPElement element=(SOAPElement)it.next();
          If(element name is loginfo and must understand it){
          element.getValue();
          element.detach();
          file://Invoke only when the setMustUnderstand(true)
          }
          }
          }
          detach方法用來移除元素,這個(gè)需求僅當(dāng)一個(gè)元素設(shè)置了mustUnderstand屬性在必要。
          ·編輯jaxrpc-ri.xml文件
          <?xml version=”1.0” encoding=”UTF-8”?>
          <webServices xmlns=”http://java.sun.com/jax-rpc/config/ri/dd”
          version=”1.0”
          targetNamespaceBase=”urn:Star:wsdl”
          typeNamespaceBase=”urn:Star:types”
          urlPatternBase=”/handler”>
          <endpoint name=”HandlerTest”
          displayName=”Handler Test”
          description=” … …”
          interface=”service.HandlerTest”
          model=”/WEB-INF/model.gz”
          implementation=”service.HandlerTestImpl”>
          <handlerChains>
          <chain runAt=”server”>
          <handler className=”service.LoggerHandler”
          headers=”ns1:loginfo”
          xmlns:ns1=”urn:Star:headerprops”>
          <property name=”name” value=”Logger”/>
          </handler>
          <handler className=”service.NameHandler”>
          <propery name=”name” value=”Name”/>
          </handler>
          </chain>
          </handlerChains>
          </endpoint>
          <endpointMapping endpointName=”HandlerTest”
          urlPattern=”/handler”/>
          </webServices>
          在第一個(gè)處理器中,XML使用了屬性 headers描述頭信息。這是因?yàn)榭蛻舸a告訴服務(wù)端,logger頭必須被理解,否則客戶將收到SOAP錯(cuò)誤消息
          ·生成WAR文件并部署到服務(wù)器上
          4.源代碼
          ·HelloIF.java(endpoint接口)
          package helloservice;

          import java.rmi.RemoteException;
          import java.rmi.Remote;

          public interface HelloIF extends Remote{
          public String sayHello(String target) throws RemoteException;
          }
          ·HelloImpl.java
          package helloservice;

          public class HelloImpl implements HelloIF{
          private String message="Hello";
          public String sayHello(String target){
          return message+target;
          }
          }
          ·StaticClient.java
          package staticstub;
          import javax.xml.rpc.Stub;
          public class StaticClient{
          private static String endpointAddress;
          public static void main(String [] args){
          if(args.length!=1){
          System.err.println("Usage : java HelloClient [endpoint address]");
          System.exit(-1);
          }
          endpointAddress=args[0];
          System.out.println("Connect to :"+endpointAddress);
          try{
          Stub stub=createStub();
          stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
          endpointAddress);
          HelloIF hello=(HelloIF)stub;
          System.out.println(hello.sayHello(" Starchu!"));
          }catch(Exception e){System.err.println(e.toString());}
          }
          private static Stub createStub(){
          return (Stub)(new HelloService_Impl().getHelloIFPort());
          }
          }
          ·DynamicClient.java
          package dynamicproxy;
          import java.net.URL;
          import javax.xml.namespace.QName;
          import javax.xml.rpc.Service;
          import javax.xml.rpc.ServiceFactory;
          import javax.xml.rpc.JAXRPCException;
          import staticstub.HelloIF;

          public class DynamicClient{
          private static String wsdl;
          private static String namespaceUri="urn:Star:wsdl";
          private static String serviceName="HandlerService";
          private static String portName="HandlerTestPort";

          public static void main(String [] args){
          if(args.length!=1){
          System.err.println("Usage : java DynamicClient [server Url]");
          System.exit(-1);
          }
          System.out.println("Connect to :"+args[0]);
          helloWsdl=args[0]+"?WSDL";
          try{
          URL wsdlUrl=new URL(wsdl);
          ServiceFactory serviceFactory=ServiceFactory.newInstance();
          Service service=
          serviceFactory.createService(wsdlUrl,
          new QName(namespaceUri,serviceName));
          HandlerTest proxy=(HandlerTest)service.getPort(
          new QName(namespaceUri,portName),HandlerTest.class);
          proxy.test();
          }catch(Exception e){
          System.err.println(e.toString());
          }
          }
          }
          ·DIIClient.java
          package dii;
          import javax.xml.rpc.*;
          import javax.xml.namespace.*;

          public class DIIClient{
          private static String qnameService = "HelloService";
          private static String qnamePort = "HelloIF";
          private static String BODY_NAMESPACE_VALUE ="urn:Star";
          private static String ENCODING_STYLE_PROPERTY ="javax.xml.rpc.encodingstyle.namespace.uri";
          private static String NS_XSD ="http://www.w3.org/2001/XMLSchema";
          private static String URI_ENCODING ="http://schemas.xmlsoap.org/soap/encoding/";

          public static void main(String [] args){
          try{

          ServiceFactory factory=ServiceFactory.newInstance();
          Service service=factory.createService(new QName(qnameService));
          QName port=new QName(qnamePort);
          Call call=service.createCall(port);
          call.setTargetEndpointAddress(args[0]);
          call.setProperty(Call.SOAPACTION_USE_PROPERTY,new Boolean(true));
          call.setProperty(Call.SOAPACTION_URI_PROPERTY,"");
          call.setProperty(ENCODING_STYLE_PROPERTY,URI_ENCODING);
          QName qnameTypeString=new QName(NS_XSD,"string");
          call.setReturnType(qnameTypeString);
          call.setOperationName(new QName(BODY_NAMESPACE_VALUE,"sayHello"));
          call.addParameter("String_1",qnameTypeString,ParameterMode.IN);
          String [] params = { "Starchu" };
          System.out.println((String)call.invoke(params));
          }catch(Exception e){
          System.err.println(e.toString());
          }
          }
          }
          ·Ant文件build.xml
          <project name="helloWS" basedir="." default="deploy">
          <property file="build.properties"/>
          <property name="build" value="build"/>
          <property name="dist" value="${build}\classes"/>
          <property name="lib" value="${build}\lib"/>
          <property name="src" value="src"/>
          <property name="etc" value="${src}\etc"/>

          <target name="clean">
          <delete dir="${build}"/>
          </target>

          <target name="init">
          <mkdir dir="${build}"/>
          <mkdir dir="${dist}"/>
          <mkdir dir="${lib}"/>
          </target>

          <path id="classpath">
          <fileset dir="${tomcat.home}">
          <include name="jaxrpc/**/*.jar"/>
          <include name="jaxb/**/*.jar"/>
          <include name="jaxp/**/*.jar"/>
          <include name="saaj/**/*.jar"/>
          <include name="jwsdp-shared/lib/**/*.jar"/>
          </fileset>
          <pathelement path="${dist}"/>
          <pathelement location="${lib}"/>
          </path>

          <target name="compile-service" depends="init">
          <javac srcdir="${src}" destdir="${dist}" includes="HelloService/**/*.java"/>
          </target>

          <target name="generate-sei-service" depends="compile-service">
          <exec executable="wscompile.bat">
          <arg line="-define -d ${build} -nd ${build} -classpath ${dist} ${etc}\config-interface.xml -model ${build}\model.gz"/>
          </exec>
          <copy todir="${build}">
          <fileset dir="${etc}" includes="*.xml"/>
          </copy>
          </target>

          <target name="package-service" depends="generate-sei-service">
          <war warfile="${build}\${ant.project.name}-portable.war"
          webxml="${build}\web.xml">
          <webinf dir="${build}" includes="*.xml,*.gz,*.wsdl" excludes="web.xml"/>
          <classes dir="${dist}" includes="**/*.class" defaultexcludes="no"/>
          </war>
          </target>

          <target name="process-war" depends="package-service">
          <exec executable="wsdeploy.bat">
          <arg line="-o ${ant.project.name}.war ${build}\${ant.project.name}-portable.war"/>
          </exec>
          </target>

          <target name="deploy">
          <copy file="${ant.project.name}.war" todir="${server}"/>
          </target>

          <target name="undeploy">
          <delete file="${server}\${ant.project.name}.war"/>
          </target>

          <!-- Generating Static Client -->
          <target name="generate-stubs" depends="init">
          <exec executable="wscompile.bat">
          <arg line="-gen:client -d ${dist} -classpath ${dist} ${etc}\config-wsdl.xml"/>
          </exec>
          </target>

          <target name="compile-client" depends="generate-stubs">
          <javac srcdir="${src}" destdir="${dist}" includes="StaticStub/**/*.java">
          <classpath refid="classpath"/>
          </javac>
          </target>

          <target name="package-client" depends="compile-client">
          <jar destfile="${lib}\client.jar" basedir="${dist}" excludes="HelloService/**/*.class"/>
          </target>

          <target name="run-client" depends="package-client">
          <java classname="staticstub.HelloClient"
          classpathref="classpath"
          fork="true">
          <sysproperty key="endpoint" value="${endpoint}"/>
          <arg value="${server.port.url}"/>
          </java>
          </target>

          <!-- Generating Dynamic Client -->
          <target name="generate-interface" depends="init">
          <exec executable="wscompile.bat">
          <arg line="-import -d ${dist} -classpath ${dist} ${etc}\config-wsdl.xml"/>
          </exec>
          </target>

          <target name="compile-dynamic-client" depends="generate-interface">
          <javac srcdir="${src}" destdir="${dist}" includes="DynamicProxy/**/*.java">
          <classpath refid="classpath"/>
          </javac>
          </target>

          <target name="package-dynamic-client" depends="compile-dynamic-client">
          <jar destfile="${lib}\client.jar" basedir="${dist}" includes="**/HelloIF.class,**/DynamicClient.class"/>
          </target>

          <target name="run-dynamic-client" depends="package-dynamic-client">
          <java classname="dynamicproxy.DynamicClient"
          classpathref="classpath"
          fork="true">
          <sysproperty key="endpoint" value="${endpoint}"/>
          <arg value="${server.port.url}"/>
          </java>
          </target>

          <!-- Generating Dynamic Invocation Interface -->

          <target name="compile-dii">
          <javac srcdir="${src}" destdir="${dist}" includes="DII/**/*.java">
          <classpath refid="classpath"/>
          </javac>
          </target>

          <target name="run-dii" depends="compile-dii">
          <java classname="dii.DIIClient"
          classpathref="classpath"
          fork="true">
          <sysproperty key="endpoint" value="${endpoint}"/>
          <arg value="${server.port.url}"/>
          </java>
          </target>

          </project>
          ·屬性文件(build.xml文件使用)
          server=C:/Java/jwsdp-1.2/webapps
          tomcat.home=C:/Java/jwsdp-1.2
          endpoint=http://localhost:8080/helloWS/hello
          server.port.url=http://localhost:8080/helloWS/hello

          參考資料
          1. Developing Web Service Series <http://www.theserverside.com/resources/article.jsp?l=Systinet-web-services-part-1> www.theserverside.com
          2. JWSDP-1.2 Tutorial java.sun.com

          posted on 2007-05-18 15:24 鴻雁 閱讀(748) 評論(0)  編輯  收藏 所屬分類: IT技術(shù)相關(guān)

          主站蜘蛛池模板: 钟山县| 淳安县| 莱芜市| 海城市| 乐昌市| 青海省| 北海市| 宁夏| 龙里县| 团风县| 咸阳市| 星座| 海安县| 明溪县| 明水县| 九江市| 清流县| 抚州市| 木兰县| 宣化县| 昭苏县| 高邑县| 花莲县| 兴仁县| 丹棱县| 乐陵市| 柳州市| 伊春市| 天水市| 安化县| 仪征市| 修文县| 昌邑市| 乌鲁木齐县| 高阳县| 苍南县| 大新县| 嵩明县| 岳普湖县| 鄂托克前旗| 康马县|