服务端用CXF,客户端用Axis2调用,抛异常,求解决

cherry 2013-09-13 06:18:52
步骤
一.建立Web Service服务
1.导入cxf框架到WebService项目中.
2.建立功能性Interface
3.新建类Impl,实现2中接口的方法.
(逻辑部分)
4.新建startWebService类,其中main方法
public static void main(String[] args) {
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setAddress("http://localhost:8080/HelloService");
factory.setServiceClass(IHelloService.class);
factory.setServiceBean(new HelloServiceImpl());

factory.create();
}

5.run as Java application

二.客户端调用Web Service服务
1.导入axis2框架到Client项目中
2.wsdl2java 逆向 web Service的调用接口
3.建立测试用的类
main方法
public static void main(String[] args) throws RemoteException, ExceptionException {
IHelloServiceServiceStub stub = new IHelloServiceServiceStub();
GetHelloE he = new IHelloServiceServiceStub.GetHelloE();
GetHello h = new IHelloServiceServiceStub.GetHello();
he.setGetHello(h);

String a = stub.getHello(he).getGetHelloResponse().get_return();
System.out.println(a);
}
运行main方法,抛出如下异常:

Exception in thread "main" org.apache.axis2.AxisFault: The given SOAPAction http://bean.server.com/IHelloService/getHello does not match an operation.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.client.jaxws.IHelloServiceServiceStub.getHello(IHelloServiceServiceStub.java:331)
at com.client.test.HelloClientTest.main(HelloClientTest.java:19)
----------
cxf:apache-cxf-2.7.6
axis2:axis2-1.6.1
jdk:1.6.0_24
----------
...全文
1805 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
liangwang86 2013-10-04
  • 打赏
  • 举报
回复
如果用spring配置,接口方法上添加 @WebMethod(action = "urn:your_action_name") 参考: http://stackoverflow.com/questions/13902874/apache-cxf-the-given-soapaction-does-not-match-an-operation
cherry 2013-09-18
  • 打赏
  • 举报
回复
问题已经解决,谢谢。
cherry 2013-09-18
  • 打赏
  • 举报
回复
我知道我的为什么错了,是因为我的CXF发布方式有问题。 我一开始用的是这个:JaxWsServerFactoryBean,它就报错了。 后来我改用:ServerFactoryBean,就没有问题了。
无聊找乐 2013-09-15
  • 打赏
  • 举报
回复
webservice的接口和wsdl都贴出来看看
引用 2 楼 xxshouai 的回复:
[quote=引用 1 楼 rainbowsix 的回复:] 大麦不全,看不错所以然。 貌似是 方法名 或参数不对
哪不全呀?我在补充,方法名和参数怎么会不对,这是用wsdl2java直接生成的,不是我手写的呀。。。 求解决方法。[/quote]
cherry 2013-09-15
  • 打赏
  • 举报
回复
引用 1 楼 rainbowsix 的回复:
大麦不全,看不错所以然。 貌似是 方法名 或参数不对
哪不全呀?我在补充,方法名和参数怎么会不对,这是用wsdl2java直接生成的,不是我手写的呀。。。 求解决方法。
无聊找乐 2013-09-14
  • 打赏
  • 举报
回复
大麦不全,看不错所以然。 貌似是 方法名 或参数不对

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧