隨筆-159  評論-114  文章-7  trackbacks-0

          1.?? WebService 開發

          1.1. 開發 JavaBean 封裝的 WebService

          1.1.1.??? Java

          /*

          ?* 創建日期 2006-7-13

          ?*

          ?* TODO 要更改此生成的文件的模板,請轉至

          ?* 窗口 首選項 Java 代碼樣式 代碼模板

          ?*/

          package com.ibm.localjava;

          ?

          import com.ibm.localjava.data.FolderObject;

          ?

          /**

          ?* @author Flyiky

          ?*

          ?* TODO 要更改此生成的類型注釋的模板,請轉至

          ?* 窗口 首選項 Java 代碼樣式 代碼模板

          ?*/

          public class DimensionCao {

          ??????

          ?????? public FolderObject getSingleFolder(int level)

          ?????? {

          ????????????? FolderObject obj = new FolderObject();

          ????????????? obj.setLevel(level);

          ????????????? return obj;

          ?????? }

          ??????

          ?????? public FolderObject[] getMultiFolder(int multilevel)

          ?????? {

          ????????????? FolderObject obj1 = new FolderObject();

          ????????????? obj1.setLevel(multilevel);

          ????????????? FolderObject obj2 = new FolderObject();

          ????????????? obj2.setLevel(multilevel-1);

          ????????????? FolderObject[] objArry = new FolderObject[2];

          ????????????? objArry[0] = obj1;

          ????????????? objArry[1] = obj2;

          ????????????? return objArry;

          ?????? }

          ?

          }

          ?

          自定義類

          ?

          package com.ibm.localjava.data;

          ?

          public class FolderObject implements java.io.Serializable {

          ?

          ??? private String objectName = null;?? //the name of the folder

          ??? private String objectId = null;??? //r_object_id of the folder

          ??? private String parentId = null;??? //the r_object_id of its parent folder

          ??? private String fullPath = null;??? //fullpath of the folder,e.g. /test/test1103

          ??? private int level = 0;?

          ???

          ??? /**

          ???? * @return Returns the fullPath.

          ???? */

          ??? public String getFullPath() {

          ??????? return fullPath;

          ??? }

          ??? /**

          ???? * @param fullPath The fullPath to set.

          ???? */

          ??? public void setFullPath(String fullPath) {

          ??????? this.fullPath = fullPath;

          ??? }

          ??? /**

          ???? * @return Returns the level.

          ???? */

          ??? public int getLevel() {

          ??????? return level;

          ??? }

          ??? /**

          ???? * @param level The level to set.

          ???? */

          ??? public void setLevel(int level) {

          ??????? this.level = level;

          ??? }

          ??? /**

          ???? * @return Returns the objectId.

          ???? */

          ??? public String getObjectId() {

          ??????? return objectId;

          ??? }

          ??? /**

          ???? * @param objectId The objectId to set.

          ???? */

          ??? public void setObjectId(String objectId) {

          ??????? this.objectId = objectId;

          ??? }

          ??? /**

          ???? * @return Returns the objectName.

          ???? */

          ??? public String getObjectName() {

          ??????? return objectName;

          ??? }

          ??? /**

          ???? * @param objectName The objectName to set.

          ???? */

          ??? public void setObjectName(String objectName) {

          ??????? this.objectName = objectName;

          ??? }

          ??? /**

          ???? * @return Returns the parentId.

          ???? */

          ??? public String getParentId() {

          ??????? return parentId;

          ??? }

          ??? /**

          ???? * @param parentId The parentId to set.

          ???? */

          ??? public void setParentId(String parentId) {

          ??????? this.parentId = parentId;

          ??? }

          ?

          }

          1.1.2.??? 使用 RSA 生成接入點代碼和 WSDL

          image001.png

          ?

          ?

          image004.png

          ?

          image006.png

          ?

          image008.png

          1.1.3.??? WSDL 分析

          預先需要了解 WSDL 通用結構,看看電子書。

          image010.png

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

          <wsdl:definitions targetNamespace="http://localjava.ibm.com" xmlns:impl="http://localjava.ibm.com" xmlns:intf="http://localjava.ibm.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns2="http://data.localjava.ibm.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

          ?<wsdl:types>

          ? <schema targetNamespace="http://localjava.ibm.com" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://localjava.ibm.com" xmlns:intf="http://localjava.ibm.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns2="http://data.localjava.ibm.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

          ?? <import namespace="http://data.localjava.ibm.com"/>

          ?? <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

          ?? <element name="level" type="xsd:int"/>

          ?? <element name="multilevel" type="xsd:int"/>

          ?? <complexType name="ArrayOf_tns2_FolderObject">

          ??? <complexContent>

          ???? <restriction base="soapenc:Array">

          ????? <attribute ref="soapenc:arrayType" wsdl:arrayType="tns2:FolderObject[]"/>

          ???? </restriction>

          ??? </complexContent>

          ?? </complexType>

          ?? <element name="ArrayOf_tns2_FolderObject" nillable="true" type="impl:ArrayOf_tns2_FolderObject"/>

          ? </schema>

          ? <schema targetNamespace="http://data.localjava.ibm.com" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://localjava.ibm.com" xmlns:intf="http://localjava.ibm.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

          ?? <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

          ?? <complexType name="FolderObject">

          ??? <sequence>

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

          ???? <element name="level" type="xsd:int"/>

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

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

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

          ??? </sequence>

          ?? </complexType>

          ?? <element name="FolderObject" nillable="true" type="tns2:FolderObject"/>

          ? </schema>

          ?</wsdl:types>

          ?

          ?? <wsdl:message name="getMultiFolderRequest">

          ?

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

          ?

          ?? </wsdl:message>

          ?

          ?? <wsdl:message name="getMultiFolderResponse">

          ?

          ????? <wsdl:part name="getMultiFolderReturn" type="impl:ArrayOf_tns2_FolderObject"/>

          ?

          ?? </wsdl:message>

          ?

          ?? <wsdl:message name="getSingleFolderResponse">

          ?

          ????? <wsdl:part name="getSingleFolderReturn" type="tns2:FolderObject"/>

          ?

          ?? </wsdl:message>

          ?

          ?? <wsdl:message name="getSingleFolderRequest">

          ?

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

          ?

          ?? </wsdl:message>

          ?

          ?? <wsdl:portType name="DimensionCao">

          ?

          ????? <wsdl:operation name="getSingleFolder" parameterOrder="level">

          ?

          ???????? <wsdl:input message="impl:getSingleFolderRequest" name="getSingleFolderRequest"/>

          ?

          ???????? <wsdl:output message="impl:getSingleFolderResponse" name="getSingleFolderResponse"/>

          ?

          ????? </wsdl:operation>

          ?

          ????? <wsdl:operation name="getMultiFolder" parameterOrder="multilevel">

          ?

          ???????? <wsdl:input message="impl:getMultiFolderRequest" name="getMultiFolderRequest"/>

          ?

          ???????? <wsdl:output message="impl:getMultiFolderResponse" name="getMultiFolderResponse"/>

          ?

          ????? </wsdl:operation>

          ?

          ?? </wsdl:portType>

          ?

          ?? <wsdl:binding name="DimensionCaoSoapBinding" type="impl:DimensionCao">

          ?

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

          ?

          ????? <wsdl:operation name="getSingleFolder">

          ?

          ???????? <wsdlsoap:operation soapAction=""/>

          ?

          ???????? <wsdl:input name="getSingleFolderRequest">

          ?

          ??????????? <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localjava.ibm.com" use="encoded"/>

          ?

          ???????? </wsdl:input>

          ?

          ???????? <wsdl:output name="getSingleFolderResponse">

          ?

          ??????????? <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localjava.ibm.com" use="encoded"/>

          ?

          ???????? </wsdl:output>

          ?

          ????? </wsdl:operation>

          ?

          ????? <wsdl:operation name="getMultiFolder">

          ?

          ???????? <wsdlsoap:operation soapAction=""/>

          ?

          ???????? <wsdl:input name="getMultiFolderRequest">

          ?

          ??????????? <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localjava.ibm.com" use="encoded"/>

          ?

          ???????? </wsdl:input>

          ?

          ???????? <wsdl:output name="getMultiFolderResponse">

          ?

          ??????????? <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localjava.ibm.com" use="encoded"/>

          ?

          ???????? </wsdl:output>

          ?

          ????? </wsdl:operation>

          ?

          ?? </wsdl:binding>

          ?

          ?? <wsdl:service name="DimensionCaoService">

          ?

          ????? <wsdl:port binding="impl:DimensionCaoSoapBinding" name="DimensionCao">

          ?

          ???????? <wsdlsoap:address location="http://localhost:9080/AddressWeb/services/DimensionCao"/>

          ?

          ????? </wsdl:port>

          ?

          ?? </wsdl:service>

          ?

          </wsdl:definitions>

          targetNameSpace 是個命名空間。

          ?

          wsdl:address wsdl 的位置

          ?

          getSingleFolder 是一個方法的名稱

          ?

          ?? 該方法的參數

          ?? <wsdl:message name="getSingleFolderRequest">

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

          ?? </wsdl:message>

          ??

          該方法的返回值

          ?? <wsdl:message name="getSingleFolderResponse">

          ????? <wsdl:part name="getSingleFolderReturn" type="tns2:FolderObject"/>

          ?? </wsdl:message>

          ??

          1.2. WebService 客戶端的開發

          wsif-all-2.0

          ?

          http://mirror.vmmatrix.net/apache/ws/wsif/2_0/

          ?

          編譯環境中所需要的 jar 文件基本都包含了

          ?

          還差一個 activation.jar mail.jar ,自己找一下,哪都有。

          ?

          建立一個 Java Application 程序。

          ?

          添加 jar 文件。

          image012.png

          1.2.1.??? 拷貝所有自定義類型的類文件到工程中

          package com.ibm.localjava.data;

          ?

          public class FolderObject implements java.io.Serializable {

          ?

          ??? private String objectName = null;?? //the name of the folder

          ??? private String objectId = null;??? //r_object_id of the folder

          ??? private String parentId = null;??? //the r_object_id of its parent folder

          ??? private String fullPath = null;??? //fullpath of the folder,e.g. /test/test1103

          ??? private int level = 0;?

          ???

          ??? /**

          ???? * @return Returns the fullPath.

          ???? */

          ??? public String getFullPath() {

          ??????? return fullPath;

          ??? }

          ??? /**

          ???? * @param fullPath The fullPath to set.

          ???? */

          ??? public void setFullPath(String fullPath) {

          ??????? this.fullPath = fullPath;

          ??? }

          ??? /**

          ???? * @return Returns the level.

          ???? */

          ??? public int getLevel() {

          ??????? return level;

          ??? }

          ??? /**

          ???? * @param level The level to set.

          ???? */

          ??? public void setLevel(int level) {

          ??????? this.level = level;

          ??? }

          ??? /**

          ???? * @return Returns the objectId.

          ???? */

          ??? public String getObjectId() {

          ??????? return objectId;

          ??? }

          ??? /**

          ???? * @param objectId The objectId to set.

          ???? */

          ??? public void setObjectId(String objectId) {

          ??????? this.objectId = objectId;

          ??? }

          ??? /**

          ???? * @return Returns the objectName.

          ???? */

          ??? public String getObjectName() {

          ??????? return objectName;

          ??? }

          ??? /**

          ???? * @param objectName The objectName to set.

          ???? */

          ??? public void setObjectName(String objectName) {

          ??????? this.objectName = objectName;

          ??? }

          ??? /**

          ???? * @return Returns the parentId.

          ???? */

          ??? public String getParentId() {

          ??????? return parentId;

          ??? }

          ??? /**

          ???? * @param parentId The parentId to set.

          ???? */

          ??? public void setParentId(String parentId) {

          ??????? this.parentId = parentId;

          ??? }

          ?

          }

          ?

          /*

          ?* 創建日期 2006-7-13

          ?*

          ?* TODO 要更改此生成的文件的模板,請轉至

          ?* 窗口 首選項 Java 代碼樣式 代碼模板

          ?*/

          package com.address.client;

          ?

          import javax.xml.namespace.QName;

          ?

          import org.apache.wsif.WSIFMessage;

          import org.apache.wsif.WSIFOperation;

          import org.apache.wsif.WSIFPort;

          import org.apache.wsif.WSIFService;

          import org.apache.wsif.WSIFServiceFactory;

          ?

          import com.ibm.localjava.data.FolderObject;

          ?

          /**

          ?* @author Flyiky

          ?*

          ?* TODO 要更改此生成的類型注釋的模板,請轉至

          ?* 窗口 首選項 Java 代碼樣式 代碼模板

          ?*/

          public class TestClient {

          ??????

          ?????? public static void main(String[] args) throws Exception

          ?????? {

          //??????????? WSIFServiceFactory factory = WSIFServiceFactory.newInstance();

          //??????????? WSIFService service = factory.getService("http://localhost:9080/AddressWeb/services/DimensionCao?wsdl",null,null,"http://localjava.ibm.com","DimensionCao");

          //??????????? service.mapType(

          //???? ??????????? new QName("http://data.localjava.ibm.com", "FolderObject"),

          //???? ??????????? Class.forName("com.ibm.localjava.data.FolderObject"));

          //??????????? WSIFPort port = service.getPort();

          //???????????

          //??????????? getAFolderObj(port);

          ?????????????

          ????????????? WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); [f1] ?

          ????????????? WSIFService service = factory.getService("http://localhost:9080/AddressWeb/services/DimensionCao?wsdl",null,null,"http://localjava.ibm.com","DimensionCao"); [f2] ?

          ?????????????

          ????????????? service.mapType(

          ?????? ??????????? new QName("http://data.localjava.ibm.com", "FolderObject"),

          ?????? ??????????? Class.forName("com.ibm.localjava.data.FolderObject")); [f3] ?

          ?????????????

          ????????????? WSIFPort port = service.getPort(); [f4] ?

          ?????????????

          ????????????? getMFolder(port);

          ?????????????

          ?????? }

          ??????

          ?????? private static void getMFolder(WSIFPort port) throws Exception

          ?????? {

          ????????????? WSIFOperation operation = port.createOperation("getMultiFolder"); [f5] ?

          ????????????? WSIFMessage input = operation.createInputMessage();

          ??????? WSIFMessage output = operation.createOutputMessage();

          ??????? WSIFMessage fault = operation.createFaultMessage();

          [f6] ? ??????? input.setIntPart("multilevel", 5);

          ??????? if (operation.executeRequestResponseOperation(input, output, fault) [f7] ? ) {

          ??????????? // invocation succeeded

          ??????????? // extract the address from the output message

          ??????????? FolderObject[] folderObj = (FolderObject[]) output.getObjectPart("getMultiFolderReturn"); [f8] ?

          ??????????? System.out.println("Service returned FolderS:");

          ??????????? System.out.println(folderObj[0].getLevel());

          ??????? } else {

          ??????????? // invocation failed, check fault message

          ??????? }

          ?????? }

          ??????

          ?????? private static void getAFolderObj(WSIFPort port) throws Exception

          ?????? {

          ????????????? WSIFOperation operation = port.createOperation("getSingleFolder");

          ????????????? WSIFMessage input = operation.createInputMessage();

          ????? ??WSIFMessage output = operation.createOutputMessage();

          ??????? WSIFMessage fault = operation.createFaultMessage();

          ??????? input.setIntPart("level", 4);

          ??????? if (operation.executeRequestResponseOperation(input, output, fault)) {

          ??????????? // invocation succeeded

          ??????????? // extract the address from the output message

          ??????????? FolderObject folderObj = (FolderObject) output.getObjectPart("getSingleFolderReturn");

          ??????????? System.out.println("Service returned Folder:");

          ??????????? System.out.println(folderObj.getLevel());

          ??????? } else {

          ??????????? // invocation failed, check fault message

          ??????? }

          ?????? }

          ?

          }

          ?

          1.3. 部署 WebService

          注意:任何一次 WebService 的生成和部署,請保證服務器在開啟狀態,避免不必要的麻煩。

          image014.png

          ?

          image016.png

          ?

          測試一下

          ?

          http://localhost:9080/AddressWeb/services/DimensionCao?wsdl

          ?

          注意:如果修改了服務類的接口,需要重新生成 webservice ,如果修改了服務類的內部行為,直接發布一下即可。

          ?

          ?

          ?

          2.?? DataHandler 問題

          由于使用 DataHandler 類處理大附件,對于客戶端來說,如果使用自動生成工具生成代碼,肯定會與平臺,至少與應用服務器提供的 API 依賴。所以必須使用 WebService Invoke Framework Wsif 接口。

          2.1. 服務代碼的開發

          任何 WebService 都是以一個動態 web 應用為基礎。

          ?

          /*

          ?* 創建日期 2006-7-13

          ?*

          ?* TODO 要更改此生成的文件的模板,請轉至

          ?* 窗口 首選項 Java 代碼樣式 代碼模板

          ?*/

          package com.test;

          ?

          import java.io.BufferedInputStream;

          import java.io.BufferedOutputStream;

          import java.io.FileOutputStream;

          import java.util.Date;

          ?

          import javax.activation.DataHandler;

          ?

          /**

          ?* @author Flyiky

          ?*

          ?* TODO 要更改此生成的類型注釋的模板,請轉至

          ?* 窗口 首選項 Java 代碼樣式 代碼模板

          ?*/

          public class TestFileTransform {

          ??????

          ?????? public String storeDocumentService(DataHandler dh) {

          ????????????? try {

          ???????????????????? BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("D:\\abc"));

          ???????????????????? BufferedInputStream in = new BufferedInputStream(dh???? .getInputStream());

          ?

          ???????????????????? byte[] buffer = new byte[256];

          ???????????????????? while (true) {

          ??????????????????????????? int bytesRead = in.read(buffer);

          ??????????????????????????? if (bytesRead == -1)

          ?????????????????????????????????? break;

          ??????????????????????????? out.write(buffer, 0, bytesRead);

          ???????????????????? }

          ???????????????????? in.close();

          ???????????????????? out.close();

          ????????????? } catch (Exception e) {

          ???????????????????? System.out.println(e);

          ???????????????????? return e.toString();

          ????????????? }

          ????????????? return ("File processes succesfully " + new Date());

          ?????? }

          ?

          }

          ?

          2.2. WSDL 文件

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

          <wsdl:definitions targetNamespace="http://test.com" xmlns:impl="http://test.com" xmlns:intf="http://test.com" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

          ?<wsdl:types>

          ? <schema targetNamespace="http://test.com" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://test.com" xmlns:intf="http://test.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

          ?? <import namespace="http://ws-i.org/profiles/basic/1.1/xsd"/>

          ?? <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

          ?? <element name="dh" nillable="true" type="wsi:swaRef"/>

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

          ? </schema>

          ?</wsdl:types>

          ?

          ?? <wsdl:message name="storeDocumentServiceResponse">

          ?

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

          ?

          ?? </wsdl:message>

          ?

          ?? <wsdl:message name="storeDocumentServiceRequest">

          ?

          ????? <wsdl:part name="dh" type="wsi:swaRef"/>

          ?

          ?? </wsdl:message>

          ?

          ?? <wsdl:portType name="TestFileTransform">

          ?

          ????? <wsdl:operation name="storeDocumentService" parameterOrder="dh">

          ?

          ???????? <wsdl:input message="impl:storeDocumentServiceRequest" name="storeDocumentServiceRequest"/>

          ?

          ???????? <wsdl:output message="impl:storeDocumentServiceResponse" name="storeDocumentServiceResponse"/>

          ?

          ????? </wsdl:operation>

          ?

          ?? </wsdl:portType>

          ?

          ?? <wsdl:binding name="TestFileTransformSoapBinding" type="impl:TestFileTransform">

          ?

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

          ?

          ????? <wsdl:operation name="storeDocumentService">

          ?

          ???????? <wsdlsoap:operation soapAction=""/>

          ?

          ???????? <wsdl:input name="storeDocumentServiceRequest">

          ?

          ??????????? <mime:multipartRelated>

          ?

          ?????????????? <mime:part>

          ?

          ????????????????? <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://test.com" use="encoded"/>

          ?

          ?????????????? </mime:part>

          ?

          ?????????????? <mime:part>

          ?

          ????????????????? <mime:content part="dh" type="application/octetstream"/>

          ?

          ?????????????? </mime:part>

          ?

          ??????????? </mime:multipartRelated>

          ?

          ???????? </wsdl:input>

          ?

          ???????? <wsdl:output name="storeDocumentServiceResponse">

          ?

          ??????????? <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://test.com" use="encoded"/>

          ?

          ???????? </wsdl:output>

          ?

          ????? </wsdl:operation>

          ?

          ?? </wsdl:binding>

          ?

          ?? <wsdl:service name="TestFileTransformService">

          ?

          ????? <wsdl:port binding="impl:TestFileTransformSoapBinding" name="TestFileTransform">

          ?

          ???????? <wsdlsoap:address location="http://localhost:9080/FileTransform/services/TestFileTransform"/>

          ?

          ????? </wsdl:port>

          ?

          ?? </wsdl:service>

          ?

          </wsdl:definitions>

          2.3. 客戶端編寫

          /*

          ?* 創建日期 2006-7-13

          ?*

          ?* TODO 要更改此生成的文件的模板,請轉至

          ?* 窗口 首選項 Java 代碼樣式 代碼模板

          ?*/

          package com.testabc;

          ?

          import javax.activation.DataHandler;

          import javax.activation.FileDataSource;

          ?

          import org.apache.wsif.WSIFMessage;

          import org.apache.wsif.WSIFOperation;

          import org.apache.wsif.WSIFService;

          import org.apache.wsif.WSIFServiceFactory;

          ?

          /**

          ?* @author Flyiky

          ?*

          ?* TODO 要更改此生成的類型注釋的模板,請轉至

          ?* 窗口 首選項 Java 代碼樣式 代碼模板

          ?*/

          public class TestClient {

          ??????

          ?????? public static void main(String[] args) throws Exception

          ?????? {

          ????????????? DataHandler dh = new DataHandler(new FileDataSource("C:\\DocumentumServiceImpl.wsdl"));

          ????????????? WSIFServiceFactory factory = WSIFServiceFactory.newInstance();

          ????????????? WSIFService service = factory.getService("D:\\TestFileTransform.wsdl",null,null,"http://test.com","TestFileTransform"); [f9] ?

          ????????????? WSIFOperation op = service.getPort().createOperation("storeDocumentService");

          ????????????? WSIFMessage input = op.createInputMessage();

          ????????????? WSIFMessage output = op.createOutputMessage();

          ????????????? WSIFMessage fault = op.createFaultMessage();

          ????????????? input.setObjectPart("dh",dh);

          ????????????? if(op.executeRequestResponseOperation(input,output,fault)){

          ????????????????????

          ???????????????????? // 調用成功,從返回信息中獲取我們需要的信息

          ????????????????????

          ???????????????????? String returninfo = (String)output.getObjectPart("storeDocumentServiceReturn");

          ???????????????????? System.out.println(returninfo);

          ????????????????????

          ????????????? } else {

          ???????????????????? System.out.println("Invocation failed");??????????????

          ????????????? }

          ?????????????

          ?????? }

          ?

          }

          3.?? 附加信息

          ?

          如果有問題,請發郵件給 lhulcn618@gmail.com

          ?



          posted on 2006-10-27 11:56 北國狼人的BloG 閱讀(2624) 評論(0)  編輯  收藏 所屬分類: 原創

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 苗栗市| 梅州市| 洛川县| 辽中县| 岑溪市| 四子王旗| 厦门市| 马山县| 田东县| 孟州市| 泰来县| 阿拉善右旗| 靖边县| 信宜市| 胶南市| 彰武县| 嵩明县| 绍兴县| 裕民县| 郎溪县| 景泰县| 宜丰县| 布拖县| 阿拉善左旗| 滦平县| 古田县| 青神县| 抚宁县| 平定县| 翁牛特旗| 宜城市| 那坡县| 北碚区| 徐闻县| 布拖县| 阳新县| 额济纳旗| 迁西县| 邻水| 赣州市| 临安市|