Reputation: 337
can any one suggest me requirements for this process
Upvotes: 1
Views: 277
Reputation: 1860
Try this
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
private static final String HostUrl =" http://test.gloriatech.in:5657/Service.svc";//(your url)
private static final String NAMESPACE = "http://tempuri.org/";
private HttpTransportSE httpTransport = new HttpTransportSE(HostUrl);
SoapPrimitive response=null;
final String methodname="InsertGPSInformation";
request = new SoapObject(NAMESPACE,methodname);
envelope.dotNet = true;
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String getImeNumber=telephonyManager.getDeviceId();
SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String newtime = sdfDateTime.format(new Date(System.currentTimeMillis()));
request.addProperty("IMEINumber",getImeNumber);
request.addProperty("Longitude",longitudeField.getText().toString());
request.addProperty("Latitude",latituteField.getText().toString());
request.addProperty("Date",newtime);
request.addProperty("formName",className);
envelope.setOutputSoapObject(request);
String result = null;
try
{
httpTransport.call(NAMESPACE+"IService/"+methodname, envelope);
response = ( SoapPrimitive )envelope.getResponse();
result=response.toString();
}
catch(Exception e)
{
Toast.makeText(this, "Exception"+e.toString(), Toast.LENGTH_LONG).show();
Log.e("Upload Picture Error:",e.getMessage());
}
Toast.makeText(this, ""+result, Toast.LENGTH_LONG).show();
Upvotes: 1
Reputation: 3095
You can either use a webservice or servlet
if you are using webservice then you will have to do something like
SoapObject requestObject = new SoapObject(NAMESPACE, METHOD_NAME);
requestObject.addProperty("name", value);
requestObject.addProperty("name", value);
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(requestObject);
transportSE = new HttpTransportSE(URL1);
transportSE.call(SOAP_ACTION, envelope);
Object obj = (Object) envelope.getResponse();
and for servlet
HttpResponse response = null;
HttpEntity httpEntity;
InputStream responseInput;
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("*URL here*");
try {
entity = new UrlEncodedFormEntity(postParams);
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
// entity.setContentEncoding(HTTP.UTF_8);
// entity.setContentType("text/html");
httppost.setEntity(entity);
try {
response = httpclient.execute(httppost);
Log.v("Resonse", "Request Send successfully!!!");
httpEntity = response.getEntity();
Log.v("Resonse", "Response recieved successfully!!!");
responseInput = httpEntity.getContent();
BufferedReader br = new BufferedReader(
new InputStreamReader(responseInput));
//....and so on
Upvotes: 0
Reputation: 29672
you can do this in two ways, One is using URL Connection & another one is by accessing the webservies available for that uploading page.
Upvotes: 0