can any one suggest me requirements for this process
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();
您可以通过两种方式做到这一点,一种是使用URL连接,另一种是通过访问可用于该上传页面的网络服务。
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.