仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1755|回复: 20
打印 上一主题 下一主题

[学习教程] JAVA网页编程之Java WS和C#挪用

[复制链接]
若天明 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-18 11:54:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

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的开发并没有必然的关系,也不见得在所以情况下,别人使用起来会简单。
小魔女 该用户已被删除
沙发
发表于 2015-1-21 16:57:16 | 只看该作者
Java是一个纯的面向对象的程序设计语言,它继承了 C++语言面向对象技术的核心。Java舍弃了C ++语言中容易引起错误的指针(以引用取代)、运算符重载(operator overloading)
谁可相欹 该用户已被删除
板凳
发表于 2015-1-21 21:27:23 | 只看该作者
Java 编程语言的风格十分接近C、C++语言。
admin 该用户已被删除
地板
发表于 2015-1-27 06:39:19 | 只看该作者
Jive的资料在很多网站上都有,大家可以找来研究一下。相信你读完代码后,会有脱胎换骨的感觉。遗憾的是Jive从2.5以后就不再无条件的开放源代码,同时有licence限制。不过幸好还有中国一流的Java程序员关注它,外国人不开源了,中国人就不能开源吗?这里向大家推荐一个汉化的Jive版本—J道。Jive(J道版)是由中国Java界大名 鼎鼎的banq在Jive 2.1版本基础上改编而成, 全中文,增加了一些实用功能,如贴图,用户头像和用户资料查询等,而且有一个开发团队在不断升级。你可以访问banq的网站
乐观 该用户已被删除
5#
发表于 2015-2-5 00:38:41 | 只看该作者
还好,SUN提供了Javabean可以把你的JSP中的 Java代码封装起来,便于调用也便于重用。
只想知道 该用户已被删除
6#
发表于 2015-2-7 19:26:06 | 只看该作者
有时间再研究一下MVC结构(把Model-View-Control分离开的设计思想)
蒙在股里 该用户已被删除
7#
发表于 2015-2-8 06:51:14 | 只看该作者
吧,现在很流行的Structs就是它的一种实现方式,不过Structs用起来实在是很繁,我们只要学习其精髓即可,我们完全可以设计自己的MVC结构。然后你再研究一下软件Refactoring (重构)和极限XP编程,相信你又会上一个台阶。 做完这些,你不如整理一下你的Java代码,把那些经典的程序和常见的应用整理出来,再精心打造一番,提高其重用性和可扩展性。你再找几个志同道合的朋友成立一个工作室吧
老尸 该用户已被删除
8#
发表于 2015-2-24 17:48:49 | 只看该作者
Java是一个纯的面向对象的程序设计语言,它继承了 C++语言面向对象技术的核心。Java舍弃了C ++语言中容易引起错误的指针(以引用取代)、运算符重载(operator overloading)
柔情似水 该用户已被删除
9#
发表于 2015-3-4 05:04:32 | 只看该作者
Java语言支持Internet应用的开发,在基本的Java应用编程接口中有一个网络应用编程接口(java net),它提供了用于网络应用编程的类库,包括URL、URLConnection、Socket、ServerSocket等。Java的RMI(远程方法激活)机制也是开发分布式应用的重要手段。
飘飘悠悠 该用户已被删除
10#
发表于 2015-3-7 11:35:44 | 只看该作者
在全球云计算和移动互联网的产业环境下,Java更具备了显著优势和广阔前景。
再见西城 该用户已被删除
11#
发表于 2015-3-13 02:09:35 | 只看该作者
接着就是EJB了,EJB就是Enterprise JavaBean, 看名字好象它是Javabean,可是它和Javabean还是有区别的。它是一个体系结构,你可以搭建更安全、更稳定的企业应用。它的大量代码已由中间件(也就是我们常听到的 Weblogic,Websphere这些J2EE服务器)完成了,所以我们要做的程序代码量很少,大部分工作都在设计和配置中间件上。
小妖女 该用户已被删除
12#
发表于 2015-3-20 10:03:07 | 只看该作者
是一种使网页(Web Page)由静态(Static)转变为动态(Dynamic)的语言
兰色精灵 该用户已被删除
13#
发表于 2015-3-23 03:49:59 | 只看该作者
J2SE开发桌面应用软件比起 VC,VB,DEPHI这些传统开发语言来说,优势好象并不明显。J2ME对于初学者来说,好象又有点深奥,而且一般开发者很难有开发环境。
若相依 该用户已被删除
14#
发表于 2015-3-27 20:08:33 | 只看该作者
一直感觉JAVA很大,很杂,找不到学习方向,前两天在网上找到了这篇文章,感觉不错,给没有方向的我指了一个方向,先不管对不对,做下来再说。
活着的死人 该用户已被删除
15#
发表于 2015-4-2 00:15:22 | 只看该作者
有时间再研究一下MVC结构(把Model-View-Control分离开的设计思想)
愤怒的大鸟 该用户已被删除
16#
发表于 2015-4-9 08:32:30 | 只看该作者
是一种突破用户端机器环境和CPU
山那边是海 该用户已被删除
17#
发表于 2015-4-17 16:14:38 | 只看该作者
一直感觉JAVA很大,很杂,找不到学习方向,前两天在网上找到了这篇文章,感觉不错,给没有方向的我指了一个方向,先不管对不对,做下来再说。
不帅 该用户已被删除
18#
发表于 2015-4-20 20:04:06 | 只看该作者
当然你也可以参加一些开源项目,一方面可以提高自己,另一方面也是为中国软件事业做贡献嘛!开发者在互联网上用CVS合作开发,用QQ,MSN,E-mail讨论联系,天南海北的程序员分散在各地却同时开发同一个软件,是不是很有意思呢?
再现理想 该用户已被删除
19#
发表于 2015-4-26 21:09:30 | 只看该作者
如果你学过HTML,那么事情要好办的多,如果没有,那你快去补一补HTML基础吧。其实JSP中的Java语法也不多,它更象一个脚本语言,有点象ASP。
海妖 该用户已被删除
20#
发表于 2015-6-11 16:16:57 | 只看该作者
自从Sun推出Java以来,就力图使之无所不包,所以Java发展到现在,按应用来分主要分为三大块:J2SE,J2ME和J2EE,这也就是Sun ONE(Open Net Environment)体系。J2SE就是Java2的标准版,主要用于桌面应用软件的编程;J2ME主要应用于嵌入是系统开发,如手机和PDA的编程;J2EE是Java2的企业版,主要用于分布式的网络程序的开发,如电子商务网站和ERP系统。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-8 15:35

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表