Android 服务器在建立webservice连接时无法读取参数
我正在使用以下代码连接到.net webservice,我能够连接并从服务器获得不完整的响应。我正在添加userId has参数,其值为“1”且类型为字符串。问题是“服务器根本无法读取我在请求中发送的参数”。我不确定我是否有问题。我已附加了webservice请求和响应以及我的代码 还有我的android连接代码Android 服务器在建立webservice连接时无法读取参数,android,asp.net,web-services,ksoap2,Android,Asp.net,Web Services,Ksoap2,我正在使用以下代码连接到.net webservice,我能够连接并从服务器获得不完整的响应。我正在添加userId has参数,其值为“1”且类型为字符串。问题是“服务器根本无法读取我在请求中发送的参数”。我不确定我是否有问题。我已附加了webservice请求和响应以及我的代码 还有我的android连接代码 private class AsyncCallWS extends AsyncTask<String, Void, Void> { @Override
private class AsyncCallWS extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... params) {
//Invoke webservice
displayText=WebService.invokeHelloWorldWS(editText,"GetReminder");
return null;
}
@Override
protected void onPostExecute(Void result) {
//Set response
tv.setText(displayText);
//Make ProgressBar invisible
pg.setVisibility(View.INVISIBLE);
}
@Override
protected void onPreExecute() {
//Make ProgressBar invisible
pg.setVisibility(View.VISIBLE);
}
@Override
protected void onProgressUpdate(Void... values) {
}
}
我犯了一个很愚蠢的错误,我做了这么多的尝试后才发现。。,
private静态字符串命名空间=”http://tempuri.org";代码>更改为私有静态字符串命名空间=”http://tempuri.org/";代码>一切正常。请发布您的服务器端代码,我从服务器端工作人员那里得到了三个文件,…,我粘贴了…,请检查…,据我所知,您的代码似乎是合法的。意思是完美的?但为什么服务器不能看到我的参数
public class WebService {
//What is the Namespace of the Webservice ??
private static String NAMESPACE = "http://tempuri.org";
//Webservice URL
private static String URL = "http://1.3.44.5:8080/csmmobileapi/service.asmx";
//SOAP Action URI ???
private static String SOAP_ACTION = "http://tempuri.org/GetReminder";
private static final String TAG=null;
public static String invokeHelloWorldWS(String name, String webMethName)
{
boolean result=false;
String resTxt = null;
// Create request
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
SoapObject request = new SoapObject(NAMESPACE, webMethName);
envelope.setOutputSoapObject(request);
androidHttpTransport.debug=true;
// Property which holds input parameters
PropertyInfo sayHelloPI = new PropertyInfo();
// Set Name
sayHelloPI.setName("UserId");
// Set Value
sayHelloPI.setValue("1");
// Set dataType
sayHelloPI.setType(String.class);
// Add the property to request object
request.addProperty(sayHelloPI);
//Set envelope as dotNet
envelope.dotNet = true;
try {
// Invoke web service
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the response
String response=androidHttpTransport.responseDump;
Log.d("Result --- ", response.toString() );
//tried with SoapObject and SoapPrimitive
SoapObject obj=(SoapObject)envelope.getResponse();
Log.d("Result --- ", obj);
System.out.println("obj---->" + obj.toString());
}