Сервер не может прочитать параметры при подключении к веб-сервису
Я подключаюсь к.net webservice с помощью приведенного ниже кода, я могу подключиться и получить неполный ответ от сервера. Я добавляю userId имеет параметр с '1' имеет значение типа string. Проблема в том, что 'сервер не может прочитать параметры, которые я отправляю в запросе. Я не уверен, что со мной что-то не так. Я приложил запрос и ответ веб-службы и мой код.
и мой код подключения Android
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) {
}
}
веб-сервис называется здесь.
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());
}
1 ответ
Сделал очень глупую ошибку, я узнал после того, как сделал много проб и ошибок работы..,private static String NAMESPACE = "http://tempuri.org";
изменился на private static String NAMESPACE = "http://tempuri.org/";
и все работало хорошо.