[英]ksoap2 requests with String parameters returns null
我是android開發的新手,正在使用Ksoap2訪問.Net Web服務,並且在沒有參數或整數參數的情況下可以很好地執行調用,但是在使用String參數的情況下我什么也沒得到。 以下代碼的目的是按名稱搜索餐廳並返回它們的列表。
Action = "SearchResturant";
request = new SoapObject(WSDL_TARGET_NAMESPACE, Action);
PropertyInfo pi = new PropertyInfo();
pi.setName("name");
pi.setValue(Name);
pi.setType(String.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
// envelope.dotNet = true;
// envelope.bodyOut = request;
envelope.setOutputSoapObject(request);
envelope.setAddAdornments(false);
envelope.implicitTypes = true;
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
httpTransport.debug=true;
httpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding= \"UTF-8\"?>");
try
{
httpTransport.call(SOAP_ACTION + Action, envelope);
return httpTransport.responseDump.toString();
}
catch (Exception exception)
{
isEroor=true;
return exception.toString();
}
這是我得到的回應:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><SearchResturantResponse xmlns="http://RST.org/"><SearchResturantResult /></SearchResturantResponse></soap:Body></soap:Envelope>
有人可以幫我嗎?
您需要在調用httptransport之后添加一行並返回最終結果。 檢查此解決方案它將起作用
httpTransport.call(SOAP_ACTION + Action, envelope);
SoapObject final_result=(SoapObject)envelope.bodyIn;
return final_result.toString();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.