Axis 2 客户端未收到 Axis 2 Web 服务抛出的异常
调用 Axis 2 Web 服务的 Axis 2 客户端(wsdl2java 生成的代码)未收到服务抛出的 RuntimeException。调用的方法是一个void方法。
我用于客户端和服务器的 Axis 2 版本是 1.6.1。
当我运行以下测试时,它成功完成并且没有收到异常:
@Test
public void testMyService() throws RemoteException {
String target = "http://localhost:8080/services/MyService";
MyServiceStub myServiceStub = new MyServiceStub(target);
myServiceStub.doSomething();
}
MyService.java:
package com.afirme.webservice.service;
@Service
public class MyService {
public void doSomething() {
throw new IllegalArgumentException("Just testing!");
}
}
services.xml:
<serviceGroup>
<service name="MyService">
<description>
My Service
</description>
<messageReceivers>
<messageReceiver
mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver
mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier</parameter>
<parameter name="SpringBeanName">myService</parameter>
</service>
</serviceGroup>
An Axis 2 client (wsdl2java generated code) invoking an Axis 2 Webservice is not receiving a RuntimeException thrown from a Service. The invoked method is a void method.
The Axis 2 version I'm using for both client and server is 1.6.1.
When I run the following test it completes successfully and no Exception is received:
@Test
public void testMyService() throws RemoteException {
String target = "http://localhost:8080/services/MyService";
MyServiceStub myServiceStub = new MyServiceStub(target);
myServiceStub.doSomething();
}
MyService.java:
package com.afirme.webservice.service;
@Service
public class MyService {
public void doSomething() {
throw new IllegalArgumentException("Just testing!");
}
}
services.xml:
<serviceGroup>
<service name="MyService">
<description>
My Service
</description>
<messageReceivers>
<messageReceiver
mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver
mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier</parameter>
<parameter name="SpringBeanName">myService</parameter>
</service>
</serviceGroup>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此操作是唯一的一次。所以你不会因此而收到任何肥皂缺陷。如果你想抛出错误,你的操作必须是一种从内到外的操作。
This operation is an in only one. So you won't receive any soap faults from that. If you want to throw faults your operation must be an in-out one.