SoapFault - faultcode:'soap:Client'faultstring:'服务器无法识别HTTP Header faultactor的值:'null'

时间:2014-01-30 09:26:14

标签: android web-services soap android-ksoap2

我在Android应用程序上使用Ksoap Api。当我在静态IP中使用我的.net Web服务时,它可以正常工作,但是当我从本地IP使用我的Web服务时,就会发生此错误。

 SoapFault - faultcode: 'soap:Client' faultstring: 'Server did not recognize the value of     HTTP Header SOAPAction: http://10.77.1.81:83/InsertData.' faultactor: 'null' detail: org.kxml2.kdom.Node@43e7e128.

我的网络服务和设备在同一个网络中。 我的代码是

  public class WebService {

private static String NAMESPACE = "http://10.77.1.81:83/";
private static String URL = "http://10.77.1.81:83/Android.asmx";
private static String SOAP_ACTION = "http://10.77.1.81:83/";


public static String InsertData(String name,String work,String position, String webMethName) {
    String resTxt = null;
    // Create request
    SoapObject request = new SoapObject(NAMESPACE, webMethName);
    // Property which holds input parameters
    PropertyInfo celsiusPI = new PropertyInfo();
    // Set Name whcih is in webservice
    celsiusPI.setName("name");
    // Set Value
    celsiusPI.setValue(name);
    // Set dataType
    celsiusPI.setType(String.class);
    // Add the property to request object
    request.addProperty(celsiusPI);


    PropertyInfo celsiusP2 = new PropertyInfo();
    // Set Name whcih is in webservice
    celsiusP2.setName("work");
    // Set Value
    celsiusP2.setValue(work);
    // Set dataType
    celsiusP2.setType(String.class);
    // Add the property to request object
    request.addProperty(celsiusP2);


    PropertyInfo celsiusP3 = new PropertyInfo();
    // Set Name whcih is in webservice
    celsiusP3.setName("position");
    // Set Value
    celsiusP3.setValue(position);
    // Set dataType
    celsiusP3.setType(String.class);
    // Add the property to request object
    request.addProperty(celsiusP3);


    // 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 {
        // Invole web service
        androidHttpTransport.call(SOAP_ACTION+webMethName, envelope);
        // Get the response
        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
        // Assign it to fahren static variable
        resTxt = response.toString();

    } catch (Exception e) {

        resTxt =e.getMessage();
    } 

    return resTxt;
}

1 个答案:

答案 0 :(得分:0)

private static String SOAP_ACTION = "http://10.77.1.81:83/"

这不是你的肥皂行动。检查你的wsdl是否有正确的肥皂动作。