gpt4 book ai didi

android - 通过 SOAP 发送 xml 数据时无法获得响应

转载 作者:行者123 更新时间:2023-11-29 00:21:39 25 4
gpt4 key购买 nike

我正在尝试通过 SOAP 发送 xml 以获得特定响应。我正在尝试使用默认密码登录。正确的响应将包含一个用户 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>

我应该得到这样的回应

<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>
<pinLoginResponse xmlns="http://tempuri.org/">
<pinLoginResult>
<username>string</username>
<userID>guid</userID>
<isBusinessUser>boolean</isBusinessUser>
<functionOk>boolean</functionOk>
<checkAmount>boolean</checkAmount>
<refundRequested>boolean</refundRequested>
<isPaid>boolean</isPaid>
<duplicateUser>boolean</duplicateUser>
<isvalid>boolean</isvalid>
<funsdok>boolean</funsdok>
<emailok>boolean</emailok>
<recorddbadded>boolean</recorddbadded>
<transisvalid>boolean</transisvalid>
<user2isvalid>boolean</user2isvalid>
</pinLoginResult>
</pinLoginResponse>
</soap:Body>
</soap:Envelope>

但是我得到了这样的东西

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;}

有没有人知道哪里出了问题...

最佳答案

终于破解了。

对我有用的是最初我在一个完整的字符串中提供数据并从 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";

在我的 soapCall 方法中

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());
}

还要在 list 文件中添加 Internet 权限。我希望这对某人有用。

关于android - 通过 SOAP 发送 xml 数据时无法获得响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22625854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com