|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
学习JAVA的目的更多的是培养自身的工作能力,我觉得工作能力的一个核心就是:独立思考能力,因为只有独立思考后,才会有自己的见解文章中的WS服务使得这个服务能够在DotNet情况中挪用.
文件清单:
SEI接口类IImage.java,完成SEI接口的类IIMageImpl.java,形貌文件信息的值范例类FileInfo.java,Web使用部署形貌文件web.xml,WS公布设置文件jaxrpc-ri.xml,WS编译设置文件config-interface.xml,构建客户端桩的config-wsdl.xml,构建文件builder.xml
客户端测试类:Form1.cs.
本例是从WSDL入手下手的,因而我们要有一个WSDL文件.第一步就是失掉这个文件.
(一)失掉WSDL文件.
为到达互操纵请求,这个文件的形貌必需是文档款式的绑定,笔墨格局的编码.为失掉此文件,起首先容构建文件builder.xml:
<?xmlversion="1.0"encoding="GBK"?>
<projectname="webservice"default="build"basedir=".">
<propertyname="jaxrpc.lib.dir"value="I:jwsdp-1.6jaxrpclib">
</property>
<propertyname="jaxrpc.lib.dir1"value="D:SunAppServerlib">
</property>
<propertyname="classes.dir"value=".uildclasses">
</property>
<propertyname="src.dir"value=".uildsrc">
</property>
<propertyname="raw.war.file"value="netservice-raw.war">
</property>
<propertyname="cook.war.file"value="netservice.war">
</property>
<propertyname="nonclass.dir"value=".uild
onclass">
</property>
<propertyname="build"value="${nonclass.dir}">
</property>
<propertyname="assemble"value=".assemble">
</property>
<propertyname="assemble.war"value=".assemblewar">
</property>
<propertyname="assemble.ear"value=".assembleear">
</property>
<propertyname="wsi.dir"value=".wsi">
</property>
<propertyname="wsi.server.dir"value=".wsiserver">
</property>
<propertyname="wsi.client.dir"value=".wsiclient">
</property>
<propertyname="tmp.dir"value=". mp">
</property>
<pathid="jaxrpc-classpath1">
<filesetdir="${jaxrpc.lib.dir}">
<includename="**/*.jar"/>
</fileset>
<filesetdir="D:jdbcpostgresql">
<includename="*.jar"/>
</fileset>
</path>
<pathid="compile.classpath1">
<filesetdir="${jaxrpc.lib.dir}">
<includename="**/*.jar"/>
</fileset>
<filesetdir="D:jwsdp-1.5jaxrpclib">
<includename="**/*.jar"/>
</fileset>
</path>
<pathid="jaxrpc-classpath">
<filesetdir="${jaxrpc.lib.dir}">
<includename="**/*.jar"/>
</fileset>
<filesetdir="I:jwsdp-1.6jwsdp-sharedlib">
<includename="**/*.jar"/>
</fileset>
<filesetdir="I:jwsdp-1.6jaxplib">
<includename="**/*.jar"/>
</fileset>
<filesetdir="I:jwsdp-1.6jaxplibendorsed">
<includename="**/*.jar"/>
</fileset>
<filesetdir="D:jdbcpostgresql">
<includename="*.jar"/>
</fileset>
</path>
<pathid="compile.classpath">
<filesetdir="${jaxrpc.lib.dir}">
<includename="**/*.jar"/>
</fileset>
<filesetdir="I:jwsdp-1.6jaxplib">
<includename="**/*.jar"/>
</fileset>
<filesetdir="I:jwsdp-1.6jaxplibendorsed">
<includename="**/*.jar"/>
</fileset>
<filesetdir="I:jwsdp-1.6jwsdp-sharedlib">
<includename="**/*.jar"/>
</fileset>
<filesetdir="I:jwsdp-1.6saajlib">
<includename="**/*.jar"/>
</fileset>
<filesetdir="H:jakarta-tomcat-5.5.9commonlib">
<includename="servlet-api.jar"/>
</fileset>
</path>
<taskdefname="wscompile"classpathref="jaxrpc-classpath"classname="com.sun.xml.rpc.tools.ant.Wscompile">
</taskdef>
<taskdefname="wsdeploy"classpathref="jaxrpc-classpath"classname="com.sun.xml.rpc.tools.ant.Wsdeploy">
</taskdef>
<targetname="prepare">
<mkdirdir="${src.dir}"/>
<mkdirdir="${nonclass.dir}"/>
<mkdirdir="${classes.dir}"/>
<mkdirdir="${assemble}"/>
<mkdirdir="${assemble.war}"/>
<mkdirdir="${assemble.ear}"/>
<mkdirdir="${wsi.dir}"/>
<mkdirdir="${wsi.server.dir}"/>
<mkdirdir="${wsi.client.dir}"/>
<mkdirdir="${tmp.dir}"/>
</target>
<targetname="compile-class"depends="prepare">
<echomessage="Compilingthejavasourcecode...."/>
<propertyname="src"value="${src1}">
</property>
<propertyname="dest"value="${build1}">
</property>
<echomessage="src=${src}build=${dest}"/>
<echomessage="deleteclassindir${src}...."/>
<delete>
<filesetdir="${src}">
<includename="**/*.class"/>
<excludename="exclude"/>
</fileset>
</delete>
<echomessage="recompilejavaindir${src}...."/>
<javacsrcdir="${src}"destdir="${dest}"includes="**/*.java"excludes="hhhhhh">
<classpathrefid="compile.classpath"/>
</javac>
</target>
<targetname="build"depends="prepare"description="天生java成品,如天生可供wsdeploy利用的web档案,称为生war,就象作菜一样,先顺菜,和model,wsdl文件,这里天生的WSDL文件,wsdeploy其实不利用">
<echomessage="buildtheWAR...."/>
<wscompileimport="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">
<classpathrefid="compile.classpath"/>
</wscompile>
</target>
<targetname="deploy"depends="prepare"description="天生可供公布的web档案,称为煮熟的war,这个阶段也天生了WSDL文件并被间接打包了">
<echomessage="deploytheWAR...."/>
<wsdeploykeep="false"verbose="true"tmpDir="${tmp.dir}"outWarFile="${cook.war.file}"inWarFile="${raw.war.file}">
<classpathrefid="compile.classpath"/>
</wsdeploy>
</target>
<targetname="create-war"description="打包由wscompile天生的成品,和一切公布所用的质料">
<echomessage="build-warCreatingtheWAR...."/>
<antcalltarget="compile-class">
<paramname="src1"value="${wsi.server.dir}"/>
<paramname="build1"value="${wsi.server.dir}"/>
</antcall>
<deletefile="${assemble.war}/${war.file}"/>
<deletedir="${assemble.war}/WEB-INF"/>
<copytodir="${assemble.war}/WEB-INF/classes/">
<filesetdir="${wsi.server.dir}"includes="**/*.class"excludes="**/*Client.class,**/*.wsdl,**/*mapping.xml"/>
</copy>
<copytodir="${assemble.war}/WEB-INF/lib/">
<filesetdir="./lib"includes="**/*.jar"excludes="**/*Client.class,**/*.wsdl,**/*mapping.xml"/>
</copy>
<copyfile=".confBinaryService.wsdl"todir="${assemble.war}/WEB-INF"/>
<copyfile="jaxrpc-ri.xml"todir="${assemble.war}/WEB-INF"/>
<copyfile="model.xml.gz"todir="${assemble.war}/WEB-INF"/>
<wardestfile="${assemble.war}/${raw.war.file}"webxml="./web.xml"filesonly="true">
<filesetdir="${assemble.war}"includes="WEB-INF/**,build/**"/>
</war>
<copyfile="${assemble.war}/${raw.war.file}"todir="."/>
</target>
<targetname="genstaticstub"description="天生静态桩,供静态的挪用服务">
<echomessage="genstaticstub"/>
<wscompileclient="true"features="wsi,documentliteral"keep="true"base="."sourceBase="."xPrintStackTrace="true"config="config-wsdl.xml"verbose="true">
<classpathrefid="compile.classpath"/>
</wscompile>
</target>
<targetname="generate-dynamic-interface"description="依据WSDL文件天生SEI及别的质料,供静态挪用norpcstructures">
<echomessage="generatedynamicinterface"/>
<wscompileimport="true"keep="false"features="wsi,documentliteral"base="./dynmicstub"sourceBase="./dynmicstub"xPrintStackTrace="true"config="config-wsdl.xml"verbose="true">
<classpathrefid="compile.classpath"/>
</wscompile>
</target>
<targetdepends="prepare"name="wsiserverservice"description="GeneratingWS-ICompliantServiceFileswithwscompile依据WSDL文件天生SEI及别的质料,供静态挪用norpcstructures">
<echomessage="generate-server,generatewsiserverservice"/>
<wscompileimport="true"define="false"keep="false"features="wsi,documentliteral"base="${wsi.server.dir}"sourceBase="${wsi.server.dir}"xPrintStackTrace="true"model="model.xml.gz"config=".confconfig-server.xml"verbose="true">
<classpathrefid="compile.classpath"/>
</wscompile>
</target>
<targetdepends="prepare"name="wsiclientservice"description="GeneratingWS-ICompliantServiceFileswithwscompile依据WSDL文件天生SEI及别的质料,供静态挪用norpcstructures">
<echomessage="generatewsiclientservice"/>
<wscompileclient="true"keep="true"features="wsi,documentliteral"base="${wsi.client.dir}"sourceBase="${wsi.client.dir}"xPrintStackTrace="true"config=".confconfig-client.xml"verbose="true">
<classpathrefid="compile.classpath"/>
</wscompile>
</target>
</project>
在这个构建文件中的build义务中,features的值指定为"wsi,documentliteral",这个义务必要的config-interface.xml:
<?xmlversion="1.0"encoding="UTF-8"?>
<configurationxmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
<servicename="BinaryService"targetNamespace="urn:binary"
typeNamespace="urn:binary"packageName="com.binary">
<interfacename="com.bin.IImage"
servantName="com.bin.ImageImpl"/>
</service>
</configuration>
这个文件的必要的com.bin.IImageSEI接口文件及实在现文件com.bin.ImageImpl:
publicinterfaceIImageextendsRemote{
//publicDataHandlerfetchImg(Stringsn)throwsRemoteException;
//publicDataHandler[]fetchImgs(String[]sn)throwsRemoteException;
publicSOAPMessageconstrucMsg(String[]fn)throwsRemoteException;
publicbyte[]fetchImage(Stringsn)throwsRemoteException;
publicFileInfo[]fetchFileList()throwsjava.rmi.RemoteException;
publicFileInfogetFileList(Stringfn)throwsjava.rmi.RemoteException;
}
DataHandler,ArrayList属于java的类固然不同意呈现在接口中了,由于C#不熟悉这些类,FileInfo值范例类倒撑持,由于这个类没无方法,并且数据范例都是能够用SOAP来暗示的,C#是能够了解的.
完成文件,注重完成的办法是空办法.
publicclassImageImplimplementsIImage{
publicSOAPMessageconstrucMsg(String[]fn)throwsRemoteException{
returnnull;
}
publicbyte[]fetchImage(Stringsn)throwsRemoteException{
returnnull;
}
publicFileInfo[]fetchFileList()throwsjava.rmi.RemoteException{
returnnull;
}
publicFileInfogetFileList(Stringfn)throwsRemoteException{
returnnull;
}
}
到这里,为互操纵所做的修正只是在features的值指定为"wsi,documentliteral",别的中央没有修正包含config-interface.xml接口设置文件.
经由过程实行这个义务,能够失掉我们想要的BinaryService.wsdl文件.位于nonclass文件夹中,把它挪动到conf中.
<br>
(二)机关Web服务
在这个conf文件夹中除有BinaryService.wsdl外,另有两个文件:
config-client.xml,用来依据WSDL文件天生客户端会见服务所必要的成品.
<?xmlversion="1.0"encoding="UTF-8"?>
<configurationxmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
<wsdl
location="http://localhost:8080/netservice/binary?WSDL"
packageName="wsidotnet"/>
</configuration>
config-server.xml则用来依据BinaryService.wsdl天生服务器端成品,包含从头天生的SEI接口文件,我们将使用这个文件编写服务虚现,而不是后面提到的com.bin.IImageSEI接口文件及实在现文件com.bin.ImageImpl:
<?xmlversion="1.0"encoding="UTF-8"?>
<configurationxmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
<wsdllocation="web-inf/conf/BinaryService.wsdl"
packageName="wsidotnet"/>
</configuration>
到今朝为止,另有两个文件没有供应:
jaxrpc-ri.xml:
<?xmlversion="1.0"encoding="UTF-8"?>
<webServicesxmlns="http://java.sun.com/xml/ns/jax-rpc/ri/dd"
version="1.0"
targetNamespaceBase="http://java.sun.com/xml/ns/jax-rpc/wsi/wsdl"
typeNamespaceBase="http://java.sun.com/xml/ns/jax-rpc/wsi/types"
urlPatternBase="/ws">
<endpointname="ImageBinaryService"displayName="StockExample"
description="StockExampleWebServiceendpoint"
interface="wsidotnet.IImage"implementation="wsidotnet.IImage_Impl"
model="/WEB-INF/model.xml.gz"/>
<endpointMappingendpointName="ImageBinaryService"urlPattern="/binary"/>
</webServices>
web.xml文件:
<?xmlversion="1.0"encoding="UTF-8"?>
<web-appxmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<context-param>
<param-name>BinaryPath</param-name>
<param-value>变动成你的当地文件路径</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.jws</welcome-file>
</welcome-file-list>
</web-app>
上面就是构建历程,起首,实行wsiserverservice失掉服务器真个java成品,包含从头天生的SEI,wscompile还天生了一个完成文件IImage_Impl,前面要修正这个类,在个中到场有效的办法.
wsidotnet.IImage清单:
packagewsidotnet;
publicinterfaceIImageextendsjava.rmi.Remote{
publicwsidotnet.ConstrucMsgResponseconstrucMsg(wsidotnet.ConstrucMsgparameters)throws
java.rmi.RemoteException;
publicwsidotnet.FetchFileListResponsefetchFileList(wsidotnet.FetchFileListparameters)throws
java.rmi.RemoteException;
publicwsidotnet.FetchImageResponsefetchImage(wsidotnet.FetchImageparameters)throws
java.rmi.RemoteException;
publicwsidotnet.GetFileListResponsegetFileList(wsidotnet.GetFileListparameters)throws
java.rmi.RemoteException;
}
和后面的com.bin.IImage接口比拟很分歧了.由于接纳文档款式的绑定,以是这里就发生了所谓的包装类了.
完成文件为:
packagewsidotnet;
importjava.io.File;
importjava.io.FileInputStream;
importjava.nio.MappedByteBuffer;
importjava.nio.channels.FileChannel;
importjava.util.Calendar;
importjava.util.Date;
importjavax.servlet.ServletContext;
importjavax.xml.rpc.ServiceException;
importjavax.xml.rpc.server.ServiceLifecycle;
importjavax.xml.rpc.server.ServletEndpointContext;
publicclassIImage_Implimplementswsidotnet.IImage,java.rmi.Remote,ServiceLifecycle{
ServletEndpointContextservletEndpointContext=null;
Stringbinarypath="";
ServletContextservletContext=null;
publicwsidotnet.ConstrucMsgResponseconstrucMsg(wsidotnet.ConstrucMsgparameters)throws
java.rmi.RemoteException{
wsidotnet.ConstrucMsgResponse_retVal=null;
return_retVal;
}
publicwsidotnet.FetchFileListResponsefetchFileList(wsidotnet.FetchFileListparameters)throws
java.rmi.RemoteException{
wsidotnet.FetchFileListResponse_retVal=newFetchFileListResponse();
_retVal.setResult(fetchFileList());
return_retVal;
}
publicwsidotnet.FetchImageResponsefetchImage(wsidotnet.FetchImageparameters)throws
java.rmi.RemoteException{
wsidotnet.FetchImageResponse_retVal=newFetchImageResponse();
_retVal.setResult(fetchImage(parameters.getString_1()));
return_retVal;
}
publicwsidotnet.GetFileListResponsegetFileList(wsidotnet.GetFileListparameters)throws
java.rmi.RemoteException{
wsidotnet.GetFileListResponse_retVal=null;
return_retVal;
}
privateFileInfo[]fetchFileList(){
Filefile=newFile(this.binarypath);
System.out.println(this.binarypath);
File[]c=file.listFiles();
FileInfo[]fis=newFileInfo[c.length];
for(inti=0;i<c.length;i++){
FileInfofi=newFileInfo();
fi.setIsdir(c.isDirectory());
fi.setFilename(c.getName());
fi.setFilelength(c.length());
fi.setFilepath(c.getAbsolutePath());
Calendarcal=Calendar.getInstance();
cal.setTime(newDate(c.lastModified()));
fi.setCreatedate(cal);
fis=fi;
}
returnfis;
}
privatebyte[]fetchImage(Stringsn){
Filefile=newFile(sn);
byte[]b=null;
MappedByteBufferbuffer=null;
try{
FileInputStreamis=newFileInputStream(file);
b=newbyte[(int)file.length()];
is.read(b,0,(int)file.length());
/*
FileChannelfc=is.getChannel();
buffer=fc.map(FileChannel.MapMode.READ_ONLY,0,file.length());
buffer.get
*/
}catch(Exceptionex){
System.out.println(ex);
}
//returnbuffer.array();
returnb;
}
publicvoiddestroy(){
//TODOAuto-generatedmethodstub
servletEndpointContext=null;
servletContext=null;
}
publicvoidinit(Objectarg0)throwsServiceException{
//TODOAuto-generatedmethodstub
servletEndpointContext=(ServletEndpointContext)arg0;
servletContext=servletEndpointContext.getServletContext();
binarypath=servletContext.getInitParameter("BinaryPath");
}
}
这里展现的完成类,已过修正,让它扩大了ServiceLifecycle接口,以便运转情况送给它小金豆.这里就是取得了文件路径.别的,还供应了两个公有办法:fetchImage,fetchFileList用于详细实行功效,这里也能够把这两个办法挪动到一个新类,然后IImage_Impl利用这个新类,使IImage_Impl类酿成挪用者对内部类的适配器,如许就构成了一个适配器形式.
完成以上修正后,持续实行Ant义务:create-war,deploy后,失掉了可供公布的netservice.war举行公布.本例利用Tomcat5,反省http://localhost:8080/netservice/binary?WSDL是不是装进.
公布乐成后,用VS新建一个C#项目,经由过程这个地点http://localhost:8080/netservice/binary?WSDL援用这个服务,然后编写以下类:
usingSystem;
usingSystem.Drawing;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Windows.Forms;
usingSystem.Data;
usingtestws.binary;
namespacetestws
{
///<summary>
///Form1的择要申明。
///</summary>
publicclassForm1:System.Windows.Forms.Form
{
privateSystem.Windows.Forms.Buttonbutton1;
privateSystem.Windows.Forms.ListBoxlistBox1;
privateSystem.Windows.Forms.PictureBoxpictureBox1;
privateSystem.Windows.Forms.StatusBarstatusBar1;
privateSystem.Windows.Forms.StatusBarPanelstatusBarPanel1;
privateSystem.Windows.Forms.StatusBarPanelstatusBarPanel2;
testws.binary.IImageBindingimagelist;
privateSystem.Windows.Forms.Panelpanel1;
privateSystem.Windows.Forms.Panelpanel2;
privateSystem.Windows.Forms.Panelpanel3;
privateSystem.Windows.Forms.Panelpanel4;
privateSystem.Windows.Forms.Splittersplitter1;
///<summary>
///必须的计划器变量。
///</summary>
privateSystem.ComponentModel.Containercomponents=null;
publicForm1()
{
//
//Windows窗体计划器撑持所必须的
//
InitializeComponent();
//
//TODO:在InitializeComponent挪用后增加任何机关函数代码
//
}
///<summary>
///清算一切正在利用的资本。
///</summary>
protectedoverridevoidDispose(booldisposing)
{
if(disposing)
{
if(components!=null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#regionWindows窗体计划器天生的代码
///<summary>
///计划器撑持所需的办法-不要利用代码编纂器修正
///此办法的内容。
///</summary>
privatevoidInitializeComponent()
{
this.button1=newSystem.Windows.Forms.Button();
this.listBox1=newSystem.Windows.Forms.ListBox();
this.pictureBox1=newSystem.Windows.Forms.PictureBox();
this.statusBar1=newSystem.Windows.Forms.StatusBar();
this.statusBarPanel1=newSystem.Windows.Forms.StatusBarPanel();
this.statusBarPanel2=newSystem.Windows.Forms.StatusBarPanel();
this.panel1=newSystem.Windows.Forms.Panel();
this.panel2=newSystem.Windows.Forms.Panel();
this.panel3=newSystem.Windows.Forms.Panel();
this.panel4=newSystem.Windows.Forms.Panel();
this.splitter1=newSystem.Windows.Forms.Splitter();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.panel4.SuspendLayout();
this.SuspendLayout();
//
//button1
//
this.button1.Location=newSystem.Drawing.Point(24,8);
this.button1.Name="button1";
this.button1.Size=newSystem.Drawing.Size(56,23);
this.button1.TabIndex=0;
this.button1.Text="装进";
this.button1.Click+=newSystem.EventHandler(this.button1_Click);
//
//listBox1
//
this.listBox1.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
this.listBox1.Dock=System.Windows.Forms.DockStyle.Fill;
this.listBox1.ItemHeight=12;
this.listBox1.Location=newSystem.Drawing.Point(0,0);
this.listBox1.Name="listBox1";
this.listBox1.Size=newSystem.Drawing.Size(136,230);
this.listBox1.TabIndex=1;
this.listBox1.SelectedIndexChanged+=newSystem.EventHandler(this.listBox1_SelectedIndexChanged);
//
//pictureBox1
//
this.pictureBox1.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox1.Dock=System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Location=newSystem.Drawing.Point(0,0);
this.pictureBox1.Name="pictureBox1";
this.pictureBox1.Size=newSystem.Drawing.Size(261,231);
this.pictureBox1.TabIndex=2;
this.pictureBox1.TabStop=false;
//
//statusBar1
//
this.statusBar1.Location=newSystem.Drawing.Point(0,271);
this.statusBar1.Name="statusBar1";
this.statusBar1.Panels.AddRange(newSystem.Windows.Forms.StatusBarPanel[]{
this.statusBarPanel1,
this.statusBarPanel2});
this.statusBar1.ShowPanels=true;
this.statusBar1.Size=newSystem.Drawing.Size(400,22);
this.statusBar1.TabIndex=3;
this.statusBar1.Text="statusBar1";
//
//statusBarPanel1
//
this.statusBarPanel1.AutoSize=System.Windows.Forms.StatusBarPanelAutoSize.Contents;
this.statusBarPanel1.Width=10;
//
//statusBarPanel2
//
this.statusBarPanel2.AutoSize=System.Windows.Forms.StatusBarPanelAutoSize.Spring;
this.statusBarPanel2.Width=374;
//
//panel1
//
this.panel1.Controls.Add(this.listBox1);
this.panel1.Dock=System.Windows.Forms.DockStyle.Left;
this.panel1.Location=newSystem.Drawing.Point(0,0);
this.panel1.Name="panel1";
this.panel1.Size=newSystem.Drawing.Size(136,231);
this.panel1.TabIndex=4;
//
//panel2
//
this.panel2.Controls.Add(this.button1);
this.panel2.Dock=System.Windows.Forms.DockStyle.Top;
this.panel2.Location=newSystem.Drawing.Point(0,0);
this.panel2.Name="panel2";
this.panel2.Size=newSystem.Drawing.Size(400,40);
this.panel2.TabIndex=5;
//
//panel3
//
this.panel3.Controls.Add(this.panel4);
this.panel3.Controls.Add(this.splitter1);
this.panel3.Controls.Add(this.panel1);
this.panel3.Dock=System.Windows.Forms.DockStyle.Fill;
this.panel3.Location=newSystem.Drawing.Point(0,40);
this.panel3.Name="panel3";
this.panel3.Size=newSystem.Drawing.Size(400,231);
this.panel3.TabIndex=6;
//
//panel4
//
this.panel4.Controls.Add(this.pictureBox1);
this.panel4.Dock=System.Windows.Forms.DockStyle.Fill;
this.panel4.Location=newSystem.Drawing.Point(139,0);
this.panel4.Name="panel4";
this.panel4.Size=newSystem.Drawing.Size(261,231);
this.panel4.TabIndex=5;
//
//splitter1
//
this.splitter1.Location=newSystem.Drawing.Point(136,0);
this.splitter1.Name="splitter1";
this.splitter1.Size=newSystem.Drawing.Size(3,231);
this.splitter1.TabIndex=6;
this.splitter1.TabStop=false;
//
//Form1
//
this.AutoScaleBaseSize=newSystem.Drawing.Size(6,14);
this.ClientSize=newSystem.Drawing.Size(400,293);
this.Controls.Add(this.panel3);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.panel2);
this.Name="Form1";
this.Text="WS-IDemo---AccessSunWS";
this.Load+=newSystem.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.panel4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///<summary>
///使用程序的主出口点。
///</summary>
[STAThread]
staticvoidMain()
{
Application.Run(newForm1());
}
privatevoidForm1_Load(objectsender,System.EventArgse)
{
listBox1.Items.Clear();
panel4.AutoScroll=true;
pictureBox1.SizeMode=PictureBoxSizeMode.AutoSize;
imagelist=newtestws.binary.IImageBinding();
}
privatevoidbutton1_Click(objectsender,System.EventArgse)
{
testws.binary.fetchFileListfl=newfetchFileList();
listBox1.Items.Clear();
//testws.binary.
FileInfo[]fis=imagelist.fetchFileList(fl);
if(fis!=null)
Console.WriteLine(fis.Length);
foreach(FileInfoinfoinfis)
{
//Console.WriteLine(info.filepath+""+info.createdate);
listBox1.Items.Add(info.filepath);
}
//testws.binary.HelloIFBindingbind=newHelloIFBinding();
}
privatevoidlistBox1_SelectedIndexChanged(objectsender,System.EventArgse)
{
ListBoxlb=(ListBox)sender;
if(lb.SelectedItem!=null)
{
statusBar1.Panels[0].Text=lb.SelectedItem.ToString();
testws.binary.fetchImagefn=newfetchImage();
fn.String_1=lb.SelectedItem.ToString();
testws.binary.fetchImageResponseres=imagelist.fetchImage(fn);
try
{
System.IO.MemoryStreamms=newSystem.IO.MemoryStream(res.result);
Imageimage=Image.FromStream(ms);
pictureBox1.Image=image;
panel4.AutoScrollMinSize=pictureBox1.Size;
}
catch(Exceptionex)
{
Console.WriteLine(ex.StackTrace);
}
}
}
}
}
测试界面:
<br>
到此,在C#会见JavaWS的历程停止了,完成互操纵性关头在于要天生恪守WS-I的javaWeb服务成品,如许的服务才能够跨分歧平台操纵.
他们对jsp,servlet,javabean进行封装就是为了展示他们的某个思想,与java的开发并没有必然的关系,也不见得在所以情况下,别人使用起来会简单。 |
|