SoapFault - 故障代码:' s:客户端' faultstring:'错误代码2006' faultactor:' null' detail:org.kxml2.kdom.Node

时间:2014-07-10 07:22:50

标签: android wsdl ksoap

在尝试从WSDL Webservices获取响应时,我一次又一次地收到此错误。

我正在使用它:

    //Create request
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    //Property which holds input parameters
    PropertyInfo celsiusPI = new PropertyInfo();
    celsiusPI.setName("Driver.Token");
    celsiusPI.setType(PropertyInfo.STRING_CLASS);
    celsiusPI.setValue("c1f40074-4bf8-4159-ba15-e799e9efad9e");

    PropertyInfo latitude = new PropertyInfo();
    latitude.setName("Latitude");
    latitude.setType(Double.class);
    latitude.setValue(28.5192);

    PropertyInfo longitude = new PropertyInfo();
    longitude.setName("Longitude");
    longitude.setType(Double.class);
    longitude.setValue(77.2130);

    //Add the property to request object
    request.addProperty(celsiusPI);
    request.addProperty(latitude);
    request.addProperty(longitude);


    //Create envelope
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;


    //Set output SOAP object
    envelope.setOutputSoapObject(request);
    //Create HTTP call object
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    try {
        //Involve web service
        androidHttpTransport.call(SOAP_ACTION, envelope);
        //Get the response
        //SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
        Object response = envelope.getResponse();
        //Assign it to fahren static variable
        fahren = response.toString();
        Log.d("Response Message", fahren);
    } catch (Exception e) {
        e.getMessage();
        Log.d("Response Message--------------------", e.getMessage());
    }
}

获得此例外:SoapFault - faultcode:' s:客户端' faultstring:'错误代码2006' faultactor:' null' detail:org.kxml2.kdom.Node

这非常令人沮丧。如果有人可以帮助我!

1 个答案:

答案 0 :(得分:0)

检查需要传递的肥皂动作" wsdl:输入wsaw:Action"您的方法名称

import java.net.SocketException;

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

import android.R.string;
import android.content.Context;
import android.util.Log;

public class Services {
    private static String SOAP_ACTION;
    private static String METHOD_NAME;
    private static String NAMESPACE = "http://tempuri.org/";

private static String URL = "xyz";

private static Context mContext;

// Register User
public static String Register(Context context, String StudentCode,
        ) {

    SOAP_ACTION = "http://tempuri.org/ABC/Register"; **//Here you need to pass wsdl:input wsaw:Action**
    METHOD_NAME = "Register";

    mContext = context;
    String result = null;

    // Ack
    Log.e("method", "Register");

    try {
        SoapPrimitive responses = null;
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        // Property PassCode
        PropertyInfo piStudentCode = new PropertyInfo();
        piStudentCode.setName("sPassCode");
        piStudentCode.setValue(StudentCode);
        piStudentCode.setType(string.class);
        request.addProperty(piStudentCode);



        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE andHttp = new HttpTransportSE(URL);

        try {
            andHttp.call(SOAP_ACTION, envelope);
            responses = (SoapPrimitive) envelope.getResponse();

        } catch (SocketException ex) {
            Log.e("Register SE ex", ex.toString());
            ex.printStackTrace();
        } catch (Exception e) {
            Log.e("Register ex", e.toString());
            e.printStackTrace();
        }

        result = responses.toString();
    } catch (Exception e) {
        e.printStackTrace(System.err);
        Log.e("Register main ex", e.toString());
    }

    return result;
}