【问题标题】:SoapFault - faultcode: 'soap:Client' faultstring: 'Server did not recognize the value of HTTP Header faultactor: 'null'SoapFault - faultcode: 'soap:Client' faultstring: '服务器无法识别 HTTP Header faultactor 的值:'null'
【发布时间】:2017-12-05 14:08:04
【问题描述】:

我在我的 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;
}

【问题讨论】:

  • 我发现应用程序将空变量发送到 Web 服务的错​​误。

标签: android web-services soap android-ksoap2


【解决方案1】:
private static String SOAP_ACTION = "http://10.77.1.81:83/"

这不是你的肥皂动作。检查您的 wsdl 以了解正确的肥皂操作。

【讨论】:

  • 具有相同的肥皂作用?你能把你的绑定贴在这里吗?
猜你喜欢
  • 1970-01-01
  • 2014-12-02
  • 2010-09-26
  • 2011-12-19
  • 1970-01-01
  • 2016-04-30
  • 1970-01-01
  • 2012-01-19
  • 2018-11-16
相关资源
最近更新 更多