ServiceClass 对象未实现以下形式的所需方法:OMElement add(OMElement e)

The ServiceClass object does not implement the required method in the following form: OMElement add(OMElement e)

我无法找出错误发生的位置。我检查了 Axis2.xml 并安装了最新的 Axis2 API。我目前正在使用 Apache Tomcat 8 和 JDK 1.8 进行开发。

Exception in thread "main" org.apache.axis2.AxisFault: The ServiceClass object does not implement the required method in the following form: OMElement add(OMElement e)
    at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:508)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:368)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:414)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
    at com.test.axis2.AddOperatorStub.add(AddOperatorStub.java:181)
    at com.test.axis2.client.AddClientApp.main(AddClientApp.java:29)

是的,我做到了。我终于想通了,在 Axis2.xml 中我们需要添加

<messageReceiver mep="w3.org/ns/wsdl/in-only"; class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> <messageReceiver mep="w3.org/ns/wsdl/in-out"; class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />

此代码段使其正常工作。我不确定为什么这比默认值更重要

<messageReceiver mep="w3.org/ns/wsdl/in-only"; class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/> <messageReceiver mep="w3.org/ns/wsdl/in-out"; class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>

感谢大家的及时回复。真的帮助我弄清楚必须做什么。

我有同样的问题

我通过如下更新 WSDL 版本解决了这个问题

http://www.w3.org/2004/08/wsdl/in-only --> http://www.w3.org/ns/wsdl/in-only

&

http://www.w3.org/2004/08/wsdl/in-out --> http://www.w3.org/ns/wsdl/in-out

例子services.xml

早些时候

<service name="Axis2HelloWorld" >
    <Description>
        Please Type your service description here
    </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="ServiceClass" locked="false">com.ciber.webservices.Axis2HelloWorld</parameter>
</service>

新建

<service name="Axis2HelloWorld" >
    <Description>
        Please Type your service description here
    </Description>
    <messageReceivers>
        <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
        <messageReceiver  mep="http://www.w3.org/ns/wsdl/in-out"  class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    <parameter name="ServiceClass" locked="false">com.ciber.webservices.Axis2HelloWorld</parameter>
</service>

遇到了同样的问题。对 WEB-INF->services->MyService -> META-INF -> services.xml

进行了以下更改

发件人:

<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>

收件人:

<messageReceivers>
  <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
  <messageReceiver  mep="http://www.w3.org/ns/wsdl/in-out"  class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>