2
我試圖通過SOAP發送xml以獲取特定響應。我試圖用我的默認引腳登錄。正確的響應將包括一個用戶標識,但會變爲零。通過SOAP發送XML數據時無法獲得響應
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;}
有沒有人有任何想法有什麼問題...
你是否在瀏覽器中測試你的服務?用一些樣本值進行測試。 – Sree
是的,我確實測試過。它確實返回特定引腳的有效用戶ID – suja
result = response.getProperty(0).toString();給出了上述結果 – Sree