1.JAX-WS
选择“发布”按钮的左边第二个——》选择New Web Service Client——》选择Project与Framework——》在WSDL URL中输入WSDL地址,选择Java source folder与 Java package——》下一步——》会生成很多客户端文件
再新建一个测试类,写上main方法,在main方法中写上
StorageYKTService service= new StorageYKTService();
StorageYKTServiceImplDelegate delegate=service.getStorageYKTService();
String result=delegate.getDoorStatus("200001", "1", "001");
System.out.println(result);
2.axis
package com.talkweb.ecard.storage.action;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class StorageYKTClient {
public static void main(String[] args) throws Exception {
String url="http://116.55.248.117:8090/HelloWorldService/services/HW";
//String nameSpaceUri ="http://server";
String nameSpaceUri ="";
Service service = new Service();
Call call = null;
call = (Call)service.createCall();
call.setOperationName(new QName(nameSpaceUri,"syncRecord"));
//call.setOperationName("syncRecord");
call.setTargetEndpointAddress(new java.net.URL(url));
Object[] params = new Object[6];
params[0] = "234";
params[1] = "12";
params[2] = "23";
params[3] = "234";
params[4] = "12";
params[5] = "23";
String ret = (String)call.invoke(params);
System.out.println("-------------ret:"+ret+"-----------");
}
}
也可以这么写
package com.talkweb.ecard.storage.action;
import java.util.Calendar;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
public class StorageYKTClient {
public static void main(String[] args) throws Exception {
try {
String endpoint = "http://116.55.248.117:8090/HelloWorldService/services/HW";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint));
long timeStart, timeEnd;
String mobile="18777171717";
String name="aaa";
String openDate="20120303122201";
String doorId="1";
String dir="1";
String key="1";
int a = 9;
call.setOperationName("syncRecord");
call.addParameter("mobile",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("name",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("openDate",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("doorId",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("dir",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("key",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.setReturnType( XMLType.XSD_STRING);
timeStart = Calendar.getInstance().getTimeInMillis();
for(int i=0;i<5;i++) {
String ret = (String)call.invoke( new Object[] {mobile,name,openDate,doorId,dir,key} );
a++;
System.out.println("Got result : " + ret);
}
timeEnd = Calendar.getInstance().getTimeInMillis();
System.out.println(Long.toString( (timeEnd - timeStart)));
System.out.println(Float.toString(1000 * ( (float) 1) /(float) (timeEnd - timeStart)));
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
还可以这么写
package com.talkweb.ecard.storage.action;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class StorageYKTClient {
public static void main(String[] args) throws Exception {
String endpoint = "http://116.55.248.117:8090/HelloWorldService/services/HW";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("syncRecord");
String mobile="18777171717";
String name="aaa";
String openDate="20120303122201";
String doorId="1";
String dir="1";
String key="1";
String result="11";
result =(String)call.invoke(new Object[]{mobile, name, openDate, doorId, dir, key});
System.out.println(result);
}
}
3.xfire
1.在自己的项目中新建一个接口,接口名称随便写,方法名、方法参数、返回值类型必须与服务器的一致
接口:
package com.talkweb.ecard.storage.service;
public interface SyncRecord {
public String syncRecord(String mobile,String name,String openDate,String doorId,String dir,String key);
}
客户端:
package com.talkweb.ecard.storage.action;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import com.talkweb.ecard.storage.service.SyncRecord;
public class StorageYKTClient {
public static void main(String[] args) throws Exception {
String result="";
String serviceUrl = "http://116.55.248.117:8090/HelloWorldService/services/HW";
Service serviceModel = new ObjectServiceFactory().create(SyncRecord.class);
SyncRecord syncrecord=null;
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
try {
syncrecord = (SyncRecord)factory.create(serviceModel, serviceUrl);
} catch (Exception ex) {
//ex.printStackTrace();
}
result=syncrecord.syncRecord("18711090909", "aaa", "20120305185445", "1", "1","1");
System.out.println("----------------------------------------------------------------------------");
System.out.println(result);
System.out.println("----------------------------------------------------------------------------");
}
}
也可以不用写接口
package com.talkweb.ecard.storage.action;
import java.net.URL;
import org.codehaus.xfire.client.Client;
public class StorageYKTClient {
public static void main(String[] args) throws Exception {
Client client = new Client(new URL(
"http://116.55.248.117:8090/HelloWorldService/services/HW?wsdl"));
Object url[] = client.invoke("syncMember",new Object[]{"1","13312121212","xiao","2","2"});
System.out.println(url[0].toString());
}
}
分享到:
相关推荐
使用cxf和spring开发基于https的webservice服务端以及客户端样例
NULL 博文链接:https://babyjoycry.iteye.com/blog/429992
早期的基于 SOAP 的 JAVA 的 Web 服务规范 JAX-RPC(Java API For XML-Remote Procedure Call)目前已经被JAX-WS规范取代,JAX-WS 是JAX-RPC 的演进 版本,但 JAX-WS 并不完全向后兼容 JAX-RPC,二者最大的区别就是...
访问地址: http://127.0.0.1:8080/axis/services
在 Java 中,可以使用 Eclipse 和 Axis2 工具来创建 Webservice 客户端,然后使用该客户端来调用 SAP 的 Webservice。 首先,需要下载Axis2 的 jar 包,然后在 Eclipse 中创建一个新的 Java 项目,添加 Axis2 的 ...
MyEclipse基于JAX-WS开发Webservice+WebserviceClient客户端调用.zip
该案例是基于wsdl进行webservice接口开发打印helloworld案例 包含一个客户端 一个服务端
JAVA6 开发WebService JWS示例 WebService 概念 WebService 是一种软件系统,旨在支持跨网络的机器之间相互操作交互。它有一个机器可识别的描述格式,特别是 WSDL。不同的系统之间可以通过 SOAP 消息在规定的方式...
客户端开发步骤 1. 创建 Java 项目,项目名称为 Demo。 2. 导入必要的 jar 包,包括 XFire 的 jar 包。 3. 复制服务端的服务接口到客户端。 4. 创建测试类,用于调用 web 服务接口。 5. 运行测试类,输出结果。 ...
"Java WebService 编程基础" 在本文中,我们将详细介绍如何使用 Java 编写简单的 WebService ...通过本文,我们可以了解到 WebService 的基本概念和实现方式,以及如何使用 Java 和 Axis 来开发和部署 WebService。
概述了Web Service的特点和核心要素, 依据Delphi和Java对Web Service 的支持,给出了基于Java ,Delphi开发Web Service的流程, 并用一个Delphi调用Java开发Web Service应用程序来说明跨平台Web Service应用程序的步骤...
随着WebService技术的普及,Eclipse也提供了相应的支持,允许开发者通过wsdl文件生成Java客户端。本文将详细介绍如何在Eclipse中使用wsdl文件生成Java客户端。 首先,让我们了解什么是wsdl文件。Wsdl(Web Services...
只要WebService公开了服务接口,远程客户端就可以调用服务。WebService 是基于Http协议的组件服务,WebService是分散式应用程序的发展趋势。 WebService更多是一种标准,而不是一种具体的技术。不同的平台,不同的语言...
java基于axis的webservice实例,包含服务器端和客户端,开发工具为eclipse,下载后将TestServiceLocator类的地址改成你服务器端所在的机器ip地址,然后部署到tomcat中部署既可以运行。有问题可以留言
java期末大作业课程设计基于springboot的医院挂号预约系统源码+数据库。 软件架构说明 服务端:WebService+axis+mybatis 服务端开发环境:jdk8,mysql8.0,tomcat9.0,IDEA2021 客户端:基于Springboot来整合axis...
中文名: 经典Java EE企业应用实战--基于WebLogic/JBoss的JSF+EJB 3+JPA整合开发 原名: 经典Java EE企业应用实战--基于WebLogic/JBoss的JSF+EJB 3+JPA整合开发 作者: 李刚 资源格式: PDF 版本: 第一版 出版社: 电子...
RESTful架构: (1)每一个URI代表一种资源; (2)客户端和服务器之间,传递这种资源的某种表现层(Representation); (3)客户端通过四个HTTP动词,对服务器...在java领域,webservice框架很多,axis,xfire,cxf
如:java 的客户端 和dotnet的服务器端的接口调用: 得到接口和方法 : 基于标准的协议,可编程语言; 服务器开发 api; 特点: 自包含:只要客户端支持http和xml就可以; 自描述:只需要知道请求响应的...
这是一个基于Andriod的无线点餐系统,.net语言开发的服务器,java语言开发的客户端,分买家客户端和卖家客户端,用webservice进行服务器和客户端的交互,界面美观,亲测可用,当然还有很多不足的地方,拿出来和大家...
本资源是基于安卓开发的提供地图导航,天气查询,周边查询,拍照上传,照片浏览的APP,服务器端采用Tomcat作为应用服务器,Axis2框架构建WebService的方式搭建发布。至于如何用Axis2创建WebService请自行百度。安卓...