How to connect to a SOAP webServices with Android
Posted
by dom4
on Stack Overflow
See other posts from Stack Overflow
or by dom4
Published on 2010-04-29T09:33:55Z
Indexed on
2010/04/29
9:37 UTC
Read the original article
Hit count: 533
Hi everyone,I'm programming an application who must send coordinate and request to a WebServices this is my code:
private String SOAP_ACTION = "getAllPositions";
private String METHOD_NAME = "getAllPositions";
private String NAMESPACE = "http://session/";
private static final String URL ="http://192.41.218.56:8080/WSGeoEAR-WSGeoServer/NavFinderBean?WSDL";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("idUtente",1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
androidHttpTransport.debug = true;
try{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
ArrayList<position> resultData = (ArrayList<position>)resultsRequestSOAP.getProperty("getAllPositionsResponse");
for(position p : resultData)
{
((TextView)findViewById(R.id.lblStatus)).setText(p.getAllInformation());
}
} catch(Exception E) {
((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage());
}
}
}
I've also create a class position.
It doesn't work,can someone help me?Thanks
© Stack Overflow or respective owner