开发者

Axis2 error when invoking web service from another web service

开发者 https://www.devze.com 2023-03-03 13:15 出处:网络
I have an Axis2 web service called DownloadServer that is invoking another Axis2 web service called Publisher. They are deployed on the same server. Here is the code for the two web services.

I have an Axis2 web service called DownloadServer that is invoking another Axis2 web service called Publisher. They are deployed on the same server. Here is the code for the two web services.

In class Publisher.java:

public String getFileServers(){
    return "http://localhost:8080/axis2/services/FileServer1?wsdl http://localhost:8080/axis2/services/FileServer2?wsdl";
}

In class DownloadServer.java:

public synchronized String getBandwidth(String title) {
        try {
            // Call Publisher service to get addresses of File Servers
            RPCServiceClient serviceClient = new RPCServiceClient();
            Options options = serviceClient.getOptions();
            EndpointReference targetEPR = new EndpointReference(
                    "http://localhost:8080/axis2/services/Publisher?wsdl");
            options.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION,
                    org.apache.axis2.Constants.VALUE_TRUE);
            options.setTo(targetEPR);
            QName methodName = new QName("http://ws.apache.org/axis2",
                    "getFileServers");
            Class[] returnTypes = new Class[] { String.class };
            Object[] args = new Object[] {};
            // Exception occurs on the next line
            Object[] response = serviceClient.invokeBlocking(methodName, args,
                    returnTypes);
            serviceClient.cleanupTransport();
            String fileServers = (String) response[0];

            return fileServers
        } catch (Exception e) {
            e.printStackTrace(out);
            return "0";
        }
    }

I am getting the following Axis2 fault:

org.apache.axis2.AxisFault: The server did not recognise the action which it received: 
    at org.apache.axis2.handlers.addressing.AddressingInFaultHandler.invoke(AddressingInFaultHandler.java:114)
    at org.apache.axis2.engine.Phase.invoke(Phase.java:318)
    at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:254)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:160)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:364)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:540)
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:521)
    at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:102)
    at DownloadServer.getBandwidth(DownloadServer.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:173)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:144)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.ser开发者_StackOverflowvice(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)

The interesting aspect is that when I run the DownloadServer class as a regular java application (not invoked as a web service), i do not get the same exception.

Does anyone have any idea what may be going wrong when the same code is executed as a web service?


OK, I found the answer eventually. Looks like explicitly setting the SOAP action solves the problem. It can be done like this:

options.setAction("urn:getFileServers");
0

精彩评论

暂无评论...
验证码 换一张
取 消