package com.tuan; import org.apache.http.Header; 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 org.kxml2.kdom.Element; import org.kxml2.kdom.Node; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class Xignite_WSActivity extends Activity { /** Called when the activity is first created. */ private static final String SOAP_ACTION = "http://www.xignite.com/services/GetRealTimeCrossRate"; private static final String METHOD_NAME = "GetRealTimeCrossRate"; private static final String NAMESPACE = "http://www.xignite.com/services/"; private static final String URL = "http://www.xignite.com/xCurrencies.asmx"; TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv=(TextView)findViewById(R.id.Textview01); //tao request SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME); //Is this code to access header properly ? Request.addProperty("Username", "onlyyou2011@yahoo.com"); Request.addProperty("Password","12345qwert"); Request.addProperty("Tracer","tuan123"); Request.addProperty("From","USD"); Request.addProperty("To","VND"); SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); // soapEnvelope.dotNet=true; soapEnvelope.setOutputSoapObject(Request); HttpTransportSE httpTransportSE = new HttpTransportSE(URL); AndroidHttpTransport aht = new AndroidHttpTransport(URL); try { aht.call(SOAP_ACTION, soapEnvelope); httpTransportSE.call(SOAP_ACTION,soapEnvelope); SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse(); tv.setText("Trang Thai"+resultString); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)