Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.venkattt.pack;
- import java.net.SocketException;
- import org.ksoap2.SoapEnvelope;
- import org.ksoap2.serialization.SoapObject;
- import org.ksoap2.serialization.SoapPrimitive;
- import org.ksoap2.serialization.SoapSerializationEnvelope;
- import org.ksoap2.transport.AndroidHttpTransport;
- import org.ksoap2.transport.HttpTransportSE;
- import android.app.Activity;
- import android.os.Bundle;
- public class SoapWebservicesExampleActivity extends Activity {
- /** Called when the activity is first created. */
- final String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
- final String URL = "http://**********:8000/sap/bc/srt/wsdl/srvc_14DAE9C8D79F1EE196F1FC6C6518A345/wsdl11/allinone/ws_policy/document?sap-client=800&sap-user=*******&sap-password=*******";
- final String METHOD_NAME = "Z_GET_CUST_GEN";
- final String SOAP_ACTION = "urn:sap-com:document:sap:soap:functions:mc-style/Z_GET_CUST_GEN";
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // set up
- request.addProperty("Input", "1460");
- request.addProperty("Langu", "d");
- SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12); // put all required data into a soap
- envelope.dotNet = false;
- envelope.setOutputSoapObject(request);
- HttpTransportSE httpTransport = new HttpTransportSE(URL);
- httpTransport.debug = true;
- try {
- httpTransport.call(SOAP_ACTION, envelope);
- Object result = (Object) envelope.getResponse();
- System.out.println("theeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee result"+result);
- }
- catch(SocketException ex){
- ex.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- HttpPost httppost = new HttpPost("http://192.168.1.103/test/index1.php");
- //httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- HttpResponse response = httpclient.execute(httppost);
- HttpEntity entity = response.getEntity();
- is = entity.getContent();
- Log.e("log_tag", "connection success ");
- //convert response to string
- BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
- StringBuilder sb = new StringBuilder();
- String line = null;
- while ((line = reader.readLine()) != null)
- {
- sb.append(line + "n");
- }
- is.close();
- result=sb.toString();
- //Log.e("",""+result);
- public class From extends Activity
- {
- HttpPost httppost;
- InputStream is;
- ListView lv;
- TextView displayStrip;
- ArrayList<String> atcodeid=new ArrayList<String>();
- ArrayAdapter<String> adapter;
- ArrayList<String> listItems=new ArrayList<String>();
- ArrayList<String> originalname=new ArrayList<String>();
- String mode;
- Button btn_name;
- Button btn_map;
- SharedPreferences prefs;
- int testing;
- String shortcutname;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.from);
- lv = (ListView)findViewById(R.id.listView1);
- displayStrip= (TextView)findViewById(R.id.displayStrip);
- btn_name = (Button)findViewById(R.id.name);
- btn_map = (Button)findViewById(R.id.map);
- prefs = PreferenceManager.getDefaultSharedPreferences(this);
- testing = prefs.getInt("settings",0);
- adapter=new ArrayAdapter<String>(From.this,
- android.R.layout.simple_list_item_1,
- listItems);
- lv.setAdapter(adapter);
- lv.setFastScrollEnabled(true);
- String result = "";
- // ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
- // nameValuePairs.add(new BasicNameValuePair("birthyear","1990"));
- try{
- HttpClient httpclient = new DefaultHttpClient();
- HttpPost httppost = new HttpPost("http://192.168.1.103/test/index1.php");
- //httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- HttpResponse response = httpclient.execute(httppost);
- HttpEntity entity = response.getEntity();
- is = entity.getContent();
- //Log.e("log_tag", "connection success ");
- // Toast.makeText(getApplicationContext(), "pass", Toast.LENGTH_SHORT).show();
- }catch(Exception e){
- Log.e("log_tag", "Error in http connection "+e.toString());
- }
- //convert response to string
- try
- {
- BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
- StringBuilder sb = new StringBuilder();
- String line = null;
- while ((line = reader.readLine()) != null)
- {
- sb.append(line + "n");
- // Toast.makeText(getApplicationContext(), "pass", Toast.LENGTH_SHORT).show();
- }
- is.close();
- result=sb.toString();
- //Log.e("",""+result);
- }catch(Exception e){
- Log.e("log_tag", "Error converting result "+e.toString());
- }
- try{
- JSONArray jArray = new JSONArray(result);
- JSONObject json_data=null;
- for(int i=0;i<jArray.length();i++)
- {
- json_data =jArray.getJSONObject(i);
- String src_name=json_data.getString("commonname");
- originalname.add(src_name);
- if(src_name.contains("Wharf"))
- {
- shortcutname=src_name.substring(0, src_name.indexOf("Wharf"));
- }
- else if(src_name.contains("Station"))
- {
- shortcutname=src_name.substring(0, src_name.indexOf("Station"));
- }
- else
- shortcutname=src_name;
- listItems.add(shortcutname);
- //listItems.add(src_name);
- //Log.e("",i+"testing"+src_name);
- atcodeid.add(json_data.getString("Atcocode"));
- adapter.notifyDataSetChanged();
- }
- }catch(JSONException e){
- Log.e("log_tag", "Error parsing data "+e.toString());
- Toast.makeText(getApplicationContext(), "fail", Toast.LENGTH_SHORT).show();
- }
- lv.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView arg0,
- View arg1, int position, long arg3) {
- Intent i = new Intent(From.this, To.class);
- //Toast.makeText(From.this, ""+atcodeid.get(position)+" "+originalname.get(position), Toast.LENGTH_SHORT).show();
- i.putExtra("mode", mode);
- i.putExtra("id", atcodeid.get(position));
- i.putExtra("fromacto", originalname.get(position));
- startActivity(i);
- }
- });
- btn_map.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- btn_map.requestFocus();
- btn_map.setFocusable(true);
- SharedPreferences.Editor prefsEditor = prefs.edit();
- prefsEditor.putInt("settings", 1);
- prefsEditor.commit();
- Intent intent=new Intent(From.this , FromGoogleMaps.class);
- startActivity(intent);
- }
- });
- btn_name.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- btn_name.requestFocus();
- btn_name.setFocusable(true);
- SharedPreferences.Editor prefsEditor = prefs.edit();
- prefsEditor.putInt("settings", 0);
- prefsEditor.commit();
- Intent intent=new Intent(From.this , From.class);
- startActivity(intent);
- }
- });
- }
- responseDump = new String(buf);
- unescape(responseDump);
- your_string = responseDump;
- String SOAP_ACTION = "http://www.webserviceX.NET/GetWeather";
- String METHOD_NAME = "GetWeather";
- String NAMESPACE = "http://www.webserviceX.NET";
- String SOAP_ADDRESS = "http://www.webservicex.com/globalweather.asmx";
- SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);
- request.addProperty("login",login_id);
- request.addProperty("pwd",Password_id);
- SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
- envelope.dotNet = true;
- envelope.setOutputSoapObject(request);
- envelope.implicitTypes = true;
- HttpTransportSE httpTransaport = new HttpTransportSE(SOAP_ADDRESS);
- httpTransaport.debug = true;
- String response = null;
- try
- {
- httpTransaport.call(SOAP_ACTION,envelope);
- response = httpTransaport.responseDump;
- } catch (XmlPullParserException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return response;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement