编写客户端程序,编译并执行
方法一:
package com.demo.axis.test;
import com.demo.axis.client.HelloWorldServiceLocator;
import com.demo.axis.client.HelloWorld_PortType;
public class TestClient {
public static void main(String[] args) {
HelloWorld_PortType client;
HelloWorldServiceLocator service = new HelloWorldServiceLocator();
String destAddress = service.getHelloWorldAddress();// 服务地址
String returnStr = "";
try {
java.net.URL endpoint = new java.net.URL(destAddress);
client = service.getSayHello(endpoint);
returnStr = client.sayHello("加菲猫");// 调用服务端方法
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(returnStr);
}
}
方法二:
package com.demo.axis.test;
import com.demo.axis.client.HelloWorldService;
import com.demo.axis.client.HelloWorldServiceLocator;
import com.demo.axis.client.HelloWorld_PortType;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* junit测试客户端代码
* 需要导入junit.jar
*
*/
public class TestClient extends TestCase {
public TestClient(String string) {
super(string);
}
public void HelloWorldClient() throws Exception {
HelloWorldService service = new HelloWorldServiceLocator();
HelloWorld_PortType client = service.getSayHello();
String retValue = client.sayHello("加菲猫");
System.out.println(retValue);
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new TestClient("HelloWorldClient"));
return suite;
}
}
右击TestCase-》Run as-》1 JUnit Test执行客户端程序
分享到:
相关推荐
Web Service WebService Axis一个完整的客户端代码
使用Eclipse的Axis1.4插件开发Web Service及客户端
axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端axis 客户端
NULL 博文链接:https://enjiex.iteye.com/blog/1104455
web service axis 1.6。配置说明,客户端,服务端代码
MyEclipse下开发Web Service(Axis)
简单地描述下怎么使用 eclipse 生成 Axis2 Web Service 客户端。
axis1实现webservice 及客户端调用方法 实现
axis自动生成客户端代码,不同于axis2,
axis根据服务端wsdl生成客户端工具。
Web Service开发及axis 的客户端使用.rar
NULL 博文链接:https://goldlive.iteye.com/blog/623828
axis1实现helloWorld 博文链接:https://yehao0716.iteye.com/blog/1535268
axis1.4生成访问客户端代码
一般我们都是在命令行下用WSDL2Java工具生成WEB Service 客户端代码,繁琐的Java环境变量,以及命令行参数很容易出错,为了提高效率,我用Swing做了一个图形界面生成器,输入WSDL地址(可以是本地路径或远程地址)...
基于axis2实现的webservice简单实现(客户端+服务端)。
Axis开发Web Service实例,介绍AXIS的三种方法
使用axis2 1.6.2 生成webservice wsdl客户端代码,快速便捷,方便操作。使用有问题可留言,如看到尽快回复