Hi Fellow Android Developers,
I have fairly new to the development of Android mobile applications.
In one of my applications that I have developed, I want to consume
a .NET web service that I have created and published to the internet.
Below I have uploaded a sample of the code that I started. I have a
receiving a message that I don't understand too much about. That is
posted at the bottom of this post.
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.widget.*;
import android.net.http.AndroidHttpClient;
import android.os.Bundle;
import android.util.Log;
import android.view.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URI;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;
import org.ksoap2.*;
import java.util.Hashtable;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
public class FindMyAndroidActivity extends Activity
{
private static final String SOAP_ACTION = "http://MyServer.com/
HelloWorld";
private static final String METHOD_NAME = "HelloWorld";
private static final String NAMESPACE = "http://MyServer.com/";
//private static final String URL = "http://MyServer.com/
MyWebService.asmx";
private static final String URL = "http://MyServer.com/
MyWebService.asmx";
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.findMyAndroid);
}
public void FindMyAndroids(View view)
{
QueryMyAndroids();
}
public void CancelMyAndroid(View view)
{
Intent intent = new
Intent(FindMyAndroidActivity.this,MyAndroidPickActivity.class);
startActivity(intent);
}
public void QueryMyAndroids()
{
TextView tv = (TextView)findViewById(R.id.ListView01);
AlertDialog.Builder aMessage;
try
{
java.net.URL url = new java.net.URL(URL);
java.net.URLConnection conn = url.openConnection();
conn.setConnectTimeout(0);
java.net.HttpURLConnection httpConnection =
(HttpURLConnection)conn;
httpConnection.connect();
InputStream in = httpConnection.getInputStream();
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK)
{
tv.setText(in.toString());
}
}
catch (Exception aE)
{
tv.setText(aE.toString());
}
}
}
Error Message that I am receiving:
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl
$LimitedInputStream@45f8d630
Please help! :-|
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en