package com.example.donusum;
import java.io.IOException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import android.support.v7.app.ActionBarActivity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
private final String NAMESPACE="http://tempuri.org/";
private final String SOAP_ACTION="http://tempuri.org/TabloAdi3";
private final String METHOD_NAME="TabloAdi3";
private final String URL="http://secmesikolay.com/Service1.asmx";
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnVesselSearch = (Button)findViewById(R.id.btnInvoke);
btnVesselSearch.setOnClickListener(getVessel);
}
private OnClickListener getVessel = new OnClickListener()
{
@Override
public void onClick(View v)
{
final TextView tv = (TextView)findViewById(R.id.tv1);
new bnm().execute();
}
};
private class bnm extends AsyncTask<String, Void, SoapObject> {
private final String NAMESPACE="http://tempuri.org/";
private final String SOAP_ACTION="http://tempuri.org/TabloAdi3";
private final String METHOD_NAME="TabloAdi3";
private final String URL="http://secmesikolay.com/Service1.asmx";
protected void onPreExecute() {
}
protected SoapObject doInBackground(String... queryParams) {
// POST ETTİĞİM VERİLER BANA GERİYE SOAPOBJECT DÖNÜYOR
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("ProductID","2" );
PropertyInfo ProductName = new PropertyInfo();
ProductName.setName("_ProductName");
ProductName.setType(String.class);
request.addProperty(ProductName);
PropertyInfo CategoryName = new PropertyInfo();
CategoryName.setName("_CategoryName");
CategoryName.setType(String.class);
request.addProperty(CategoryName);
PropertyInfo UnitPrice = new PropertyInfo();
CategoryName.setName("_UnitPrice");
UnitPrice.setType(String.class);
request.addProperty(UnitPrice);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject) envelope.bodyIn;
return response;
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
protected void onPostExecute(SoapObject response) {
// DÖNEN DEĞER SOAPOBJECT RESPONSE
try {
if (response != null) {
SoapPrimitive ProductName = (SoapPrimitive) response
.getProperty("ProductName");
final TextView tv = (TextView)findViewById(R.id.tv1);
tv.setText("ProductName"+ProductName+"");
}
} catch (Exception e) {
// TODO: handle exception
}
}
}
}