Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 通过SOAP发送xml数据时无法获取响应_Android_Xml_Soap - Fatal编程技术网

Android 通过SOAP发送xml数据时无法获取响应

Android 通过SOAP发送xml数据时无法获取响应,android,xml,soap,Android,Xml,Soap,我试图通过SOAP发送xml以获得特定的响应。我正在尝试使用默认pin登录。正确的响应将包括一个用户id,但我得到零 StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder() .permitAll().build(); StrictMode.setThreadPolicy(policy); // Create the soap request object Soa

我试图通过SOAP发送xml以获得特定的响应。我正在尝试使用默认pin登录。正确的响应将包括一个用户id,但我得到零

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
            .permitAll().build();
    StrictMode.setThreadPolicy(policy);

    // Create the soap request object
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    // Set the property info for the to currency
    PropertyInfo value = new PropertyInfo();
    value.setName("xml");
    value.setValue(xml);
    value.setType(String.class);
    request.addProperty(value);


    // Create the envelop.Envelop will be used to send the request
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);        
    envelope.dotNet = true;       

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);            
        SoapObject response = (SoapObject)envelope.bodyIn;

        result = response.getProperty(0).toString();           

        Log.i("RES", result);


    } catch (Exception e) {

        result = "EXCEP " + e.toString();
    }
我的xml是

     <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns:xsd="http://www.w3.org/2001/XMLSchema"    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<pinLogin xmlns="http://tempuri.org/">
  <pin1>string</pin1>
  <pin2>string</pin2>
  <pin3>string</pin3>
  <pin4>string</pin4>
</pinLogin>

有人知道出了什么问题吗…

终于破解了

对我有效的是,最初我以完整的字符串形式提供数据,并从edittext中添加了一些数据。现在,我将pin码分配给字符串,并通过PropertyIndo将这些字符串添加到Soap请求中。我还添加了xmlversiontag。我添加了工作代码

private final String NAMESPACE = "";
private final String URL = "";
private final String SOAP_ACTION = "";
private final String METHOD_NAME = "";
String _TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";        
String pin1 = "a";
String pin2 = "b";
String pin3 = "8";
String pin4 = "d";

另外,请在清单文件中添加Internet权限。我希望这可能对某些人有用。

您是否在浏览器中测试您的服务?用一些样本值进行测试。是的,我做了测试。它确实为特定的pinresult=response.getProperty(0.toString()返回有效的用户id;正确给出上述结果是的,给出了结果我认为在传递值时存在一些问题,请检查。
anyType{userID=00000000-0000-0000-0000-000000000000;isBusinessUser=false; functionOk=false; checkAmount=false;refundRequested=false; ispaid=false; duplicateUser=false;
isValid=false; funsdok=false;emailok=false;recorddbadded=false;
transisvalid=false;user2isvalid=false;}
private final String NAMESPACE = "";
private final String URL = "";
private final String SOAP_ACTION = "";
private final String METHOD_NAME = "";
String _TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";        
String pin1 = "a";
String pin2 = "b";
String pin3 = "8";
String pin4 = "d";
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

PropertyInfo _pin1 = new PropertyInfo();
_pin1.setName("pin1");
_pin1.setValue(pin1);
_pin1.setType(String.class);

PropertyInfo _pin2 = new PropertyInfo();
_pin2.setName("pin2");
_pin2.setValue(pin2);
_pin2.setType(String.class);

PropertyInfo _pin3 = new PropertyInfo();
_pin3.setName("pin3");
_pin3.setValue(pin3);
_pin3.setType(String.class);

PropertyInfo _pin4 = new PropertyInfo();
_pin4.setName("pin4");
_pin4.setValue(pin4);
_pin4.setType(String.class);


request.addProperty(_pin1);
request.addProperty(_pin2);
request.addProperty(_pin3);
request.addProperty(_pin4);

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

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

try {
       androidHttpTransport.setXmlVersionTag(_TAG);
       androidHttpTransport.call(SOAP_ACTION, envelope);
       SoapObject response = (SoapObject)envelope.bodyIn;
       result = response.getProperty(0).toString();
       Log.i("RES", result);
    }
catch(Exception e){
       Log.i("ERR" , e.toString());
}