Wednesday, June 9, 2010

[android-developers] Re: .Net Web Service From Android

Thanks. I downloaded the new JAR and imported it into my project.
However, I still get the error can't serialize: vperez. vperez being
the username I typed in the username edit box.

What am I doing wrong?

On Jun 1, 11:56 pm, Reinhard Weidner <reinhard.weid...@gmail.com>
wrote:
> Seems you used the wrong ksoap package, there is a modified one for
> android
>
> http://code.google.com/p/ksoap2-android/
>
> with that package it works fine.
>
> regards,
> Reinhard
>
> On 31 Mai, 23:03, crusso <cru...@clarke.com> wrote:
>
>
>
> > I am trying to call an asp.net web service hosted on our local network
> > from android.
>
> > The ip address and port of where the web service can be located is on
> > 12.102.122.137:5011.  The name of the Web Service Is
> > AppWebService.asmx.  The Web Method is called AuthenticateUser and
> > accepts 2 parameters of UserName and Password.  It returns XML file
> > with some user information such as first name and last name.
>
> > I have read dozens of post trying to get this to work and am still
> > having issues.  I have android 2.1 platform with the update to google
> > maps 4.2.  I also downloaded the KSoap2 file ksoap2-j2me-
> > core-2.1.2.jar.  Below is the code I have so far that I thought might
> > work.  Can anyone let me know where I am going wrong?
>
> > package com.paad.appmobile;
>
> > import java.io.IOException;
> > import java.net.HttpURLConnection;
> > import java.net.MalformedURLException;
> > import java.net.URL;
> > import java.net.URLConnection;
>
> > import android.app.Activity;
> > import android.os.Bundle;
> > import android.widget.*;
> > import android.view.View;
> > import android.view.View.OnClickListener;
> > import org.ksoap2.*;
> > import org.ksoap2.SoapEnvelope;
> > import org.ksoap2.serialization.SoapObject;
> > import org.ksoap2.serialization.SoapPrimitive;
> > import org.ksoap2.serialization.SoapSerializationEnvelope;
> > import org.ksoap2.transport.HttpTransport;
>
> > public class appmobile extends Activity {
> >     /** Called when the activity is first created. */
> >         private Button loginButton;
> >         private EditText userName;
> >         private EditText password;
> >         private TextView loginresults;
> >         private static final String SOAP_ACTION = "http://12.102.122.137:5011/
> > AppWebService.asmx?op=AuthenticateUser";
> >         private static final String METHOD_NAME = "AuthenticateUser";
> >         private static final String NAMESPACE="http://12.102.122.137:5011/";
> >         private static final String URL="http://12.102.122.137:5011/
> > AppWebService.asmx";
> >         private Object resultRequestSOAP=null;
>
> >     @Override
> >     public void onCreate(Bundle savedInstanceState) {
> >         super.onCreate(savedInstanceState);
> > //        setContentView(R.layout.main);
> >         setContentView(R.layout.login);
>
> >         loginButton = (Button) findViewById(R.id.login);
>
> >         loginButton.setOnClickListener(new OnClickListener()
> >         {
> >                 public void onClick(View v)
> >                 {
> >                                 // TODO Auto-generated method stub
> >                         login();
>
> >                         }
> >         });
> >     }
>
> >     public void login()
> >     {
> >                 userName = (EditText) findViewById(R.id.username);
> >                 password = (EditText) findViewById(R.id.password);
> >                 loginresults = (TextView) findViewById(R.id.loginreults);
>
> >                 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
> >         request.addProperty("userName", userName.getText());
> >         request.addProperty("password", password.getText());
>
> >         SoapSerializationEnvelope envelope = new
> > SoapSerializationEnvelope(SoapEnvelope.VER11);
> >         envelope.dotNet = true;
> >         envelope.setOutputSoapObject(request);
> >         HttpTransport androidHttpTransport = new HttpTransport(URL);
>
> >         try
> >         {
> >                 androidHttpTransport.call(SOAP_ACTION, envelope);
> >                 SoapPrimitive resultString =
> > (SoapPrimitive)envelope.getResponse();
> >                 //resultRequestSOAP = envelope.getResponse();
> >                 //String[] results = (String[]) resultRequestSOAP;
> >                 loginresults.setText("Status:" + resultString);
> >         }
> >         catch (Exception ae)
> >         {
> >                 ae.printStackTrace();
> >         }
> >     }
>
> > }
>
> > Any help would be massively appreciated.  I just can't seem to get the
> > correct configuration for the thing to work.
>
> > Thank you in advance.
>
> > crusso- Hide quoted text -
>
> - Show quoted text -

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment