熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

Java WS和C#調用

2022-06-13   來源: Java核心技術 

  互操作性是Web Service的真正優勢雖然關於WS標准有很多但不同廠家都是自己的實現不同實現之間的互操作性因此很差於是有了WSI組織成立來管理這種差異並提供統一的互操作性規范到目前為止這些工作仍在進行中不過成果早已經有了:WSI Attachment Profile 並且也已經在Sun提供的WS設施上有了體現通過使用wscompile 工具中的選項 f wsi 即可生成兼容WSI規范的java制品
  
  文件清單:
  
  SEI接口類IImagejava實現SEI接口的類IIMageImpljava描述文件信息的值類型類FileInfojavaWeb應用部署描述文件webxmlWS發布配置文件jaxrpcrixmlWS編譯配置文件configinterfacexml構建客戶端樁的configwsdlxml構建文件builderxml
  
  客戶端測試類:Formcs
  
  本例是從WSDL開始的因此我們要有一個WSDL文件第一步就是得到這個文件
  
  (一) 得到WSDL文件
  
  為達到互操作要求這個文件的描述必須是文檔樣式的綁定文字格式的編碼為得到此文件首先介紹構建文件builderxml:
  
  <?xml version= encoding=GBK?>
  <project name=webservice default=build basedir=>
  <property name=jaxrpclibdir value=I:\jwsdp\jaxrpc\lib>
  </property>
  <property name=jaxrpclibdir value=D:\Sun\AppServer\lib>
  </property>
  <property name=classesdir value=\build\classes>
  </property>
  <property name=srcdir value=\build\src>
  </property>
  <property name=rawwarfile value=netservicerawwar>
  </property>
  <property name=cookwarfile value=netservicewar>
  </property>
  <property name=nonclassdir value=\build\nonclass>
  </property>
  <property name=build value=${nonclassdir}>
  </property>
  <property name=assemble value=\assemble>
  </property>
  <property name=assemblewar value=\assemble\war>
  </property>
  <property name=assembleear value=\assemble\ear>
  </property>
  <property name=wsidir value=\wsi>
  </property>
  <property name=wsiserverdir value=\wsi\server>
  </property>
  <property name=wsiclientdir value=\wsi\client>
  </property>
  <property name=tmpdir value=\tmp>
  </property>
  
  <path id=jaxrpcclasspath>
  <fileset dir=${jaxrpclibdir}>
  <include name=**/*jar />
  </fileset>
  <fileset dir=D:\jdbc\postgresql>
  <include name=*jar />
  </fileset>
  </path>
  <path id=compileclasspath>
  <fileset dir=${jaxrpclibdir}>
  <include name=**/*jar />
  </fileset>
  <fileset dir=D:\jwsdp\jaxrpc\lib>
  <include name=**/*jar />
  </fileset>
  </path>
  
  <path id=jaxrpcclasspath>
  <fileset dir=${jaxrpclibdir}>
  <include name=**/*jar />
  </fileset>
  
  <fileset dir=I:\jwsdp\jwsdpshared\lib>
  <include name=**/*jar />
  </fileset>
  <fileset dir=I:\jwsdp\jaxp\lib>
  <include name=**/*jar />
  </fileset>
  <fileset dir=I:\jwsdp\jaxp\lib\endorsed>
  <include name=**/*jar />
  </fileset>
  <fileset dir=D:\jdbc\postgresql>
  <include name=*jar />
  </fileset>
  </path>
  <path id=compileclasspath>
  <fileset dir=${jaxrpclibdir}>
  <include name=**/*jar />
  </fileset>
  <fileset dir=I:\jwsdp\jaxp\lib>
  <include name=**/*jar />
  </fileset>
  <fileset dir=I:\jwsdp\jaxp\lib\endorsed>
  <include name=**/*jar />
  </fileset>
  <fileset dir=I:\jwsdp\jwsdpshared\lib>
  <include name=**/*jar />
  </fileset>
  <fileset dir=I:\jwsdp\saaj\lib>
  <include name=**/*jar />
  </fileset>
  <fileset dir=H:\jakartatomcat\common\lib>
  <include name=servletapijar />
  </fileset>
  
  </path>
  <taskdef name=wscompile classpat classname=comsunxmlrpctoolsantWscompile>
  </taskdef>
  <taskdef name=wsdeploy classpat classname=comsunxmlrpctoolsantWsdeploy>
  </taskdef>
  <target name=prepare>
  <mkdir dir=${srcdir} />
  <mkdir dir=${nonclassdir} />
  <mkdir dir=${classesdir} />
  <mkdir dir=${assemble} />
  <mkdir dir=${assemblewar} />
  <mkdir dir=${assembleear} />
  <mkdir dir=${wsidir} />
  <mkdir dir=${wsiserverdir} />
  <mkdir dir=${wsiclientdir} />
  <mkdir dir=${tmpdir} />
  </target>
  
  <target name=compileclass depends=prepare>
  <echo message=Compiling the java source code />
  <property name=src value=${src}>
  </property>
  <property name=dest value=${build}>
  </property>
  <echo message=src=${src} build=${dest} />
  <echo message=delete class in dir ${src} />
  <delete>
  <fileset dir=${src}>
  <include name=**/*class />
  <exclude name=exclude />
  </fileset>
  </delete>
  <echo message=recompile java in dir ${src} />
  <javac srcdir=${src} destdir=${dest} includes=**/*java excludes=hhhhhh>
  <classpath refid=compileclasspath />
  </javac>
  </target>
  
  <target name=build depends=prepare description=生成java制品如生成可供wsdeploy使用的web檔案稱為生war就象作菜一樣先順菜以及modelwsdl文件這裡生成的WSDL文件wsdeploy並不使用>
  <echo message=build the WAR />
  <wscompile import=false features=wsidocumentliteral define=true gen=false keep=true base=${classesdir} sourceBase=${srcdir} classpath=\classes nonClassDir=${nonclassdir} model=modelxmlgz xPrintStackTrace=true config=configinterfacexml verbose=true>
  <classpath refid=compileclasspath />
  </wscompile>
  </target>
  
  <target name=deploy depends=prepare description=生成可供發布的web檔案稱為煮熟的war這個階段也生成了WSDL文件並被直接打包了>
  <echo message=deploy the WAR />
  <wsdeploy keep=false verbose=true tmpDir=${tmpdir} outWarFile=${cookwarfile} inWarFile=${rawwarfile}>
  <classpath refid=compileclasspath />
  </wsdeploy>
  </target>
  <target name=createwar description=打包由wscompile生成的制品以及所有發布所用的材料>
  <echo message=buildwar Creating the WAR />
  <antcall target=compileclass>
  <param name=src value=${wsiserverdir} />
  <param name=build value=${wsiserverdir} />
  </antcall>
  <delete file=${assemblewar}/${warfile} />
  <delete dir=${assemblewar}/WEBINF />
  <copy todir=${assemblewar}/WEBINF/classes/>
  <fileset dir=${wsiserverdir} includes=**/*class excludes=**/*Clientclass **/*wsdl **/*mappingxml />
  </copy>
  <copy todir=${assemblewar}/WEBINF/lib/>
  <fileset dir=/lib includes=**/*jar excludes=**/*Clientclass **/*wsdl **/*mappingxml />
  </copy>
  <copy file=\conf\BinaryServicewsdl todir=${assemblewar}/WEBINF />
  <copy file=jaxrpcrixml todir=${assemblewar}/WEBINF />
  <copy file=modelxmlgz todir=${assemblewar}/WEBINF />
  <war destfile=${assemblewar}/${rawwarfile} webxml=/webxml filesonly=true>
  <fileset dir=${assemblewar} includ
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26828.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.