i am trying to fetch the record from the SOAP web service but due to larger
xml size i didn't get the proper output,
here i'm putting my code as well as logcat entry.
*------------------------------------------------*
*CODE (SoapHTTPPostActivity.java)*
*------------------------------------------------*
public class SoapHTTPPostActivity extends Activity
{
private XMLGettersSetters data;
//private XML_DOM_Parser xml_dom_parser=null;
private ListView list=null;
private TextView selection=null;
private ArrayList<ArrayList<String>> masterData=new
ArrayList<ArrayList<String>>();
//private String URL =
"http://pro.bookadspace.com/WebServices/BAAccountService.asmx";
private ProgressDialog dialog=null;
private String TAG="SOAP";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
list=(ListView)findViewById(R.id.list);
selection=(TextView)findViewById(R.id.selection);
FetchRecord fetchRecord=new FetchRecord();
fetchRecord.execute();
}
public class FetchRecord extends AsyncTask<String,
ArrayList<ArrayList<String>>, ArrayList<ArrayList<String>>>
{
String xml = "<?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>"+
"<GetAllAdspacesByBusiness xmlns=\"http://tempuri.org/\">"+
"<businessID>"+55+"</businessID>"+
"</GetAllAdspacesByBusiness>"+
"</soap:Body>"+
"</soap:Envelope>";
@Override
protected void onPreExecute()
{
super.onPreExecute();
//xml_dom_parser=new XML_DOM_Parser();
dialog = ProgressDialog.show(SoapHTTPPostActivity.this, "Downloading",
"Loading. Please wait...", true);
}
@Override
protected ArrayList<ArrayList<String>> doInBackground(String... params)
{
String request = String.format(xml);
HTTPOST httpost = new HTTPOST();
String
xmlResult=httpost.getResponseByFile("http://pro.bookadspace.com/WebServices/BAAccountService.asmx",request);
InputStream in=new ByteArrayInputStream(xmlResult.getBytes());
try
{
InputSource is=new InputSource(in);
//-----------------------------------------------------
SAXParserFactory saxPF = SAXParserFactory.newInstance();
SAXParser saxP = saxPF.newSAXParser();
XMLReader xmlR = saxP.getXMLReader();
URL url = new
URL("http://pro.bookadspace.com/WebServices/BAAccountService.asmx"); // URL
of the XML
XMLHandler myXMLHandler = new XMLHandler();
xmlR.setContentHandler(myXMLHandler);
// ++++++++++++++++++++ Facing Exception ++++++++++++++++++++
xmlR.parse(is);
// ++++++++++++++++++++ Exception ++++++++++++++++++++
}
catch(Exception e)
{
Log.d(TAG,"++++++++++ Catch : "+e.toString());
}
//data = new XMLGettersSetters();
//=====================================================
return null;
}
@Override
protected void onPostExecute(ArrayList<ArrayList<String>> result)
{
//super.onPostExecute(result);
dialog.dismiss();
for(int i=0;i<data.getId().size();i++)
{
Log.d("SAX","+-+-+-+-+-+--> Id : "+data.getId());
Log.d("SAX","+-+-+-+-+-+--> Name: "+data.getAdName());
Log.d("SAX","+-+-+-+-+-+--> Address : "+data.getAddress());
}
Log.d("SOAP","++++**+-// Finish Successfully ++++**+-//");
//list.setAdapter(new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_list_item_1,result.get(0)));
}
}
}
*------------------------------------------------*
*CODE (HTTPPOST.java)*
*------------------------------------------------*
public class HTTPOST
{
public String getResponseByFile(String URL,String xml)
{
HttpPost httpPost = new HttpPost(URL);
String response_string = null;
try
{
StringEntity ent=new StringEntity(xml,"UTF-8");
httpPost.setHeader("Content-Type","text/xml;charset=UTF-8");
httpPost.setEntity(ent);
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(httpPost);
response_string = EntityUtils.toString(response.getEntity());
//Log.d("SOAP","+++++++++ Response : "+response_string);
}
catch (Exception e)
{
e.printStackTrace();
}
return Html.fromHtml(response_string).toString();
}
}
*------------------------------------------------*
*LogCat*
*------------------------------------------------*
D/dalvikvm(1260): GC_FOR_MALLOC freed 10803 objects / 490816 bytes in 63ms
08-16 19:13:38.885: D/SOAP(1260):
++++++++++ *Catch : org.apache.harmony.xml.ExpatParser$ParseException: At
line 1, column 0: syntax error*
08-16 19:13:38.885: D/AndroidRuntime(1260): Shutting down VM
08-16 19:13:38.885: W/dalvikvm(1260): threadid=1: thread exiting with
uncaught exception (group=0x4001d800)
08-16 19:13:38.895: E/AndroidRuntime(1260): FATAL EXCEPTION: main
*08-16 19:13:38.895: E/AndroidRuntime(1260): java.lang.NullPointerException*
*
*
*08-16 19:13:38.895: E/AndroidRuntime(1260): at
com.simform.adspacesoapparsing.SoapHTTPPostActivity$FetchRecord.onPostExecute(SoapHTTPPostActivity.java:113)
*
*
*
*08-16 19:13:38.895: E/AndroidRuntime(1260): at
com.simform.adspacesoapparsing.SoapHTTPPostActivity$FetchRecord.onPostExecute(SoapHTTPPostActivity.java:1)
*
08-16 19:13:38.895: E/AndroidRuntime(1260): at
android.os.AsyncTask.finish(AsyncTask.java:417)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
android.os.AsyncTask.access$300(AsyncTask.java:127)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
android.os.Looper.loop(Looper.java:123)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
android.app.ActivityThread.main(ActivityThread.java:4627)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
java.lang.reflect.Method.invokeNative(Native Method)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
java.lang.reflect.Method.invoke(Method.java:521)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-16 19:13:38.895: E/AndroidRuntime(1260): at
dalvik.system.NativeStart.main(Native Method)
08-16 19:13:38.916: W/ActivityManager(59): Force finishing activity
com.simform.adspacesoapparsing/.SoapHTTPPostActivity
08-16 19:13:39.452: W/ActivityManager(59): Activity pause timeout for
HistoryRecord{44f729e8 com.simform.adspacesoapparsing/.SoapHTTPPostActivity}
08-16 19:13:45.175: D/dalvikvm(294): GC_EXPLICIT freed 27 objects / 1368
bytes in 133ms
08-16 19:13:49.694: W/ActivityManager(59): Activity destroy timeout for
HistoryRecord{44f729e8 com.simform.adspacesoapparsing/.SoapHTTPPostActivity}
08-16 19:17:22.785: D/SntpClient(59): request time failed:
java.net.SocketException: Address family not supported by protocol
--
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