对c#/java + web service架构方式进行的可行性测试2007-05-24 14:50:44来自:兰音的BLOG 新建目录...
根目录
1.服务器端开发和运行环境
eclipse3.2 + jdk1.5.0 + tomcat5.5 + xfire + myeclipse5.1
xfire参考:
http://www2.matrix.org.cn/resource/article/2006-09-24/XFire_6bd1061c-4bc6-11db-978f-43b3336b7e51.html
2.服务器端开发及运行环境的配置
略
3.web service的开发和部署:
新建project -〉web service project
src下新建-〉web service
修改已生成的javabean,
package server;
//Generated by MyEclipse
public class LoginImpl implements ILogin {
public String Login(String UserID, String Password) {
String message = "Hello " + UserID + "!";
return message;
}
}
接口中也许修改。
配置tomcat
部署该项目,启动tomcat
输入链接:http://localhost:8080/LoginWS/services/Login?wsdl
如果部署成功,显示xml文件。
4.客户端开发(java)
new -> java project
new->web service client
在wsdl url中输入上面的链接.
修改生成的代码:
//TODO: Add custom client code here
//
//loginPortType.yourServiceOperationHere();
System.out.println(loginPortType.login("liuhuan", "123456"));
编译运行报错:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity
需要下载apache的httpclient开发包:
下载地址:
http://jakarta.apache.org/site/downloads/downloads_commons-httpclient.cgi
然后将commons-httpclient-3.1-rc1.jar添加到该工程.
运行得到:
Hello liuhuan!
test client completed
5.客户端开发(c#)
使用vc2005
新建windows应用程序,添加引用->web 引用,在wsdl url中输入链接.生成代理类.
添加调用代码,
private void button1_Click(object sender, EventArgs e)
{
SDClient.localhost.Login li = new SDClient.localhost.Login();
this.Text = li.CallLogin("test","test");
}
编译运行成功.
根目录
1.服务器端开发和运行环境
eclipse3.2 + jdk1.5.0 + tomcat5.5 + xfire + myeclipse5.1
xfire参考:
http://www2.matrix.org.cn/resource/article/2006-09-24/XFire_6bd1061c-4bc6-11db-978f-43b3336b7e51.html
2.服务器端开发及运行环境的配置
略
3.web service的开发和部署:
新建project -〉web service project
src下新建-〉web service
修改已生成的javabean,
package server;
//Generated by MyEclipse
public class LoginImpl implements ILogin {
public String Login(String UserID, String Password) {
String message = "Hello " + UserID + "!";
return message;
}
}
接口中也许修改。
配置tomcat
部署该项目,启动tomcat
输入链接:http://localhost:8080/LoginWS/services/Login?wsdl
如果部署成功,显示xml文件。
4.客户端开发(java)
new -> java project
new->web service client
在wsdl url中输入上面的链接.
修改生成的代码:
//TODO: Add custom client code here
//
//loginPortType.yourServiceOperationHere();
System.out.println(loginPortType.login("liuhuan", "123456"));
编译运行报错:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity
需要下载apache的httpclient开发包:
下载地址:
http://jakarta.apache.org/site/downloads/downloads_commons-httpclient.cgi
然后将commons-httpclient-3.1-rc1.jar添加到该工程.
运行得到:
Hello liuhuan!
test client completed
5.客户端开发(c#)
使用vc2005
新建windows应用程序,添加引用->web 引用,在wsdl url中输入链接.生成代理类.
添加调用代码,
private void button1_Click(object sender, EventArgs e)
{
SDClient.localhost.Login li = new SDClient.localhost.Login();
this.Text = li.CallLogin("test","test");
}
编译运行成功.