AxisFault:ServiceClass 对象未实现以下形式的所需方法:OMElement add(OMElement e)
AxisFault: The ServiceClass object does not implement the required method in the following form: OMElement add(OMElement e)
我正在尝试学习 WebServices (Axis2)
我正在使用 Jboss EAP 7.0、eclipse_mars 和 JDK 8,以及最新的 Axis2 (axis2-1.7.4)。
当运行调用客户端代码时,
package com.durgasoft.service;
public class Test {
public static void main(String[] args) throws Exception{
CalServiceStub stub = new CalServiceStub();
//Code to invoke add()
CalServiceStub.Add params =
new CalServiceStub.Add();
params.setI(13);
params.setJ(10);
CalServiceStub.AddResponse
res = stub.add(params);
int result = res.get_return();
System.out.println(result);
}
}
我得到的错误是:
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.durgasoft.service.CalServiceStub.add(CalServiceStub.java:181)
at com.durgasoft.service.Test.main(Test.java:12)
我查看了 Whosebug 上的以下帖子:
-
已尝试更新 http://www.w3.org/2004/08/wsdl/in-only to http://www.w3.org/ns/wsdl/in-only and http://www.w3.org/2004/08/wsdl/in-out to http://www.w3.org/ns/wsdl/in-out
已尝试在 service.xml 中添加操作标签,如
Simple axis2.xml for Axis2 embedded in webapp
我什至还确保Axis2.xml中描述的messageReceivers和service.xml中提到的是相同的。我有
完全 运行 出主意。如果你知道怎么做,请帮助我
解决这个问题。
我已经创建了服务,
package com.durgaSoft.service;
public class CalService {
public int add(int i, int j){
return i+j;
}
}
我用过eclipse wsdl生成工具来生成WSDL。生成的WSDL文件如下图
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://service.durgaSoft.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" targetNamespace="http://service.durgaSoft.com">
<wsdl:documentation>Please Type your service description here</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.durgaSoft.com">
<xs:element name="add">
<xs:complexType>
<xs:sequence>
<xs:element name="i" type="xs:int"/>
<xs:element name="j" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="addResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="addRequest">
<wsdl:part name="parameters" element="ns:add"/>
</wsdl:message>
<wsdl:message name="addResponse">
<wsdl:part name="parameters" element="ns:addResponse"/>
</wsdl:message>
<wsdl:portType name="CalServicePortType">
<wsdl:operation name="add">
<wsdl:input message="ns:addRequest" wsaw:Action="urn:add"/>
<wsdl:output message="ns:addResponse" wsaw:Action="urn:addResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalServiceSoap11Binding" type="ns:CalServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="add">
<soap:operation soapAction="urn:add" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="CalServiceSoap12Binding" type="ns:CalServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="add">
<soap12:operation soapAction="urn:add" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="CalServiceHttpBinding" type="ns:CalServicePortType">
<http:binding verb="POST"/>
<wsdl:operation name="add">
<http:operation location="add"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalService">
<wsdl:port name="CalServiceHttpSoap11Endpoint" binding="ns:CalServiceSoap11Binding">
<soap:address location="http://localhost:8080/Axis2CalService/services/CalService.CalServiceHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="CalServiceHttpSoap12Endpoint" binding="ns:CalServiceSoap12Binding">
<soap12:address location="http://localhost:8080/Axis2CalService/services/CalService.CalServiceHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="CalServiceHttpEndpoint" binding="ns:CalServiceHttpBinding">
<http:address location="http://localhost:8080/Axis2CalService/services/CalService.CalServiceHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
ServiceXML:
<service name="CalService" >
<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>
<!--
<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.durgaSoft.service.CalService</parameter>
</service>
我也遇到了这个问题,我解决了。
继续服务文件中的这条路径:
WebContent--> WEB-INF--> services--> ProjectName--> META-INF--> sevices.xml
之后更改此代码:
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
因为在 axis2.xml 文件中你正在使用这个 URL。所以检查并更改它。
确保 WEB-INF/conf/axis2.xml 中的 messageReceivers 应与 WEB-INF/services//services.xml 文件中的 messageReceivers 匹配。它对我有用。
<messageReceivers>
<messageReceiver
mep="http://www.w3.org/ns/wsdl/in-only"
class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
<messageReceiver
mep="http://www.w3.org/ns/wsdl/in-out"
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
<messageReceiver
mep="http://www.w3.org/ns/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
</messageReceivers>
我正在尝试学习 WebServices (Axis2)
我正在使用 Jboss EAP 7.0、eclipse_mars 和 JDK 8,以及最新的 Axis2 (axis2-1.7.4)。
当运行调用客户端代码时,
package com.durgasoft.service;
public class Test {
public static void main(String[] args) throws Exception{
CalServiceStub stub = new CalServiceStub();
//Code to invoke add()
CalServiceStub.Add params =
new CalServiceStub.Add();
params.setI(13);
params.setJ(10);
CalServiceStub.AddResponse
res = stub.add(params);
int result = res.get_return();
System.out.println(result);
}
}
我得到的错误是:
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.durgasoft.service.CalServiceStub.add(CalServiceStub.java:181)
at com.durgasoft.service.Test.main(Test.java:12)
我查看了 Whosebug 上的以下帖子:
-
已尝试更新 http://www.w3.org/2004/08/wsdl/in-only to http://www.w3.org/ns/wsdl/in-only and http://www.w3.org/2004/08/wsdl/in-out to http://www.w3.org/ns/wsdl/in-out
已尝试在 service.xml 中添加操作标签,如 Simple axis2.xml for Axis2 embedded in webapp
我什至还确保Axis2.xml中描述的messageReceivers和service.xml中提到的是相同的。我有 完全 运行 出主意。如果你知道怎么做,请帮助我 解决这个问题。
我已经创建了服务,
package com.durgaSoft.service;
public class CalService {
public int add(int i, int j){
return i+j;
}
}
我用过eclipse wsdl生成工具来生成WSDL。生成的WSDL文件如下图
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://service.durgaSoft.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" targetNamespace="http://service.durgaSoft.com">
<wsdl:documentation>Please Type your service description here</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.durgaSoft.com">
<xs:element name="add">
<xs:complexType>
<xs:sequence>
<xs:element name="i" type="xs:int"/>
<xs:element name="j" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="addResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="addRequest">
<wsdl:part name="parameters" element="ns:add"/>
</wsdl:message>
<wsdl:message name="addResponse">
<wsdl:part name="parameters" element="ns:addResponse"/>
</wsdl:message>
<wsdl:portType name="CalServicePortType">
<wsdl:operation name="add">
<wsdl:input message="ns:addRequest" wsaw:Action="urn:add"/>
<wsdl:output message="ns:addResponse" wsaw:Action="urn:addResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalServiceSoap11Binding" type="ns:CalServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="add">
<soap:operation soapAction="urn:add" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="CalServiceSoap12Binding" type="ns:CalServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="add">
<soap12:operation soapAction="urn:add" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="CalServiceHttpBinding" type="ns:CalServicePortType">
<http:binding verb="POST"/>
<wsdl:operation name="add">
<http:operation location="add"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalService">
<wsdl:port name="CalServiceHttpSoap11Endpoint" binding="ns:CalServiceSoap11Binding">
<soap:address location="http://localhost:8080/Axis2CalService/services/CalService.CalServiceHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="CalServiceHttpSoap12Endpoint" binding="ns:CalServiceSoap12Binding">
<soap12:address location="http://localhost:8080/Axis2CalService/services/CalService.CalServiceHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="CalServiceHttpEndpoint" binding="ns:CalServiceHttpBinding">
<http:address location="http://localhost:8080/Axis2CalService/services/CalService.CalServiceHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
ServiceXML:
<service name="CalService" >
<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>
<!--
<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.durgaSoft.service.CalService</parameter>
</service>
我也遇到了这个问题,我解决了。
继续服务文件中的这条路径:
WebContent--> WEB-INF--> services--> ProjectName--> META-INF--> sevices.xml
之后更改此代码:
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
因为在 axis2.xml 文件中你正在使用这个 URL。所以检查并更改它。
确保 WEB-INF/conf/axis2.xml 中的 messageReceivers 应与 WEB-INF/services/
<messageReceivers>
<messageReceiver
mep="http://www.w3.org/ns/wsdl/in-only"
class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
<messageReceiver
mep="http://www.w3.org/ns/wsdl/in-out"
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
<messageReceiver
mep="http://www.w3.org/ns/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
</messageReceivers>