互操作性是Web Service的真正優勢
雖然關於WS標准有很多
但不同廠家都是自己的實現
不同實現之間的互操作性因此很差
於是有了WS
I組織成立來管理這種差異
並提供統一的互操作性規范
到目前為止
這些工作仍在進行中
不過成果早已經有了:WS
I Attachment Profile
並且也已經在Sun提供的WS設施上有了體現
通過使用wscompile 工具中的選項
f wsi 即可生成兼容WS
I規范的java制品
文件清單: SEI接口類IImage
java
實現SEI接口的類IIMageImpl
java
描述文件信息的值類型類FileInfo
java
Web應用部署描述文件web
xml
WS發布配置文件jaxrpc
ri
xml
WS編譯配置文件config
interface
xml
構建客戶端樁的config
wsdl
xml
構建文件builder
xml
客戶端測試類:Formcs 本例是從WSDL開始的
因此我們要有一個WSDL文件
第一步就是得到這個文件
(一) 得到WSDL文件 為達到互操作要求
這個文件的描述必須是文檔樣式的綁定
文字格式的編碼
為得到此文件
首先介紹構建文件builder
xml:
<?xml version=
encoding=
GBK
?>
<project name=
webservice
default=
build
basedir=
>
<property name=
jaxrpc
lib
dir
value=
I:\jwsdp
\jaxrpc\lib
>
</property>
<property name=
jaxrpc
lib
dir
value=
D:\Sun\AppServer\lib
>
</property>
<property name=
classes
dir
value=
\build\classes
>
</property>
<property name=
src
dir
value=
\build\src
>
</property>
<property name=
raw
war
file
value=
netservice
raw
war
>
</property>
<property name=
cook
war
file
value=
netservice
war
>
</property>
<property name=
nonclass
dir
value=
\build\nonclass
>
</property>
<property name=
build
value=
${nonclass
dir}
>
</property>
<property name=
assemble
value=
\assemble
>
</property>
<property name=
assemble
war
value=
\assemble\war
>
</property>
<property name=
assemble
ear
value=
\assemble\ear
>
</property>
<property name=
wsi
dir
value=
\wsi
>
</property>
<property name=
wsi
server
dir
value=
\wsi\server
>
</property>
<property name=
wsi
client
dir
value=
\wsi\client
>
</property>
<property name=
tmp
dir
value=
\tmp
>
</property>
<path id=
jaxrpc
classpath
>
<fileset dir=
${jaxrpc
lib
dir}
>
<include name=
**/*
jar
/>
</fileset>
<fileset dir=
D:\jdbc\postgresql
>
<include name=
*
jar
/>
</fileset>
</path>
<path id=
compile
classpath
>
<fileset dir=
${jaxrpc
lib
dir}
>
<include name=
**/*
jar
/>
</fileset>
<fileset dir=
D:\jwsdp
\jaxrpc\lib
>
<include name=
**/*
jar
/>
</fileset>
</path>
<path id=
jaxrpc
classpath
>
<fileset dir=
${jaxrpc
lib
dir}
>
<include name=
**/*
jar
/>
</fileset>
<fileset dir=
I:\jwsdp
\jwsdp
shared\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=
compile
classpath
>
<fileset dir=
${jaxrpc
lib
dir}
>
<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
\jwsdp
shared\lib
>
<include name=
**/*
jar
/>
</fileset>
<fileset dir=
I:\jwsdp
\saaj\lib
>
<include name=
**/*
jar
/>
</fileset>
<fileset dir=
H:\jakarta
tomcat
\common\lib
>
<include name=
servlet
api
jar
/>
</fileset>
</path>
<taskdef name=
wscompile
classpat classname=
com
sun
xml
rpc
tools
ant
Wscompile
>
</taskdef>
<taskdef name=
wsdeploy
classpat classname=
com
sun
xml
rpc
tools
ant
Wsdeploy
>
</taskdef>
<target name=
prepare
>
<mkdir dir=
${src
dir}
/>
<mkdir dir=
${nonclass
dir}
/>
<mkdir dir=
${classes
dir}
/>
<mkdir dir=
${assemble}
/>
<mkdir dir=
${assemble
war}
/>
<mkdir dir=
${assemble
ear}
/>
<mkdir dir=
${wsi
dir}
/>
<mkdir dir=
${wsi
server
dir}
/>
<mkdir dir=
${wsi
client
dir}
/>
<mkdir dir=
${tmp
dir}
/>
</target>
<target name=
compile
class
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=
compile
classpath
/>
</javac>
</target>
<target name=
build
depends=
prepare
description=
生成java制品
如生成可供wsdeploy使用的web檔案
稱為生war
就象作菜一樣
先順菜
以及model
wsdl文件
這裡生成的WSDL文件
wsdeploy並不使用
>
<echo message=
build the WAR
/>
<wscompile import=
false
features=
wsi
documentliteral
define=
true
gen=
false
keep=
true
base=
${classes
dir}
sourceBase=
${src
dir}
classpath=
\classes
nonClassDir=
${nonclass
dir}
model=
model
xml
gz
xPrintStackTrace=
true
config=
config
interface
xml
verbose=
true
>
<classpath refid=
compile
classpath
/>
</wscompile>
</target>
<target name=
deploy
depends=
prepare
description=
生成可供發布的web檔案
稱為煮熟的war
這個階段也生成了WSDL文件並被直接打包了
>
<echo message=
deploy the WAR
/>
<wsdeploy keep=
false
verbose=
true
tmpDir=
${tmp
dir}
outWarFile=
${cook
war
file}
inWarFile=
${raw
war
file}
>
<classpath refid=
compile
classpath
/>
</wsdeploy>
</target>
<target name=
create
war
description=
打包由wscompile生成的制品
以及所有發布所用的材料
>
<echo message=
build
war Creating the WAR
/>
<antcall target=
compile
class
>
<param name=
src
value=
${wsi
server
dir}
/>
<param name=
build
value=
${wsi
server
dir}
/>
</antcall>
<delete file=
${assemble
war}/${war
file}
/>
<delete dir=
${assemble
war}/WEB
INF
/>
<copy todir=
${assemble
war}/WEB
INF/classes/
>
<fileset dir=
${wsi
server
dir}
includes=
**/*
class
excludes=
**/*Client
class
**/*
wsdl
**/*mapping
xml
/>
</copy>
<copy todir=
${assemble
war}/WEB
INF/lib/
>
<fileset dir=
/lib
includes=
**/*
jar
excludes=
**/*Client
class
**/*
wsdl
**/*mapping
xml
/>
</copy>
<copy file=
\conf\BinaryService
wsdl
todir=
${assemble
war}/WEB
INF
/>
<copy file=
jaxrpc
ri
xml
todir=
${assemble
war}/WEB
INF
/>
<copy file=
model
xml
gz
todir=
${assemble
war}/WEB
INF
/>
<war destfile=
${assemble
war}/${raw
war
file}
webxml=
/web
xml
filesonly=
true
>
<fileset dir=
${assemble
war}
includ
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26828.html