ksoap setProperity is not working in android

307 Views Asked by At

I am building an app that consume .asmx web service

I am facing a strange problem , all parameters that I sent with the request is null in the server

This is my method

try {

                    SoapObject request = new SoapObject(DealightsConstants.NAMESPACE, DealightsConstants.METHOD_MOBILE_LOGIN);
                    //request.addProperty(DealightsConstants.METHOD_MOBILE_LOGIN_USERNAME, username);
                    //request.addProperty(DealightsConstants.METHOD_MOBILE_LOGIN_PASSWORD, password);
                    PropertyInfo pi = new PropertyInfo();
                    pi.setName(DealightsConstants.METHOD_MOBILE_LOGIN_USERNAME);
                    pi.setValue(username);
                    pi.setType(String.class);

                    PropertyInfo pi1 = new PropertyInfo();
                    pi1.setName(DealightsConstants.METHOD_MOBILE_LOGIN_PASSWORD);
                    pi1.setValue(password);
                    pi1.setType(String.class);

                    request.addProperty(pi);
                    request.addProperty(pi1);

                    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                    envelope.dotNet=true;
                    envelope.setOutputSoapObject(request);

                    HttpTransportSE androidHttpTransport = new HttpTransportSE(DealightsConstants.URL);
                    androidHttpTransport.call(DealightsConstants.SOAP_ACTION + DealightsConstants.METHOD_MOBILE_LOGIN, envelope);
                    androidHttpTransport.debug=true;

                    Object result = envelope.getResponse();
                    if (result != null) {

                        Log.i("AMIRA" , result.toString());
                        JSONArray array = new JSONArray(result.toString());
                        if (array != null && array.length() > 0) {
                            return array.getJSONObject(0);
                        } else {
                            return null;
                        }
                    } else {
                        return null;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    return null;
                }

I have use a lot of formats and nothing work with me

EDIT

part of asmx method description

    POST /DealightsWS.asmx HTTP/1.1
Host: ------
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "Dealights/mobileLogin"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <mobileLogin xmlns="Dealights">
      <uname>string</uname>
      <pass>string</pass>
    </mobileLogin>
  </soap:Body>
</soap:Envelope>
1

There are 1 best solutions below

2
buradd On

comparing to my own soap projects, maybe this will fix it:

androidHttpTransport.call(DealightsConstants.SOAP_ACTION, envelope);

notice that I've removed:

+ DealightsConstants.METHOD_MOBILE_LOGIN

which is already provided in the request that is attached to the envelope