Error:org.ksoap2.SoapFault The service class object does not implement the required method

Error:org.ksoap2.SoapFault The service class object does not implement the required method

我在 java..

中使用 axis2 创建了用于将两个数字相乘的网络服务

wsdl文件是

<?xml version="1.0" encoding="UTF-8" ?> 
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://multiply.example.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://multiply.example.com">
  <wsdl:documentation>Please Type your service description here</wsdl:documentation> 
- <wsdl:types>
- <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://multiply.example.com">
- <xs:element name="multiply">
- <xs:complexType>
+ <xs:sequence>
  <xs:element name="x" type="xs:int" /> 
  <xs:element name="y" type="xs:int" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
- <xs:element name="multiplyResponse">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="return" type="xs:int" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>
  </wsdl:types>
- <wsdl:message name="multiplyRequest">
  <wsdl:part name="parameters" element="ns:multiply" /> 
  </wsdl:message>
- <wsdl:message name="multiplyResponse">
  <wsdl:part name="parameters" element="ns:multiplyResponse" /> 
  </wsdl:message>
- <wsdl:portType name="MulPortType">
- <wsdl:operation name="multiply">
  <wsdl:input message="ns:multiplyRequest" wsaw:Action="urn:multiply" /> 
  <wsdl:output message="ns:multiplyResponse" wsaw:Action="urn:multiplyResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="MulSoap11Binding" type="ns:MulPortType">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
- <wsdl:operation name="multiply">
  <soap:operation soapAction="urn:multiply" 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="MulSoap12Binding" type="ns:MulPortType">
  <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
- <wsdl:operation name="multiply">
  <soap12:operation soapAction="urn:multiply" 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="MulHttpBinding" type="ns:MulPortType">
  <http:binding verb="POST" /> 
- <wsdl:operation name="multiply">
  <http:operation location="multiply" /> 
- <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="Mul">
- <wsdl:port name="MulHttpSoap11Endpoint" binding="ns:MulSoap11Binding">
  <soap:address location="http://localhost:9998/Multiplication/services/Mul.MulHttpSoap11Endpoint/" /> 
  </wsdl:port>
- <wsdl:port name="MulHttpSoap12Endpoint" binding="ns:MulSoap12Binding">
  <soap12:address location="http://localhost:9998/Multiplication/services/Mul.MulHttpSoap12Endpoint/" /> 
  </wsdl:port>
- <wsdl:port name="MulHttpEndpoint" binding="ns:MulHttpBinding">
  <http:address location="http://localhost:9998/Multiplication/services/Mul.MulHttpEndpoint/" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

我正在使用 ksoap2 在 android 中调用网络服务。

Android客户端代码为:

   import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.ksoap2.SoapFault;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


public class Addd extends Activity {

    EditText edit1,edit2;
    Button button1;
    TextView text1;


    private String METHOD_NAME = "multiply"; // our webservice method name
    private String NAMESPACE = "http://muliply.example.com"; // Here package name in webservice with reverse order.
    private String SOAP_ACTION = "http://muliply.example.com/multiply"; // NAMESPACE + method name
    private static final String URL = "http://192.168.100.193:9998/Multiplication/services/Mul?wsdl" ;// you must use ipaddress here, don’t use Hostname or localhost


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        edit1  =(EditText) findViewById(R.id.fnumber);
        edit2  =(EditText) findViewById(R.id.snumber);
        button1=(Button) findViewById(R.id.badd);
        text1  =(TextView) findViewById(R.id.result);


        button1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                try
                {

                //int a=Integer.parseInt(edit1.getText().toString());
                //int b=Integer.parseInt(edit2.getText().toString());

                SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

                PropertyInfo num1 = new PropertyInfo();
                num1.setName("a");
                num1.setValue(5);
                request.addProperty(num1);

                PropertyInfo num2 = new PropertyInfo();
                num2.setName("b");
                num2.setValue(9);
                request.addProperty(num2);


                //request.addProperty("a", 10);
                //request.addProperty("b",11);
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            //  envelope.dotNet = true;
                envelope.setOutputSoapObject(request);
                HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                androidHttpTransport.call(SOAP_ACTION,envelope);
                Object result = envelope.getResponse();
                System.out.println("Result :"+ result.toString());
                text1.setText("Addition : "+result.toString());
                } catch (Exception E) {
                E.printStackTrace();
                ((TextView) findViewById (R.id.result)).setText("ERROR:"   + E.getClass().getName() + ":" + E.getMessage());
                }

            }
        });







    }

}

我收到这个错误:Error:org.ksoap2.SoapFault The service class object does not implement the required method in the following form OMElement multiply(OMElement e)

如何解决这个错误?任何答案都会对我有帮助

将此添加到您的 services.xml 文件中

<operation name="Your method name" >
    <messageReceiver  mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
    </operation>