0

I'm new to this android apps, so i developed a sample .net web service app and putted this service in another machine IIS server and calling from there to my system. But i didn't getting response everything looks fine, so 'm placing my code on skydrive so please download my code "Android app and .net service.rar" from below link and check it and tell me what's wrong in that from 2 days i'm struggling with that :(

This is my code...

.net web service code:

[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService]

public class Service : System.Web.Services.WebService
{
    public Service () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string MobileApp(string type) 
    {
        return "Type is"+type;
    }

}

Service call code in eclipse:

public void ServiceCall()
    {
        try{
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);        
        request.addProperty("type",view1.getText().toString());

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

        //@SuppressWarnings("deprecation")
        //ndroidHttpTransport androidHttpTransport=new AndroidHttpTransport(URL);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug=true;

        androidHttpTransport.call(SOAP_ACTION, envelope);

        SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
        TextView txtView=(TextView)findViewById(R.id.txtSer);
                txtView.setText(result.toString());

        }       
        catch (final IOException e)

        {
            // TODO Auto-generated catch block

            e.printStackTrace();

        } catch (final XmlPullParserException e)

        {

            // TODO Auto-generated catch block

            e.printStackTrace();

        } catch (final Exception e)

        {

            // TODO Auto-generated catch block

            e.printStackTrace();

        }


    }

Lines added in manifest:

<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
<uses-sdk android:minSdkVersion="7" /> 

@nag

6
  • 2
    Instead of folks having to download and extract a rar file, please tell us what you're seeing and give the appropriate portions of the code on both server and client. Commented Aug 1, 2011 at 10:50
  • Looks like you've asked this question before: stackoverflow.com/questions/6872219/… From the previous question, it looks like you have 2 pc's - are they networked correctly? Can you ping one from the other? Commented Aug 1, 2011 at 11:03
  • @John Both are different samples but concept is same but there i didn't attach any of my solution for download. Commented Aug 1, 2011 at 11:06
  • @john Also i didn't get solved my problem so that's why i make my solution as downloadable for easy to recognize the problem. Commented Aug 1, 2011 at 11:08
  • 1
    Please don't ask StackOverflow users to download and debug your code. If you have specific questions about a software development related question, please ask it here. If you need to illustrate your issue with code, please repro your issue with the minimum amount of code and add it to your question. Often this process helps you identify the problem before you even ask. Commented Aug 1, 2011 at 20:54

2 Answers 2

0

Should be these but i don't know how is your webservice please give more if these do not work.

request.addProperty("type",view1.getText().toString() );

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

1 Comment

ya i made a change as you said that but even though its not working. Is this working for your side after changing this line?
0

If you have your web service running on one pc and (I assume) your android app running on another pc on the emulator - I'm not sure how the emulator networks to another local pc - this might be part of your problem. Try running your web service on the same pc as the emulator as localhost but use port 10.0.2.2 to connect to it from your application code.

1 Comment

if i give like "localhost:58817/MobService/Service.asmx" its working in my local sys browser but if i use like this "10.0.2.2:58817/MobService/Service.asmx" its not working?

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.