Xfire调用webservice无法传递参数问题解决
来源:互联网 发布:网络交流的利与弊英语 编辑:程序博客网 时间:2024/05/22 07:44
最近开发Xfire发布调用webservice,发现无法传递参数。
问题出在,发布的webservice接口类需要使用如下这种定义方式
package com.demo.service;
import javax.jws.WebParam;
public interface MyService {
String example(
@WebParam(targetNamespace = "http://com.demo.service")String agr0,//第一个参数
@WebParam(targetNamespace = "http://com.demo.service")String agr1,//第二个参数
@WebParam(targetNamespace = "http://com.demo.service")String agr2,//第三个参数
@WebParam(targetNamespace = "http://com.demo.service")String agr3//第四个参数,你可以写N个参数
);
}
当然,用Xfire调用这个webservice的接口时需要用这种方式
package com.demo.client;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService(name = "IMyService", targetNamespace = "http://com.demo.service")
@SOAPBinding(use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public interface IMyService {
@WebMethod(operationName = "example", action = "")
@WebResult(name = "return", targetNamespace = "http://com.demo.service")
public String example(
@WebParam(name = "arg0", targetNamespace = "http://com.demo.service")
String arg0,//第一个参数
@WebParam(name = "arg1", targetNamespace = "http://com.demo.service")
String arg1,//第二个参数
@WebParam(name = "arg2", targetNamespace = "http://com.demo.service")
String arg2,//第三个参数
@WebParam(name = "arg3", targetNamespace = "http://com.demo.service")
String arg3//第四个参数,后面可以加N个参数自己定
);
}
然后再使用xfire调用方式,就可以传递参数了
package com.demo.client;
import java.net.MalformedURLException;
import org.codehaus.xfire.XFire;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.Client;
import org.codehaus.xfire.annotations.AnnotationServiceFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
public class Test {
public static void main(String[] args) throws MalformedURLException {
String serviceUrl = "http://localhost:8080/Demo/services/MyService";
Service serviceModel = new AnnotationServiceFactory().create(IMyService.class);
XFire xFire = XFireFactory.newInstance().getXFire();
XFireProxyFactory serviceFactory = new XFireProxyFactory(xFire);
try {
IMyService service = (IMyService) serviceFactory.create(serviceModel,
serviceUrl);
String hello = service.example("001", "002","003","004");
System.out.println(hello);
} catch (Exception e) {
e.printStackTrace();
}
}
}
demo源码下载:http://download.csdn.net/detail/zongkai2012/5992713
- Xfire调用webservice无法传递参数问题解决
- java调用webservice XFire!
- java调用webservice XFire
- java调用webservice XFire
- xfire webservice接口调用
- 用xfire客户端调用服务端时,传递参数总是null
- delphi调用.net的webservice服务参数无法传递的问题
- xfire调用webService接口方法
- xfire+webservice(客户端调用篇)
- xfire开发并调用webservice
- xfire客户端调用webservice测试
- OSGI系列 xfire调用WebService
- 使用xFire调用Webservice接口
- Android 客户端调用基于XFire的webService方法传递自定义对象
- WebService 开发 XFire 传递java对象
- XFire实现自定义类型参数传递和调用返回自定义类型方法
- 关于SOAPpy传递对象参数调用WebService的问题总结
- 关于java调用webservice参数传递为空问题
- BeanUtils对Date和Decimal类型的转换器
- VC从文件中加载图片
- MFC与.net比较
- uva 11997
- xcode合并模拟器和真机静态库的编译
- Xfire调用webservice无法传递参数问题解决
- LBS打车定位系统
- java中RSA加解密的实现
- SAS学习笔记(二)
- Mac OS上编译Mobile VLC for ios
- 关于RSA算法密钥长度/密文长度/明文长度的介绍
- ASP.Net使用用户控件做公用分页控件
- 基于百度定位SDK的定位服务的实现
- ASP.NET后台手动调用POST提交并获取返回值,用于短信平台接口//这是一个短信平台的后台提交功能