01/10/2018, 09:55
Lấy chi tiết đối tượng trong WCF use Ksoap2
em muốn lấy phone của một đối tượng trong WCF thì làm sao vậy a ?
đây code java của em a
protected String doInBackground(String... params)
{
//Initialize soap request + add parameters
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//Use this to add parameters
request.addProperty("USERNAME","thangvtq");
request.addProperty("USERID","");
//Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
//Needed to make the internet call
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SoapResult from the envelope body.
SoapObject result = (SoapObject)envelope.getResponse();
//SoapPrimitive rs = (SoapPrimitive) result.getProperty("USERNAME");
//String kq = rs.toString();
//Toast.makeText(this,result.toString(),Toast.LENGTH_LONG).show();
//Log.INFO("Ket qua tra ve: " + result.toString());
return result.toString();
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
@Override
protected void onPostExecute(String result)
{
TextView t= (TextView) findViewById(R.id.text);
t.setText(result);
// Toast.makeText(MainActivity.this,result,Toast.LENGTH_LONG).show();
}
}
Bài liên quan