步骤
一.建立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
----------cxfaxis2
一.建立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
----------cxfaxis2
求解决方法。
求解决方法。
我一开始用的是这个:JaxWsServerFactoryBean,它就报错了。
后来我改用:ServerFactoryBean,就没有问题了。
参考:
http://stackoverflow.com/questions/13902874/apache-cxf-the-given-soapaction-does-not-match-an-operation