gpt4 book ai didi

android - 使用 ksoap2 将参数传递给 .net Web 服务,始终传递 null(空)值

转载 作者:行者123 更新时间:2023-11-29 02:16:36 25 4
gpt4 key购买 nike

我是 android 应用程序的新手,我正在使用 Ksoap2 访问 .Net webservice 并且调用在没有参数的情况下执行得很好。但是有了参数,我变得空了。我遵循了站点中提供的所有步骤。我尝试了一切可能但到目前为止没有运气。我希望有人可以帮忙,

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

}

最佳答案

我遇到了同样的问题。在我的例子中,我从 android 发送的参数名称与我的网络服务期望的参数名称不同。

它们必须相同。

    request.addProperty("DeviceId",uid); --add parameter from android


[WebMethod]
public LoginResult Login(string DeviceId) ---web service
{
.......
}

关于android - 使用 ksoap2 将参数传递给 .net Web 服务,始终传递 null(空)值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3298956/

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