0

我有一个客户端试图调用 Web 服务 -

public static void main(String[] args) throws RemoteException {
    SimpleServiceStub service = new SimpleServiceStub(
            "http://localhost:8080/axis2/services/SimpleService");
            ConcatRequest request = new ConcatRequest();
            request.setS1("abc");
            request.setS2("123");
            ConcatResponse response = service.concat(request);
            System.out.println(response.getConcatResponse());
}

来自eclipse内部的异常堆栈跟踪是-

Exception in thread "main" org.apache.axis2.AxisFault
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at com.ttdev.ss.SimpleServiceStub.fromOM(SimpleServiceStub.java:1419)
at com.ttdev.ss.SimpleServiceStub.concat(SimpleServiceStub.java:190)
at com.ttdev.ss.SimpleClient.main(SimpleClient.java:15)
Caused by: java.lang.NullPointerException
at com.ttdev.ss.SimpleServiceStub.fromOM(SimpleServiceStub.java:1413)
... 2 more

*编辑*这是来自轴的堆栈跟踪

Exception in thread "HttpConnection-8080-1" java.lang.IllegalStateException: Response already committed
    at org.apache.axis2.transport.http.server.AxisHttpResponseImpl.assertNotCommitted(AxisHttpResponseImpl.java:75)
    at org.apache.axis2.transport.http.server.AxisHttpResponseImpl.sendError(AxisHttpResponseImpl.java:110)
    at org.apache.axis2.transport.http.server.AxisHttpService.doService(AxisHttpService.java:315)
    at org.apache.axis2.transport.http.server.AxisHttpService.handleRequest(AxisHttpService.java:187)
    at org.apache.axis2.transport.http.server.HttpServiceProcessor.run(HttpServiceProcessor.java:82)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

当我调试代码时,我看到在生成的存根类中传递了一个空参数(第一个参数) -

private  java.lang.Object fromOM(
    org.apache.axiom.om.OMElement param,
    java.lang.Class type,
    java.util.Map extraNamespaces) throws org.apache.axis2.AxisFault{

    try {

            if (com.ttdev.ss.SimpleServiceStub.ConcatRequest.class.equals(type)){

                       return com.ttdev.ss.SimpleServiceStub.ConcatRequest.Factory.parse(param.getXMLStreamReaderWithoutCaching());


            }

            if (com.ttdev.ss.SimpleServiceStub.ConcatResponse.class.equals(type)){

                       return com.ttdev.ss.SimpleServiceStub.ConcatResponse.Factory.parse(param.getXMLStreamReaderWithoutCaching());


            }

    } catch (java.lang.Exception e) {
    throw org.apache.axis2.AxisFault.makeFault(e);
    }
       return null;
    }

我试过axis2版本1.5.1和1.6.2服务器是本地服务器,版本是1.6.2。

我不能在这里发布 wsdl 代码。它只是没有出现! 但这是用于生成存根类的代码 -

WSDL2Code.main(new String[] {       
    "-S", "src/main/java",
    "-R", "src/main/resources/META-INF",
    "-ns2p", "http://ttdev.com/ss=com.ttdev.ss",
    "-uri", "src/main/resources/SimpleService.wsdl" });

任何帮助表示赞赏。顺便说一句,当我尝试使用 CXF 时,它可以工作。所以要么这是一个错误,要么我在从有效的 WSDL 生成 java 代码时做错了。

4

1 回答 1

1

这是版本 1.6.2 的错误!我将服务器版本降级到 1.5.1 并且可以正常工作!我希望这可以帮助其他人努力寻找axis2的答案(就像我一样)。

于 2013-02-11T12:57:39.133 回答