Hi everyone
i am looking for soap web services in android. my hand also will help to u
actually i need to connect the PHP soap web services in android
i need to get the response from the PHP server and should return it in xml
format.
can any body give me suggestions regarding this
i have tried some small code but it is unexpectedly quiting
if any android runtime errors in log cat is any problem
how can i clear that android runtime errors in log cat what i am getting ...
Here is my code
protected void onCreate(Bundle icicle)
{
super.onCreate(icicle);
// SOAP Request for the FindServiceSOAP.GetRatingInfo web service
String soapRequestXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<soap:Envelope xmlns:soap=\"
http://schemas.xmlsoap.org/soap/envelope/\" " +
" xmlns:xsi=\"
http://www.w3.org/2001/XMLSchema-instance\" " +
" xmlns:xsd=\"
http://www.w3.org/2001/XMLSchema\">\n" +
" <getRating xmlns=\"http://tempuri.org\">\n"
+
" </getRating>\n" +
" </soap:Body>\n" +
"</soap:Envelope>";
String url = "http://www.hasdhs.com/ask.php";
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(url);
// Construct a SOAP request by hand
StringBuffer request = new StringBuffer();
request.append(soapRequestXML);
postMethod.setRequestBody(request.toString());
postMethod.setRequestHeader("Content-Type","text/xml; charset=utf-8");
postMethod.setRequestHeader("SOAPAction",
"\"http://tempuri.org\"");
int statusCode = 0;
try {
statusCode = client.executeMethod(postMethod);
} catch (IOException e) {
Log.d("ReverseGeoCoder", e.toString(), e);
}
// Parse the SOAP Response
MyContentHandler myContentHandler = new MyContentHandler();
try {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
} catch (Exception e) {
Log.d("ISizzle", e.toString(), e);
}
// Display the response details.
List list = myContentHandler.getRating();
String[] items = new String[list.size()];
for (int i = 0; i < list.size(); i++)
{
MyContentHandler.GetRating rating = (MyContentHandler.GetRating)
list.get(i);
}
// Show the data in the list view
ListView listView = (ListView) findViewById(R.id.data);
listView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
items));
postMethod.releaseConnection();
}
}
thanks in advance
On Sat, Jun 20, 2009 at 8:08 PM, fifi <[email protected]> wrote:
>
> I would like to parse a soap envelope using KSOAP2 how can I start I
> am new and I tried the following code but i couldnot. Also I would
> like to display the parsed elements on the screen?Thanks
>
> package parsingsteps;
>
> import java.io.*;
> import org.ksoap2.SoapEnvelope;
> import org.kxml2.io.KXmlParser;
> import org.xmlpull.v1.XmlPullParserException;
>
> /**
> *
> * @author fa00064
> */
> public class ParsingSteps {
>
> /**
> * @param args the command line arguments
> */
> public static void main(String[] args) {
> try{
> // String msg="<hello>World!</hello>";
> String msg = "<SOAP-ENV:Envelope " + "xmlns:SOAP-ENV=\"http://
> www.w3.org/2001/12/soap- envelope\" " + "xmlns:xsi=\"http://www.w3.org/
> 2001/XMLSchema-instance <http://www.w3.org/%0A2001/XMLSchema-instance>\" "
> +"xmlns:xsd=\"http://www.w3.org/2001/
> XMLSchema\"& gt;" +
> "<SOAP-ENV:Body>" +
> "<result>" +
> "<message xsi:type=\"xsd:string\">Hello World</message>" +
> "</result>" +
> "</SOAP-ENV:Body>" +
> "</SOAP-ENV:Envelope>";
>
>
> // byte[] in= msg.getBytes();
>
> KXmlParser parser=new KXmlParser();
> parser.setInput(new StringReader(msg));
> SoapEnvelope soapenvelope= new SoapEnvelope
> (SoapEnvelope.VER12);
> //soapenvelope.parse(parser);
> soapenvelope.parseBody(parser);
>
>
> }
> catch (IOException e) {
> System.out.println("Error reading URI: " + e.getMessage
> ());
> } catch (XmlPullParserException e) {
> System.out.println("Error in parsing: " + e.getMessage
> ());
> }
> // String result=parser.getName();
> //System.out.println(result);
> }
> }
>
> >
>
--
Regards
-------------------
Desu Vinod Kumar
[email protected]
09916009493
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---