【问题标题】:calling another function from WebService从 WebService 调用另一个函数
【发布时间】:2014-04-19 09:38:32
【问题描述】:

我有一个关于从另一个包调用一个包中的 java 函数的问题。

我在 Eclipse 中创建了 2 个项目(例如 proj1 - 简单的 java 项目,proj2 - Web 服务项目)。

在 proj2 内的 Web 服务中,我在 proj1 的 funclib 包中的 FooClass{} 类中调用函数 say foo(),但出现错误: “线程“主”org.apache.axis2.AxisFault 中的异常:funclib/FooClass”

我已创建 proj1.jar 并将其添加到“构建路径”以及“类路径”中。

如果我将包 funclib 从 proj1 复制到 proj2,那么它可以正常工作。但是,我想将两个包分别保存在 2 个不同的项目中。 有谁知道我该如何解决这个错误?

【问题讨论】:

  • 请发布整个堆栈跟踪
  • 你在哪里添加到“构建路径”?在 Eclipse 项目定义中?你什么时候得到例外?听起来您在实际运行 proj2 时没有导出 proj1.jar 或没有将其包含在类路径中。您要将其部署到服务器吗?
  • 线程“主”org.apache.axis2.AxisFault 中的异常:org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531) 在 org.apache.axis2 的 funclib/FooClass .description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375) 在 org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421) 在 org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229 ) 在 org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
  • 在 com.classes.ConcatenateStub.concatenateString(ConcatenateStub.java:185) 在 com.classes.ClientCall.main(ClientCall.java:20)
  • 我将它添加为:proj2(右键单击)->构建路径->配置构建路径->库->添加外部罐子。 Proj2 类路径为:运行->运行配置->类路径->添加外部罐子。我只部署 proj2。当我运行 WebService 客户端(即 proj3)时,出现上一条评论中显示的异常。

标签: java web-services


【解决方案1】:

检查了来源 (http://grepcode.com/file/repo1.maven.org/maven2/org.apache.axis2/axis2-kernel/1.4.1/org/apache/axis2/util/Utils.java#Utils.getInboundFaultFromMessageContext%28org.apache.axis2.context.MessageContext%29),大概这部分正在发挥作用:

org.apache.axis2.util.Utils.java

...
// If its a REST response the content is not a SOAP envelop and hence we will
// Have use the soap body as the exception
if (messageContext.isDoingREST() && soapBody.getFirstElement() != null) {
    return new AxisFault(soapBody.getFirstElement().toString());
}
...

它本身是从以下位置调用的:

org.apache.axis2.description.OutInAxisOperation

...
// rampart handlers change the envelope and set the decrypted envelope
// so need to check the new one else resenvelope.hasFault() become false.
resenvelope = responseMessageContext.getEnvelope();
if (resenvelope.hasFault()||responseMessageContext.isProcessingFault()) {
    if (options.isExceptionToBeThrownOnSOAPFault()) {
        // does the SOAPFault has a detail element for Excpetion
        throw Utils.getInboundFaultFromMessageContext(responseMessageContext);
    }
}
...

所以在处理响应时似乎出现了问题。由于可能有一百万个原因,因此我鼓励您在此处设置断点并对其进行调试以找出根本原因。

【讨论】:

  • 谢谢。会尝试这样做。但是,当我将包 funclib 从 proj1 复制到 proj2 时,它是如何工作的?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-11-19
  • 1970-01-01
  • 2017-08-04
  • 1970-01-01
  • 2022-12-05
  • 1970-01-01
相关资源
最近更新 更多