我是新來的android應用程序,我使用Ksoap2來訪問.net web服務和調用沒有參數執行就好。但有了參數,我變空了。 我遵循網站中提供的所有步驟。我嘗試了一切可能,但迄今爲止沒有運氣。我希望 有人能幫助,傳遞參數使用ksoap2到.net網絡服務,總是傳遞NULL(空)值
private static final String SOAP_ACTION = "http://www.agilelearning.com/GetProvincelist1";
private static final String METHOD_NAME = "GetProvincelist1 ";
private static final String NAMESPACE = "http://www.agilelearning.com" ;
private static final String URL = "http://192.168.1.24/Service.asmx";
//Method executed when Province is selected
private OnItemSelectedListener selectListener = new OnItemSelectedListener()
{
public void onItemSelected(AdapterView parent, View v, int position, long id)
{
try
{
ArrayList<String> districts=new ArrayList<String>();
int Provinceid=position+1;//parent.getItemAtPosition(position).toString();
SoapObject request1 = new SoapObject(NAMESPACE, METHOD_NAME1);
request1.addProperty("Provincename","East Province");
SoapSerializationEnvelope envelope1 = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope1.dotNet = true;
envelope1.setOutputSoapObject(request1);
HttpTransportSE at = new HttpTransportSE(URL);
at.debug = true;
at.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
at.call(SOAP_ACTION1, envelope1);
SoapObject rs = (SoapObject)envelope1.getResponse(); int count=rs.getPropertyCount();
for(int i=0;i<count;i++)
{
districts.add(rs.getProperty(i).toString());
}
ArrayAdapter<String> aa;
aa = new ArrayAdapter<String>(home1.this, android.R.layout.simple_spinner_item, districts);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sd.setAdapter(aa);
}
catch(Exception ex)
{
MessageBox("No Districts found");
}
}
當參數的元素不在正確的xml命名空間中時,會發生這種情況,使用哪個命名空間取決於您的.NET服務的配置方式。 (你可以從WSDL中解決這個問題)。 – superfell 2010-11-03 23:16:56