使用 Java 调用 Web 服务时出现“org.apache.axis2.AxisFault: unknown”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1882398/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 23:31:01  来源:igfitidea点击:

"org.apache.axis2.AxisFault: unknown" when calling web service with Java

javaweb-servicesaxis2

提问by dax

I'm trying to call a web service with a Java client. The WSDL looks like this: http://pastebin.com/m13124ba

我正在尝试使用 Java 客户端调用 Web 服务。WSDL 如下所示:http: //pastebin.com/m13124ba

My client:

我的客户:

public class Client{
    public static void main(java.lang.String args[]){
        try{
            CompileAndExecuteServiceInterfaceStub stub =
                new CompileAndExecuteServiceInterfaceStub
                ("http://192.168.1.3:8080/axis2/services/CompileAndExecuteServiceInterface");

            Compile comp = new Compile();
            comp.setArgs0("Test");
            comp.setArgs1("public class Test { public static void main(String[] args) { System.out.println(\"Hello\");}}");
            String[] classpath = {};
            comp.setArgs2(classpath);
            stub.compile(comp);

        } catch(Exception e){
            e.printStackTrace();


        }
    }

}

When I run the client now the following error occurs:

当我现在运行客户端时,出现以下错误:

org.apache.axis2.AxisFault: unknown


at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:517)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371)
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 de.dax.compileandexecuteclient.CompileAndExecuteServiceInterfaceStub.compile(CompileAndExecuteServiceInterfaceStub.java:184)
at de.dax.compileandexecuteclient.Client.main(Client.java:17)</blockquote>

I tried out the business logic of the server on my local machine and there it works. The service creates files and folders. Are web services allowed to do that? I also wrote a simple "Hello World" web service and deployed it to the server. This worked fine.

我在本地机器上尝试了服务器的业务逻辑,并在那里工作。该服务创建文件和文件夹。允许 Web 服务这样做吗?我还编写了一个简单的“Hello World”Web 服务并将其部署到服务器。这工作得很好。

采纳答案by dax

The problem was that there was an NullPointerException in my service.

问题是我的服务中存在 NullPointerException。

回答by jawi

From the provided logs, I cannot determine what's wrong. Try to set the log-level of Axis2 to "debug" (see the two log-configurations in the root directory of your Axis2 installation) and check the details for the exact cause. Axis2 tends to be a bit sparse in propagating the errors coming from webservices.

从提供的日志中,我无法确定出了什么问题。尝试将 Axis2 的日志级别设置为“调试”(请参阅​​ Axis2 安装根目录中的两个日志配置)并检查详细信息以了解确切原因。Axis2 在传播来自 Web 服务的错​​误方面往往有点稀疏。

回答by Daniel F. Thornton

When you get one of these "unknown" AxisFaults, definitely check the server log! The client-side stack trace most likely will not be detailed enough for you to track down the error.

当您获得这些“未知”AxisFault 之一时,一定要检查服务器日志!客户端堆栈跟踪很可能不够详细,无法让您跟踪错误。

I believe dax is indicating above that he found the NullPointerException in the more-detailed server side stack trace. It would look something like:

我相信 dax 在上面指出他在更详细的服务器端堆栈跟踪中发现了 NullPointerException。它看起来像:

org.apache.axis2.AxisFault
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)

    [....]

Caused by: java.lang.NullPointerException

    [....]