0

I am connecting to .net webservice using below code,i am able to connect and get incomplete response from server.I am adding userId has parameter with '1' has value of type string.The issue is 'server is not able to read the parameters at all i am sending in request' .I am not sure if something is wrong on my side.I have attached the webservice request and response and my code.

enter image description here

and my android connecting code

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) {
        }

    }

webservice called here.

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());
}
4
  • pls do post your server side code Commented Mar 23, 2015 at 17:52
  • pastebin.com/t2YeAuHW ,i got three files from person working on server side,..,which i pasted ..,please check.., Commented Mar 24, 2015 at 8:59
  • as per my knowledge your code seems legit. Commented Mar 24, 2015 at 10:29
  • means perfect? but why server is not able to see my params Commented Mar 24, 2015 at 10:41

1 Answer 1

0

Did a very silly mistake,i found out after doing so much trial n error work.., private static String NAMESPACE = "http://tempuri.org"; changed to private static String NAMESPACE = "http://tempuri.org/"; and everything worked well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.