webservice入门学习笔记
时间:2008-08-30 07:01:33
来源:论坛整理 作者: 编辑:chinaitzhe
**date: 2007/01/16
**author:laomai
**url: http://blog.csdn.net/laomai/
*/
web service入门学习笔记
最近要做一个java项目,里面用到了webservice技术,
经过一个多月的磕磕绊绊的摸索,总算如了点门。现将我的学习笔记贴出来,供大家参考。
说明,本笔记第七部分主要参考了
http://blog.csdn.net/lin_bei/archive/2006/11/07/1371131.aspx
的内容,由于这位兄弟翻译的不是很通顺,我就按照自己的理解来改编成了
hellowrold的例子:-)。
其他部分为我原创,转载时请注明出处。
一、实验环境
win2k jdk1.6 javee5.0 Myeclipse5.1
jdk和javee5.0均可从
http://java.sun.com/javase/downloads/index.jsp
下载,安装文件名为
jdk-6-windows-i586.exe
java_ee_sdk-5_02-windows.exe
没有myeclipse的也可以用eclipse代替,只要ide能执行
ant脚本就可以.
/*title: web service入门学习笔记(二)
**date: 2007/01/16
**author:laomai
**url: http://blog.csdn.net/laomai/
*/
二、第一个最简单的例子
jsee5安装以后会在系统中建立一个Application Server pe9,这是sun自带的网络服务器,
和tomcat、weblogic的性质类似。
在D:\Sun\SDK\samples\javaee5\webservices\hello-jaxws下有一个自带的web service入门例子,
(D:\Sun\SDK\为我机器上javaee5的安装路径)
我们就先实验它,来理解webservice的本质
1、把jdk的安装路径如D:\Java\jdk1.6.0\bin 加到系统的path环境变量中
2、运行sun自带的网络服务器,具体方法为
开始-> 程序-> Sun Microsystems-> Application Server PE 9-> Start Default Server
然后当弹出的cmd窗口中出现提示“按任意键继续时”输入回车,窗口会关闭,此时在浏览器输入
http://localhost:8080,应该出现如下内容:
Sun Java System Application Server Platform Edition 9.0
Your server is up and running!
说明服务器已经启动了
3、在Myeclipse打开刚才的例子目录D:\Sun\SDK\samples\javaee5\webservices\hello-jaxws
下的build.xml文件,这个一个ant脚本,具体含义我们以后再讲,现在先执行它
3、在build.xml文件中单击右键,在弹出菜单中选择 "run as "-> "1 ant build ",此时build.xml里的
内容会被执行,在Myeclipse的console中会输出:
buildfile: D:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\build.xml
init:
compile-deploy-service:
[echo] d:/Sun/SDK
get-artifacts-windows:
get-artifacts-unix:
get-artifacts:
compile-client:
[javac] Compiling 1 source file to D:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\build
run-client-windows:
[exec] Hello result = Hello Administrator!
run-client-unix:
run-client:
all:
BUILD SUCCESSFUL
Total time: 43 seconds
其中
[exec] Hello result = Hello Administrator!
的输出结果说明客户端调用服务器的webservice已经成功。
第一个例子就完成了。我们下面会对这个例子进行详细讲解.
/*title: web service入门学习笔记(三)、(四)
**date: 2007/01/16
**author:laomai
**url: http://blog.csdn.net/laomai/
*/
三、WebService的本质
从搞c的程序员的眼光来看,webservice实际上就是用java实现的rpc(远端过程调用),
或者说是dll的变形。服务器把它的接口对外发布成一个wsdl文件,客户端根据这个wsdl的内容生成
本地的代理类,再通过代理类调用远端的接口,代理再把接口的执行执行结果回传给客户端,
进行下一步处理。
网友回复:四、例子源代码剖析
D:\Sun\SDK\samples\javaee5\webservices\hello-jaxws(以后简称为hello-jaxws)
项目里的源文件只有三个
hello-jaxws\src\endpoint\Hello.java 提供webservice的服务器端实现类
hello-jaxws\src\client\Client.java 调用webservice的客户端测试类
hello-jaxws\build.xml 自动编译的ant脚本
下面我们把这三个文件的内容看一下
1、服务器端的service实现类文件Hello.java,
/* src\endpoint\Hello.java文件的内容 */
package endpoint;
import javax.jws.WebService;
@WebService
public class Hello
{
public String getHello(String name)
{
return "Hello " name "! ";
}
}
有这个文件可以看出,编写一个service的实现类,把编写普通的java类
差不多,只不过又多了三点
①要在该类前一个@WebService说明,
②引入javax.jws.WebService;
③在公开的方法前加@WebMethod说明,如果不加的话,
所有的public方法都会自动变成service的对外接口.
2、客户端测试类的实现文件
/* src\client\Client.java文件的内容 */
package client;
import javax.xml.ws.WebServiceRef;
import endpoint.HelloService;
import endpoint.Hello;
public class Client
{
@WebServiceRef(wsdlLocation= "http://localhost:8080/Hello/HelloService?WSDL ")
static HelloService service;
public static void main(String[] args)
{
Client client = new Client();
client.doHello();
}
public void doHello()
{
try
{
Hello port = service.getHelloPort();
String ret = port.getHello(System.getProperty( "user.name "));
System.out.println( "Hello result = " ret);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
客户端调用代码要点为:
①导入WebServiceRef包
import javax.xml.ws.WebServiceRef;
②导入本地生成的stub类,另外编译时也要指明stub类的路径
import endpoint.HelloService;
import endpoint.Hello;
③指明服务器的wsdl路径
@WebServiceRef(wsdlLocation= "http://localhost:8080/myhello/HelloService?WSDL ")
④声明一个静态的service对象
static HelloService service;
⑤对要调用的远程方法声明一个代理对象,通过代理来调用真正的远程方法
Hello port = service.getHelloPort();
String ret = port.getHello(System.getProperty( "user.name "));
3、ant 脚本build.xml
<!-- ant 脚本build.xml的内容 -->
<?xml version= "1.0 " encoding= "UTF-8 "?>
<project name= "hello-jaxws " default= "all " basedir= ". ">
<!-- include user specific build properties -->
<!-- 导入预先j2ee预先写好的设置文件-->
<property file= "../../../bp-project/build.properties "/>
<property file= "${user.home}/build.properties "/>
<property file= "../../../bp-project/app-server.properties "/>
<!-- 设置发布目录和类的输出目录 -->
<property name= "autodeploydir " value= "${javaee.domaindir}/autodeploy "/>
<property name= "classesdir " value= "./build "/>
<!-- 设置java的类库路径 -->
<path id= "classpath ">
<pathelement location= "${javaee.home}/lib/j2ee.jar "/>
<pathelement location= "${classesdir} "/>
</path>
<!-- 项目的最终任务 -->
<target name= "all " depends= "run-client ">
<!--antcall target= "restore "/-->
</target>
<!-- 测试操作系统环境-->
<target name= "init ">
<condition property= "windows ">
<os family= "windows " />
</condition>
<condition property= "unix ">
<os family= "unix " />
</condition>
</target>
<!-- 编译服务器端并把它自动发布到sun的服务器上 -->
<target name= "compile-deploy-service " depends= "init ">
<mkdir dir= "${classesdir} "/>
<echo message= "${javaee.home} "/>
<javac
srcdir= "./src "
includes= "endpoint/** "
destdir= "${autodeploydir} "
classpath= "${javaee.home}/lib/j2ee.jar "
/>
<waitfor maxwait= "100 " maxwaitunit= "second ">
<or>
<available file= "${autodeploydir}/endpoint/Hello.class_deployed "/>
<available file= "${autodeploydir}/endpoint/Hello.class_deployFailed "/>
</or>
</waitfor>
<condition property= "deploy_succeeded ">
<available file= "${autodeploydir}/endpoint/Hello.class_deployed "/>
</condition>
<condition property= "deploy_failed ">
<available file= "${autodeploydir}/endpoint/Hello.class_deployFailed "/>
</condition>
</target>
<target name= "get-artifacts " depends= "compile-deploy-service,get-artifacts-windows,get-artifacts-unix "/>
<!-- 生成客户端所需的stub -->
<target name= "get-artifacts-windows " if= "windows ">
<exec executable= "${javaee.home}/bin/wsimport.bat ">
<arg line= "-keep -d ${classesdir} http://${javaee.server.name}:${javaee.server.port}/Hello/HelloService?WSDL "/>
</exec>
</target>
<target name= "get-artifacts-unix " if= "unix ">
<exec executable= "${javaee.home}/bin/wsimport ">
<arg line= "-keep -d ${classesdir} http://${javaee.server.name}:${javaee.server.port}/Hello/HelloService?WSDL "/>
</exec>
</target>
<!-- 编译客户端 -->
<target name= "compile-client " depends= "get-artifacts ">
<javac srcdir= "./src/client " destdir= "${classesdir} ">
<classpath refid= "classpath "/>
</javac>
</target>
<target name= "run-client " depends= "compile-client,run-client-windows,run-client-unix "/>
<!-- 执行客户端 -->
<target name= "run-client-windows " if= "windows ">
<exec executable= "${javaee.home}/bin/appclient.bat " dir= "${classesdir} ">
<arg value= "client.Client "/>
</exec>
</target>
<target name= "run-client-unix " if= "unix ">
<exec executable= "${javaee.home}/bin/appclient " dir= "${classesdir} " failifexecutionfails= "false ">
<arg value= "client.Client "/>
</exec>
</target>
<!-- 以下几个任务用与清理和卸载-->
<!-- 删除生成的类文件-->
<target name= "clean ">
<delete dir= "${classesdir} "/>
</target>
<!-- 删除和卸载服务器的webservice-->
<target name= "restore ">
<delete>
<fileset dir= "${autodeploydir}/endpoint " includes= "Hello*.* "/>
</delete>
</target>
<target name= "undeploy ">
<antcall target= "restore "/>
</target>
</project>
这个脚本有许多在windows平台用不到的步骤,下面我们对其进行改造,把它精简一下.
/*title: web service入门学习笔记(五)
**date: 2007/01/18
**author:laomai
**url: http://blog.csdn.net/laomai/
*/
网友回复:
五、精简后的ant脚本
1、卸载webservice
执行原build.xml里的clean和 undeploy任务,把安装好的webservice删除掉,具体办法为:
(1)在myeclipse里打开build.xml文件
(2)在build.xml文件里单击右键菜单中的 " "run as "-> "2 ant build... " ",
(3)在弹出的对话框中只选择clean和undelpoy任务。 然后单击 "run "按钮。
此时再访问http://localhost:8080/Hello/HelloService?WSDL,出现http 404错误,说明卸载成功
2、简化后的脚本内容,在hello-jaxws目录下新建一个buildtest.xml文件,内容为
<?xml version= "1.0 " encoding= "UTF-8 "?>
<project name= "hello-jaxws " default= "all " basedir= ". ">
<!-- javaee安装目录的设置,代替了原来脚本中的导入语句 -->
<property name= "javaee.home " value = "d:/Sun/SDK "/>
<property name= "javaee.domaindir " value= "${javaee.home}/domains/domain1 "/>
<property name= "javaee.server.name " value= "localhost "/>
<property name= "javaee.server.port " value= "8080 "/>
<!-- 设置发布目录和类的输出目录 -->
<property name= "autodeploydir " value= "${javaee.domaindir}/autodeploy "/>
<property name= "classesdir " value= "./build "/>
<!-- 设置java类库路径 -->
<path id= "classpath ">
<pathelement location= "${javaee.home}/lib/j2ee.jar "/>
<pathelement location= "${classesdir} "/>
</path>
<target name= "all " depends= "run-client ">
<!--antcall target= "restore "/-->
</target>
<target name= "run-client " depends= "compile-client,run-client-windows " />
<!-- 运行测试类,为项目的最后一个步骤-->
<target name= "run-client-windows ">
<exec executable= "${javaee.home}/bin/appclient.bat " dir= "${classesdir} ">
<arg value= "client.Client " />
</exec>
</target>
<!-- 编译测试webservice的客户类,为项目的第三个步骤,本步骤的输出文件为
${classesdir}/client/Client.class
-->
<target name= "compile-client " depends= "get-artifacts ">
<javac srcdir= "./src/client " destdir= "${classesdir} ">
<classpath refid= "classpath " />
</javac>
</target>
<target name= "get-artifacts " depends= "compile-deploy-service,get-artifacts-windows "/>
<!-- 本步骤的目的是生成客户端的stub文件,是项目的第二个步骤,本步骤的输出文件为
在${classesdir}下面自动生成了如下的文件
GetHello.java
GetHelloResponse.java
Hello.java
HelloService.java
ObjectFactory.java
package-info.java
package-info.class
GetHello.class
GetHelloResponse.class
Hello.class
HelloService.class
ObjectFactory.class
-->
<target name= "get-artifacts-windows ">
<exec executable= "${javaee.home}/bin/wsimport.bat ">
<arg line= "-keep -d ${classesdir} http://${javaee.server.name}:${javaee.server.port}/Hello/HelloService?WSDL " />
</exec>
</target>
<!-- 本步骤的目的是编译服务器类,并自动产生wsdl.是项目的第一个步骤,本步骤的主要输出文件为
${autodeploydir}\endpoint\Hello.class
${autodeploydir}\domain1\autodeploy\endpoint\Hello.class_deployed
在d:\Sun\SDK\domains\domain1\applications\j2ee-modules
下建立一个endpoint_Hello目录,
在d:\Sun\SDK\domains\domain1\generated\ejb\j2ee-modules建立一个
endpoint_Hello目录,这个目录下又建立了一个endpoint\jaxws目录,里面有如下内容
GetHello.java
GetHelloResponse.java
GetHello.class
GetHelloResponse.class
在D:\Sun\SDK\domains\domain1\generated\xml\j2ee-modules\下建立一个
endpoint_Hello目录,这个目录下又有一个WEB-INF子目录,内容为
wsdl子目录
sun-web.xml 文件
web.xml 文件
webservices.xml 文件
wsdl子目录下又有两个文件
HelloService.wsdl
HelloService_schema1.xsd
当我们在浏览器输入http://localhost:8080/Hello/HelloService?WSDL时,显示的正是
这个domains\domain1\generated\xml\j2ee-modules\endpoint_Hello\WEB-INF\wsdl
文件的内容
-->
<target name= "compile-deploy-service ">
<mkdir dir= "${classesdir} " />
<echo message= "${javaee.home} " />
<javac
srcdir= "./src "
includes= "endpoint/** "
destdir= "${autodeploydir} "
classpath= "${javaee.home}/lib/j2ee.jar "
/>
<waitfor maxwait= "100 " maxwaitunit= "second ">
<or>
<available file= "${autodeploydir}/endpoint/Hello.class_deployed "/>
<available file= "${autodeploydir}/endpoint/Hello.class_deployFailed "/>
</or>
</waitfor>
<condition property= "deploy_succeeded ">
<available file= "${autodeploydir}/endpoint/Hello.class_deployed "/>
</condition>
<condition property= "deploy_failed ">
<available file= "${autodeploydir}/endpoint/Hello.class_deployFailed "/>
</condition>
</target>
<!-- 以下的任务用于清理和卸载-->
<target name= "clean ">
<delete dir= "${classesdir} "/>
</target>
<target name= "restore ">
<delete>
<fileset dir= "${autodeploydir}/endpoint " includes= "Hello*.* "/>
</delete>
</target>
<target name= "undeploy ">
<antcall target= "restore "/>
</target>
</project>
3、运行结果
在myeclipse里执行这个刚才编写的buildtest.xml脚本,console里的输出为
Buildfile: D:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\buildtest.xml
compile-deploy-service:
[mkdir] Created dir: D:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\build
[echo] d:/Sun/SDK
[javac] Compiling 1 source file to D:\Sun\SDK\domains\domain1\autodeploy
get-artifacts-windows:
get-artifacts:
compile-client:
[javac] Compiling 1 source file to D:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\build
run-client-windows:
[exec] Hello result = Hello Administrator!
run-client:
all:
BUILD SUCCESSFUL
Total time: 50 seconds
也执行成功
网友回复:/*title: web service入门学习笔记(六)
**date: 2007/01/19
**author:laomai
**url: http://blog.csdn.net/laomai/
*/
六、一个通用的ant脚本
1、脚本内容
上面的buildtest.xml脚本虽然对原始的build.xml做了精简,但是还不够通用,
比如服务器的类名和方法名等等都写死了,显然还不适合我们的需要,于是我又写了一个相对通用的脚本
mybuild.xml,内容如下
<?xml version= "1.0 " encoding= "UTF-8 "?>
<project name= "hello-jaxws " default= "all " basedir= ". ">
<!-- javaee安装目录的设置,代替了原来脚本中的导入语句 -->
<property name= "javaee.home " value = "d:/Sun/SDK "/>
<property name= "javaee.domaindir " value= "${javaee.home}/domains/domain1 "/>
<property name= "javaee.server.name " value= "localhost "/>
<property name= "javaee.server.port " value= "8080 "/>
<!-- 设置发布目录和类的输出目录 -->
<property name= "autodeploydir " value= "${javaee.domaindir}/autodeploy "/>
<property name= "classesdir " value= "./build "/>
<!-- 设置java类库路径 -->
<path id= "classpath ">
<pathelement location= "${javaee.home}/lib/j2ee.jar "/>
<pathelement location= "${classesdir} "/>
</path>
<!-- 提供服务的类名 -->
<property name= "serviceclass " value= "Hello " />
<property name= "serverclasspath " value= "endpoint " /> <!-- 服务器所在的package名称
也就是Hello.java文件中第一句
package endpoint;语句中的endpoint
-->
<!-- 调用webservice的测试类名-->
<property name = "clientclass " value= "Client "/>
<property name = "clientclasspath " value= "client "/> <!-- 测试类所在的package名称,
也就是Client.java文件中第一句
package client;语句中的client;
-->
<!-- 生成的wsdl文件的uri的格式,注意value的值分成两行写时有问题,
这里为了阅读方便而分行,拷贝时必须放到一行
我还没找到ant脚本里的续行符是什么:-(
-->
<property name= "wsdluri "
value= "http://${javaee.server.name}:${javaee.server.port}
/${serviceclass}/${serviceclass}Service?WSDL " />
<target name= "all " depends= "run-client ">
<!-- antcall target= "restore "/ -->
</target>
<target name= "run-client " depends= "compile-client,run-client-windows " />
<!-- 运行测试类,为项目的最后一个步骤-->
<target name= "run-client-windows ">
<exec executable= "${javaee.home}/bin/appclient.bat " dir= "${classesdir} ">
<arg value= "${clientclasspath}.${clientclass} " />
</exec>
</target>
<!-- 编译测试webservice的客户类,为项目的第三个步骤,本步骤的输出文件为
${classesdir}/client/Client.class
-->
<target name= "compile-client " depends= "get-artifacts ">
<javac srcdir= "./src/${clientclasspath} " destdir= "${classesdir} ">
<classpath refid= "classpath " />
</javac>
</target>
<target name= "get-artifacts " depends= "compile-deploy- ②asadmin deploy --user admin --password laomailaomai --host localhost --port 4848 --contextroot hello --upload=true --target server
service,get-artifacts-windows "/>
<!-- 生成客户端的stub类 -->
<target name= "get-artifacts-windows ">
<exec executable= "${javaee.home}/bin/wsimport.bat ">
<arg line= "-keep -d ${classesdir} ${wsdluri} " />
</exec>
</target>
<!-- 本步骤的目的是编译服务器类,并自动产生wsdl文件-->
<target name= "compile-deploy-service ">
<echo message= "${javaee.home} " />
<javac
srcdir= "./src "
includes= "${serverclasspath}/** "
destdir= "${autodeploydir} "
classpath= "${javaee.home}/lib/j2ee.jar "
/>
<waitfor maxwait= "100 " maxwaitunit= "second ">
<or>
<available file= "${autodeploydir}/${serverclasspath}/${serviceclass}.class_deployed "/>
<available file= "${autodeploydir}/${serverclasspath}/${serviceclass}.class_deployFailed "/>
</or>
</waitfor>
<condition property= "deploy_succeeded ">
<available file= "${autodeploydir}/${serverclasspath}/${serviceclass}.class_deployed "/>
</condition>
<condition property= "deploy_failed ">
<available file= "${autodeploydir}/${serverclasspath}/${serviceclass}.class_deployFailed "/>
</condition>
</target>
<!-- 以下的任务用于清理和卸载-->
<target name= "clean ">
<delete dir= "${autodeploydir}/${serverclasspath} "/>
<delete dir= "${classesdir}/${serverclasspath} "/>
<delete dir= "${classesdir}/${clientclasspath} "/>
</target>
</project>
2、脚本的使用方式
以后再写自己service时,只要按实际情况改变以下4条语句中的value值就可以了
<property name= "serviceclass " value= "Hello " />
<property name= "serverclasspath " value= "endpoint " />
<property name = "clientclass " value= "Client "/>
<property name = "clientclasspath " value= "client "/>
/*title: web service入门学习笔记(七)
**date: 2007/01/19
**author:laomai
**url: http://blog.csdn.net/laomai/
*/
网友回复:七、命令行开发过程
通过以上的学习,我们知道如何在ant脚本和ide环境中开发一个简单的webservice.
但是作为搞技术的人特别是搞c的人来看,上面的过程隐藏了太多的东西,
对我们有钻研精神的人,自然就想搞清楚脚本背后的过程。
假设我们的机器上没有ide环境和ant工具,
我们如何“手工”编译出自己的webservice呢?
这就是本节要讲述的内容--只用命令行工具开发webservice.
0、设置环境变量
把jdk和javaee的路径如
D:\Java\jdk1.6.0
D:\Sun\SDK\bin加到系统的path变量中去
1、建立项目目录
首先建立一个项目的目录,名为WebTest,项目目录下又包含三个子目录
src\ 本目录用于存放源代码,
build\ 本目录用于存放输出的文件
deploy\ 本目录用于对服务器打包
2、编写服务器类实现文件
在项目的src目录下建立一个个子目录endpoint,
在这个endpoint子目录下新建一个Hello.java文件,内容如下
/*src\endpoint\Hello.java文件
提供webservice的服务器端实现类
*/
package endpoint;
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService
public class Hello
{
@WebMethod
public String getHello(String name)
{
return "Hello " name "! ";
}
}
3、编译服务器类
①在build目录下建立一个子目录classes
②在命令行执行如下命令
cd WebTest ;进入项目目录
javac -classpath d:/Sun/SDK/lib/javaee.jar -d ./build/classes src/endpoint/Hello.java ;编译服务器类
执行完后会产生一个build\classes\endpoint\Hello.class文件
4、生成wsdl文件
①在build目录下建立一个子目录generated
②生成wsdl文件,执行
wsgen -cp ./build/classes -keep -d ./build/classes -r ./build/generated -wsdl endpoint.Hello
执行完成会在./build/generated产生两个文件
HelloService.wsdl
HelloService_schema1.xsd
并且在\build\class\endpoint下建立一个jaxws目录,下面有4个文件
GetHello.java
GetHello.class
GetHelloResponse.java
GetHelloResponse.class
这些文件与与前面所说的ant脚本中生成的
D:\Sun\SDK\domains\domain1\generated\ejb\j2ee-modules\endpoint_Hello\endpoint\jaxws
下的文件相同
5、将服务器打包,做成war文件
①建立打包所需要的目录
在项目的deploy目录下建立一个子目录/WEB-INF,
WEB-INF子目录下再建立两个子目录
classes/ 用于存放服务器端类
wsdl/ 用于存放wsdl文件
②将各输出文件或目录拷贝到相应的目录下
(1)把build\classes\endpoint整个目录拷贝到deploy/WEB-INF/class目录下
(2)把build\generated目录下的两个文件
HelloService.wsdl、HelloService_schema1.xsd拷贝到
deploy/WEB-INF/wsdl目录下
③在deploy/WEB-INF/ 目录下新建一个web.xml文件,内容为
<?xml version= "1.0 " encoding= "UTF-8 "?>
<web-app xmlns= "http://java.sun.com/xml/ns/javaee "
xmlns:j2ee= "http://java.sun.com/xml/ns/javaee "
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance " version= "2.5 "
xsi:schemaLocation= "http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">
<description> WebTier for the Hello Service </description>
<display-name> HelloWAR </display-name>
<servlet>
<description> Endpoint for Hello Web Service </description>
<display-name> HelloWebService </display-name>
<servlet-name> Hello </servlet-name>
<servlet-class> endpoint.Hello </servlet-class>
<load-on-startup> 0 </load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name> Hello </servlet-name>
<url-pattern> /HelloService </url-pattern>
</servlet-mapping>
<session-config>
<session-timeout> 54 </session-timeout>
</session-config>
</web-app>
④将service打包,执行
(1)cd WebTest\deploy ;进入打包目录
(2)jar cvf hello.war * ;将当前目录下的所有内容打包到hello.war文件中
网友回复:6、将service 类发布到网络服务器上
①启动sun 服务器
方法为
开始-> 程序-> Sun Microsystems-> Application Server PE 9-> Start Default Server
②在项目目录下建立一个passwd文件,内容是sun服务器admin用户的密码,例如
AS_ADMIN_PASSWORD=testtesttest
③将hello.war发布到服务器上,执行
(1)cd WebTest ;进入项目目录
(2)发布服务器包,注意这个命令是在一行执行的,
我为了书写方便而断行。分号后面是注释
asadmin deploy
--user admin ;管理员用户名
--passwordfile passwd ;密码文件名,就是我们刚才写的passwd文件
--host localhost
--port 4848 ;管理端口号
--contextroot myhello ;上下文根名称
--upload=true
--target server
deploy/hello.war
④在浏览器中输入地址
http://localhost:8080/myhello/HelloService?WSDL,
如果浏览器能显示出正确的内容,就说明成功。
7、生成客户端的stub类
①在项目的build\classes目录下建立一个stub子目录
②执行
(1)cd WebTest ;进入项目子目录
(2)wsimport -keep -d ./build/classes/stub http://localhost:8080/myhello/HelloService?WSDL
执行完成后会在build/classes/stub下建立一个endpoint目录,下面有这些文件
GetHello.java
GetHelloResponse.java
Hello.java
HelloService.java
GetHello.class
GetHelloResponse.class
Hello.class
HelloService.class
ObjectFactory.class
ObjectFactory.java
package-info.java
package-info.class
这些文件和ant脚本中import执行的结果一样
8、编写客户端测试程序
在项目的src目录下建立一个子目录client,在这个目录下面建立一个
Client.java文件,内容为
// src\client\Client.java文件 调用服务器提供的webservice的测试类
package client;
import javax.xml.ws.WebServiceRef;
import endpoint.HelloService;
import endpoint.Hello;
public class Client
{
@WebServiceRef(wsdlLocation= "http://localhost:8080/myhello/HelloService?WSDL ")
static HelloService service;
public static void main(String[] args)
{
Client client = new Client();
client.doHello();
}
public void doHello()
{
try
{
Hello port = service.getHelloPort();
String ret = port.getHello(System.getProperty( "user.name "));
System.out.println( "Hello result = " ret);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
9、编译客户端程序
执行
(1)cd WebTest ;进入项目目录
(2)javac -classpath ./build/classes/stub;d:/Sun/SDK/lib/javaee.jar;d:/Sun/SDK/lib/appserv-ws.jar -d ./build/classes/stub src/client/Client.java
执行成功后会在F:\exercise\java\WebTest\build\classes目录下建立一个
client目录,下面有一个Client.class文件
10、运行客户端程序
(1)cd WebTest\build\classes\stub ;进入client的上级目录
(2)set APPCPATH=. ;设置环境变量APPCPATH,不然运行appclient程序时会出一堆莫名奇妙的错误
(3)> appclient client.Client运行测试程序,结果为
Hello result = Hello Administrator!
执行成功
网友回复:/*title: web service入门学习笔记(八)
**date: 2007/01/19
**author:laomai
**url: http://blog.csdn.net/laomai/
*/
八、小结
开发webservice的基本步骤为
1、编写服务器端,要点有
①导入WebService包和WebMethod包
import javax.jws.WebService;
import javax.jws.WebMethod;
②实现的服务类前加@WebService符号
③为了代码清晰,类提供的公开方法前加@WebMethod符号,这个不写对编译也没影响,
2、编译服务器端,要点为
①javac命令的classpath选项中要有javaee.jar的路径,如
javac -classpath d:/Sun/SDK/lib/javaee.jar -d ./build src/endpoint/Hello.java
②用wsgen命令生成wsdl文件.
③将服务器端打包
注意如果是sun的服务器,那么把service类直接编译到
javaee5安装目录\domains\domain1\autodeploy下,可以自动完成②和③的工作。
我们介绍的sun自带的入门脚本就是这么做的。
3、在客户端机器上自动生成stub类,要点为
①客户机上必须也装有jdk和javaee5
②用wsimport工具将服务器传过来的wsdl文件转换成本地的stub类
4、编写客户端调用代码,要点:
①导入WebServiceRef包
import javax.xml.ws.WebServiceRef;
②导入本地生成的stub类,如
import endpoint.HelloService;
import endpoint.Hello;
③指明服务器的wsdl路径
@WebServiceRef(wsdlLocation= "http://localhost:8080/myhello/HelloService?WSDL ")
④声明一个静态的service对象
static HelloService service;
⑤对要调用的远程方法声明一个代理对象,通过代理来调用真正的远程方法
Hello port = service.getHelloPort();
String ret = port.getHello(System.getProperty( "user.name "));
5、编译客户端调用程序,注意classpath参数中要有
①stub类的路径
②javaee.jar的路径
③appserv-ws.jar的路径
6、用appclient执行客户端程序,要点为
①进入到客户端程序的上级目录
②把APPCPATH的值设置为当前目录 " . "
③appclient的第一个参数为客户端程序名,
后面的参数是传给客户端程序本身的命令行参数。
/*title: web service入门学习笔记(九)
**date: 2007/01/19
**author:laomai
**url: http://blog.csdn.net/laomai/
*/
九、本文中用到的文件
1、WebTest项目文件列表
WebTest\passwd 保存密码的文件,手工建立
WebTest\src 子目录 手工建立,内容为
endpoint\Hello.java 服务器类的实现文件
client\Client.java 客户类的实现文件
WebTest\build
generated 子目录,手工建立,内容为
HelloService.wsdl 由wsgen命令生成
HelloService_schema1.xsd 由wsgen命令生成
classes 子目录,手工建立,内容为
endpoint\Hello.class 由javac命令生成
endpoint\jaxws子目录,由wsgen命令自动生成,内容为
GetHello.java
GetHelloResponse.java
GetHello.class
GetHelloResponse.class
stub 子目录,手工建立,内容为:
client\Client.class 由javac命令生成
endpoint 子目录 由wsimport命令自动生成,内容为:
GetHello.java
GetHelloResponse.java
Hello.java
HelloService.java
ObjectFactory.java
package-info.java
package-info.class
GetHello.class
GetHelloResponse.class
Hello.class
HelloService.class
ObjectFactory.class
WebTest\deploy子目录 手工建立,内容为
hello.war 将WEB-INF子目录打包后生成的文件,由jar命令生成
WEB-INF 打包的输入目录,手工建立。内容包括:
web.xml 手工建立
classes\endpoint子目录 为build\classes\endpoint的拷贝
wsdl子目录,由build\generated拷贝而来
2、生成的HelloService.wsdl文件的内容
<?xml version= "1.0 " encoding= "UTF-8 " standalone= "yes "?>
<definitions targetNamespace= "http://endpoint/ " name= "HelloService " xmlns= "http://schemas.xmlsoap.org/wsdl/ " xmlns:tns= "http://endpoint/ " xmlns:xsd= "http://www.w3.org/2001/XMLSchema " xmlns:soap= "http://schemas.xmlsoap.org/wsdl/soap/ ">
<types>
<xsd:schema>
<xsd:import namespace= "http://endpoint/ " schemaLocation= "HelloService_schema1.xsd "/>
</xsd:schema>
</types>
<message name= "getHello ">
<part name= "parameters " element= "tns:getHello "/>
</message>
<message name= "getHelloResponse ">
<part name= "parameters " element= "tns:getHelloResponse "/>
</message>
<portType name= "Hello ">
<operation name= "getHello ">
<input message= "tns:getHello "/>
<output message= "tns:getHelloResponse "/>
</operation>
</portType>
<binding name= "HelloPortBinding " type= "tns:Hello ">
<soap:binding transport= "http://schemas.xmlsoap.org/soap/http " style= "document "/>
<operation name= "getHello ">
<soap:operation soapAction= " "/>
<input>
<soap:body use= "literal "/>
</input>
<output>
<soap:body use= "literal "/>
</output>
</operation>
</binding>
<service name= "HelloService ">
<port name= "HelloPort " binding= "tns:HelloPortBinding ">
<soap:address location= "REPLACE_WITH_ACTUAL_URL "/>
</port>
</service>
</definitions>
十、致谢
在学习WebService的过程中,我得到了csdn java版的叶锋城朋友的许多指点,
饼子堂的兄弟们也给了很多有用的资料,这里一并表示谢意。本文也算是我给这些
朋友们的一个汇报和总结,呵呵。
(--end
/*title: web service入门学习笔记
**date: 2007/01/23
**author:laomai
**url: http://blog.csdn.net/laomai/*/)
网友回复:奉旨顶楼.顶.
网友回复:抢位子.. 呵呵
网友回复:可怜 的村长
网友回复:老迈村长(00000000) 12:12:34
http://community.csdn.net/Expert/topic/5313/5313082.xml?temp=.5064661
老迈村长(00000000) 12:12:39
去帮我顶起来
网友回复:还好,表扬一下:)
网友回复:没学过,关注ing
网友回复:老迈村长(00000000) 12:12:34
http://community.csdn.net/Expert/topic/5313/5313082.xml?temp=.5064661
老迈村长(00000000) 12:12:39
去帮我顶起来
网友回复:老迈村长(00000000) 12:12:34
http://community.csdn.net/Expert/topic/5313/5313082.xml?temp=.5064661
老迈村长(00000000) 12:12:39
去帮我顶起来
网友回复:老迈村长(00000000) 12:12:34
http://community.csdn.net/Expert/topic/5313/5313082.xml?temp=.5064661
老迈村长(00000000) 12:12:39
去帮我顶起来
网友回复:写得不错啊,我很容易就看懂了。
感觉web services挺像ejb,
差别在于获得远程服务对象
web services用的是通过http的web services规范,
ejb是通过rmi的ejb规范。
网友回复:学习
网友回复:mark
网友回复:mark
网友回复:mark
网友回复:谢谢~分享~
网友回复:感谢楼主。。。
网友回复:学习下
网友回复:收藏中
网友回复:顶
网友回复:mark
网友回复:脚印, 晚上看
网友回复:good
网友回复:谢谢!
网友回复:Very Good!
网友回复:o
网友回复:mark
网友回复:mark
网友回复:还没用到web service
先mark下,以后用方便查,谢谢楼主
网友回复:mark
网友回复:Webservice是个好东西,用于大型和分布系统的集成非常好.
大雁软件
Tiger
<a href=www.szdayan.com target=_blank> 大雁协同办公 </a>
网友回复:怎么复杂?
网友回复:用myeclipse的xfire做webservice,就跟用vs.net做webservice一样方便。
无论是服务端,还是客户端,都是鼠标点几下,无需什么配置脚本,就可以生成一个完整的框架。
楼主可能是linux出身,喜欢搞些脚本配置
我windows出身,就喜欢指指点点。
你直接上不就行了,费那事干吗(出自疯狂的石头)
网友回复:学习
网友回复:MARK
网友回复:先mark,再好好看一下.
网友回复:学习
网友回复:mark
网友回复:mark
网友回复:mark
网友回复:mark
网友回复:支持,我突然想起j2se sdk和j2ee sdk有什么区别。
网友回复:.net好象和這個不一樣啊?
网友回复:学习兼顶帖
网友回复:能不能不用ant工具 讲解一下啊 谢谢楼主
网友回复:收藏,有空看看
网友回复:mars50887355() ( ) 信誉:95 Blog 2007-01-25 09:19:54 得分: 0
能不能不用ant工具 讲解一下啊 谢谢楼主
-----------------------------------------------------
我的第七部分就是讲如何用纯命令行开发的啊。
网友回复:建议老迈继续写出 WEB Service 传递对象的 教程
网友回复:Buildfile: C:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\build.xml
init:
compile-deploy-service:
[echo] C:/Sun/SDK
get-artifacts-windows:
get-artifacts-unix:
get-artifacts:
compile-client:
[javac] Compiling 1 source file to C:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\build
[javac] C:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\src\client\Client.java:10: 无法访问 endpoint.HelloService
[javac] 错误的类文件: C:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\build\endpoint\HelloService.class
[javac] 类文件具有错误的版本 50.0,应为 49.0
[javac] 请删除该文件或确保该文件位于正确的类路径子目录中。
[javac] import endpoint.HelloService;
[javac] ^
[javac] 1 错误
BUILD FAILED
C:\Sun\SDK\samples\javaee5\webservices\hello-jaxws\build.xml:92: Compile failed; see the compiler error output for details.
Total time: 8 seconds
------------------------------------------------------------------------------
我按照你的步骤,使用Eclipse,运行build.xml,出现了这种错误,怎样解决?谢谢
网友回复:C:\> C:\Sun\SDK\lib\asadmin-pause.bat start-domain domain1
Starting Domain domain1, please wait.
Log redirected to C:\Sun\SDK\domains\domain1\logs\server.log.
Domain domain1 does not exist in C:\Sun\SDK\domains. Use a different domain nam
e or the --domaindir option.
CLI156 Could not start the domain domain1.
请按任意键继续. . .
网友回复:④在浏览器中输入地址
http://localhost:8080/myhello/HelloService?WSDL,
如果浏览器能显示出正确的内容,就说明成功。
楼主,出错了....
---------
HTTP Status 404 - Servlet Hello is not available
--------------------------------------------------------------------------------
type Status report
message Servlet Hello is not available
description The requested resource (Servlet Hello is not available) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.9
网友回复:iwlk(http://www.JDict.org 已经推出)
看看你的8080端口是不是被别的服务器占用了?
yongtaowei()
把jdk1.6的路径加到path变量里去,并且保证它是path变量里的第一个java编译路径,如果你用了别的javac编译,可能就会出问题
网友回复:iwlk(http://www.JDict.org 已经推出)
另外确定你的javaee5是完整安装的么?
网友回复:写得很详细,谢谢LZ!!!
网友回复:谢谢楼主
网友回复:帮顶!!
网友回复:在文章第七部分命令行编辑语句:D:\eclipse3.1.2\workspace\WebTest〉wsgen -cp ./build/classes -keep -d ./build/classes -r ./build/generated -wsdl endpoint.Hello时出错:modeler error: A webservice endpoint could not be found
步骤都是按照你的说明,Hello.class也生成了,但是为什么不能生成wsdl文件呢,急
网友回复:lz,怎么没回复呢
网友回复:都被楼主引入歧途了。
网友回复:olivelovelive()
在文章第七部分命令行编辑语句:D:\eclipse3.1.2\workspace\WebTest〉wsgen -cp ./build/classes -keep -d ./build/classes -r ./build/generated -wsdl endpoint.Hello时出错:modeler error: A webservice endpoint could not be found
步骤都是按照你的说明,Hello.class也生成了,但是为什么不能生成wsdl文件呢,急
你确定是完全按照我的步骤做的么?./build/generated目录建立了么?
前面的编译输出结果和我的一直不?
网友回复:楼上,你用新建=》项目.webservice project 试试。
然后再用 新建=》项目==》Myeclipse.j2eeproject.webservice client试试。
网友回复:分享精神可佳
网友回复:谢谢lz的分享啊,,,,感谢大公无私
网友回复:无言了, 你们都用记事本去开发MIS去吧。
网友回复:刚开始学这个,顶一下罗!
网友回复:无言了, 你们都用记事本去开发MIS去吧。
=========================================================
你不要用笔记本去开发MIS,但是你需要知道如何用笔记本去开发MIS。
你需要知道那些美丽的IDE在你的背后都做了些什么事情,否则你就永远只能靠着他了。
网友回复:无言了, 你们都用记事本去开发MIS去吧。
=========================================================
你不要用笔记本去开发MIS,但是你需要知道如何用笔记本去开发MIS。
你需要知道那些美丽的IDE在你的背后都做了些什么事情,否则你就永远只能靠着他了。
==================
背后在做什么啊。
不就是些
(1)把build\classes\endpoint整个目录拷贝到deploy/WEB-INF/class目录下
(2)把build\generated目录下的两个文件
HelloService.wsdl、HelloService_schema1.xsd拷贝到
deploy/WEB-INF/wsdl目录下
吗?
不就是些配置吗?
请问,用VB的时候,你是不是想用记事本去编辑.frm文件,自己用键盘设置窗口控件的属性?
网友回复:呵呵,可以阿。
不知道IDE能不能帮你实现自动化部署,帮你实现每日构建,帮你实现无人值守的自动化测试。
还有,当IDE需要和生成的一些信息被意外破坏后你是不是还要重新用IDE去重新生成整个项目。
我没有说要用笔记本去开发,而是你应该知道背后都做了什么
网友回复:对于webserivce来说,真的没有必要知道服务器怎么配置,客户端存根类怎么手写。
网友回复:背后,无非就是一些 尖括号和百分号 。
网友回复:是嘛,那就出现错误就等着看着异常发呆好了
网友回复:这里有大量JAVA6 WEB SERVICE的文章
http://www.blogjava.net/vip01
网友回复:异常
只怕手工去改 ! < ; 出现异常的机会更多吧
我用myecplise的时候
只要输入http://w.w.w.com/aa?wsdl,就可以得到一个创建好的类及其方法。
这个类就是wsdl描述的类结构。
这有什么需要懂内部工作机制的? 不就是wsdl语言到class语言的转换吗?
写内嵌浏览器程序的时候,没听说过谁要自己开发html解释器的。
网友回复:看下面的代码,全部都是myecplise给我生成的。
我只需要知道s1PortType对象是我要用的远程对象。
我只需要在这个对象名称后面输入一个.,选择一个方法,就可以调用了。
package defaultnamespace;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService(name = "s1PortType ", targetNamespace = "http://DefaultNamespace ")
@SOAPBinding(use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public interface s1PortType {
@WebMethod(operationName = "example ", action = " ")
@WebResult(name = "out ", targetNamespace = "http://DefaultNamespace ")
public String example(
@WebParam(name = "in0 ", targetNamespace = "http://DefaultNamespace ")
String in0);
}
package defaultnamespace;
import java.net.MalformedURLException;
import java.util.Collection;
import java.util.HashMap;
import javax.xml.namespace.QName;
import org.codehaus.xfire.XFireRuntimeException;
import org.codehaus.xfire.aegis.AegisBindingProvider;
import org.codehaus.xfire.annotations.AnnotationServiceFactory;
import org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.jaxb2.JaxbTypeRegistry;
import org.codehaus.xfire.service.Endpoint;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.soap.AbstractSoapBinding;
import org.codehaus.xfire.transport.TransportManager;
public class s1Client {
private static XFireProxyFactory proxyFactory = new XFireProxyFactory();
private HashMap endpoints = new HashMap();
private Service service0;
public s1Client() {
create0();
Endpoint s1HttpPortEP = service0.addEndpoint(new QName(
"http://DefaultNamespace ", "s1HttpPort "), new QName(
"http://DefaultNamespace ", "s1HttpBinding "),
"http://127.0.0.1:8080/wsTest/services/s1 ");
endpoints.put(new QName( "http://DefaultNamespace ", "s1HttpPort "),
s1HttpPortEP);
Endpoint s1PortTypeLocalEndpointEP = service0.addEndpoint(new QName(
"http://DefaultNamespace ", "s1PortTypeLocalEndpoint "),
new QName( "http://DefaultNamespace ", "s1PortTypeLocalBinding "),
"xfire.local://s1 ");
endpoints.put(new QName( "http://DefaultNamespace ",
"s1PortTypeLocalEndpoint "), s1PortTypeLocalEndpointEP);
}
public Object getEndpoint(Endpoint endpoint) {
try {
return proxyFactory.create((endpoint).getBinding(), (endpoint)
.getUrl());
} catch (MalformedURLException e) {
throw new XFireRuntimeException( "Invalid URL ", e);
}
}
public Object getEndpoint(QName name) {
Endpoint endpoint = ((Endpoint) endpoints.get((name)));
if ((endpoint) == null) {
throw new IllegalStateException( "No such endpoint! ");
}
return getEndpoint((endpoint));
}
public Collection getEndpoints() {
return endpoints.values();
}
private void create0() {
TransportManager tm = (org.codehaus.xfire.XFireFactory.newInstance()
.getXFire().getTransportManager());
HashMap props = new HashMap();
props.put( "annotations.allow.interface ", true);
AnnotationServiceFactory asf = new AnnotationServiceFactory(
new Jsr181WebAnnotations(), tm, new AegisBindingProvider(
new JaxbTypeRegistry()));
asf.setBindingCreationEnabled(false);
service0 = asf.create((defaultnamespace.s1PortType.class), props);
{
AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
new QName( "http://DefaultNamespace ",
"s1PortTypeLocalBinding "),
"urn:xfire:transport:local ");
}
{
AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
new QName( "http://DefaultNamespace ", "s1HttpBinding "),
"http://schemas.xmlsoap.org/soap/http ");
}
}
public defaultnamespace.s1PortType gets1HttpPort() {
return ((defaultnamespace.s1PortType) (this).getEndpoint(new QName(
"http://DefaultNamespace ", "s1HttpPort ")));
}
public defaultnamespace.s1PortType gets1HttpPort(String url) {
defaultnamespace.s1PortType var = gets1HttpPort();
org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
return var;
}
public defaultnamespace.s1PortType gets1PortTypeLocalEndpoint() {
return ((defaultnamespace.s1PortType) (this).getEndpoint(new QName(
"http://DefaultNamespace ", "s1PortTypeLocalEndpoint ")));
}
public defaultnamespace.s1PortType gets1PortTypeLocalEndpoint(String url) {
defaultnamespace.s1PortType var = gets1PortTypeLocalEndpoint();
org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
return var;
}
public static void main(String[] args) {
s1Client client = new s1Client();
//create a default service endpoint
defaultnamespace.s1PortType s1PortType = client.gets1HttpPort();
//TODO: Add custom client code here
//
s1PortType.example( "aa ");
System.out.println( "test client completed ");
System.exit(0);
}
}
网友回复:mark
网友回复:先顶,仔细学
网友回复:该回复于2008-08-30 06:44:56被管理员或版主删除
网友回复:学习当中,十分感谢!
网友回复:现在就需要这样的好东东呀。
谢谢!!!!
网友回复:DING QI
网友回复:mark
网友回复:还有人在吗?
三、WebService的本质
从搞c的程序员的眼光来看,webservice实际上就是用java实现的rpc(远端过程调用),
或者说是dll的变形。服务器把它的接口对外发布成一个wsdl文件,客户端根据这个wsdl的内容生成
本地的代理类,再通过代理类调用远端的接口,代理再把接口的执行执行结果回传给客户端,
进行下一步处理。
为什么java要有web service ,实现远端过程调用不是有RMI么?
网友回复:ding
网友回复:为什么java要有web service ,实现远端过程调用不是有RMI么?
----------------------------------------------------------
由此证明,webservice绝不是远端过程这么简单的
网友回复:good man!
网友回复:jijl2001(jijl2001) ( ) 信誉:100 Blog 2007-3-29 16:25:08 得分: 0
为什么java要有web service ,实现远端过程调用不是有RMI么?
----------------------------------------------------------
由此证明,webservice绝不是远端过程这么简单的
在我这个搞C的人的眼里,webservice就相当于一个异地的dll而已,呵呵
网友回复:这里有解决的办法啊?http://www.javadingle.com
网友回复:ding
网友回复:路过
网友回复:MARK
网友回复:ding
网友回复:感谢楼主,这几天正要用这个东西,到处在找资料
网友回复:MARK
网友回复:有问题,去http://tonymao777.blog.163.com留言,
只解答有关eclipse、axis、mysql、uddi、jsp等,不一定都能解答,但你可以try!
也可以一起探讨……
网友回复:先mark, for using in the future
网友回复:mark, for using in the future
网友回复:mark~~
网友回复:顶起来
网友回复:we only has java class code,not source file,and has 't been allowed to deploy a java Web Server !Can we call java code using .net,and how to do this?thx.I has no idea ,thx to everyone!
网友回复:upupupupupup
网友回复:别老是转别人的帖子,自己动手调通一个再说
网友回复:为什么java要有web service ,实现远端过程调用不是有RMI么?
--------------------------------------------------------
关键词:主要是标准,而不是技术。
关于如何通过网络实现远程过程调用问题都属于如何通过网络构建软件编程模式的问题,这种技术在web service之前不是没有,多的是,有些甚至在如火如荼的用着,但都有一个缺陷,就是缺乏统一标准,各自为政,由此也产生一个问题,就是难以普及,构建成本相对也就较高。
这里出现一问题,就是为什么难以普及?原因就是每个公司提出的技术谁都说服不了谁。那么web service 怎么就能说服别人了?原因是web service 采用的技术不是自己创新的,而是本来就存在的,而且是已经普及了的标准,这些标准是什么?大家其实都应该已明白,那就是web和XML,这两个东西是已存在的老技术吧!够标准吧,够普及吧,所以也难怪web service 会成功了。
这里进一步说明一问题,就是为什么web和XML就能让web service 成功了?原因如下:
1、因为它沿用的是老技术,所以相比之下它这种模型不是复杂了,而是简单了,人们容易理解,容易接受。
2、大凡远程调用需解决的问题无非就是通信和接口问题,采用web的http通信协议作为web service 的基础通信协议,不仅是现成的,而且总是最有效的,因为80端口一般都开放的。而采用XML作为接口描述协议原因主要有二:a、它的文本特性容易被标准化,因为文本格式是哪种机器都具备的,起码绝大多数是;b、XML描述信息的能力比现存在的哪种标记语言都强而且都简单,它的层次性描述能力,正是web service 所青睐的。
3、由于http和xml的特性,很容易让web service 在环球范围内建立起具有真正松散耦合特性的程序编程模型,松散耦合意味着机器与机器之间只要遵循一定的协议(重要的是这些协议是简单性的和通用性的,比如http和xml等),就可进行有效的调用,它给我们的直接效果是较其他模型它可大大减少烦人的机器与机器之间的依赖性,这样就可让我们在环球范围内组建真正的基于自由构件块的软件开发平台,就象本地的com组件和网域的Dcom所试图追求的标准境界那样,而web service 则不仅做到了这样的境界,而且做得更好,因为它不仅是有效的,而且是简单的、开放的和低廉的。
网友回复:不错啊,很好!
网友回复:请介绍些资料给超级初学者!
主要能够说明,webservice ,ejb,javabean,j2ee,j2se。。等等概念之间的关系,让初学者能构知道,要实现什么,需要了解什么。
比如我:想实现webservic调用,需要那些基础知识?
j2se还是j2ee?
ejb还是javabean?
eclipse还是jbuilder?
????
网友回复:UP
网友回复:很好
网友回复:谢谢楼主!
网友回复:mark
网友回复:mark
网友回复:up up
网友回复:mark
thanks
网友回复:好
正在学习中。。。
网友回复: <target name= "get-artifacts " depends= "compile-deploy-②asadmin deploy --user admin --password laomailaomai --host localhost --port 4848 --contextroot hello --upload=true --target server
service,get-artifacts-windows "/>
compile-deploy-②asadmin这是什么意思?
网友回复:mark
网友回复:mark
网友回复:太深了,看不懂啊
网友回复:我顶
网友回复:we only has java class code,not source file,and has 't been allowed to deploy a java Web Server !Can we call java code using .net,and how to do this?thx.I has no idea ,thx to everyone!
------------------------------------------------------------------------------
Web Services Interoperability Technologies
(WSIT)—a product of Sun Microsystems web services interoperability
effort to develop Java clients and service providers that interoperate with
Microsoft .NET clients and service providers.
但是用WSIT只能在SUN的服务器上跑
网友回复:学习
网友回复: 感谢CCTV,感谢CSDN,感谢党,感谢楼主!
网友回复:挺好,有空恶补下ant
网友回复:非常感谢楼主!!!
网友回复:java程序员群:12722743
网友回复:好帖,顶上去
关键字:入门,笔记,
上一篇:关于视频桢截取的问题,谢谢
下一篇:下面没有链接了











文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面