Axis 2 客户端未收到 Axis 2 Web 服务抛出的异常

发布于 2024-12-07 04:29:30 字数 1592 浏览 0 评论 0原文

调用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

攒眉千度 2024-12-14 04:29:30

此操作是唯一的一次。所以你不会因此而收到任何肥皂缺陷。如果你想抛出错误,你的操作必须是一种从内到外的操作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文