Soru & Cevap

asmx web service den gelen veriyi androidde gösterme ...

25.06.2014 - 12:51

Merhaba arkadaşlar.Visual studio üzerinde asmx uzantılı web service yazdım.Deneme amaçlı tek kayıt getiriyor bu servis.Ben web servisden gelen bu kaydı androidde TextView de göstermek istiyorum.Fakat sürekli uygulama durduruldu hatası alıyorum.Hata kodlarını araştırdım boş kayıt geliyor.Kodları paylaşıyorum neden boş kayıt gelebilir yardımcı olabilir misiniz?

[code][/code]

public class MainActivity extends ActionBarActivity {

    private static final String SOAP_ACTION="http://tempuri.org/Merhaba";
    private static final String METHOD_NAME="Merhaba";
    private static final String NAMESPACE="http://tempuri.org";
    private static final String URL="http://localhost:1070//WebService.asmx/";
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
   final TextView  textView1=(TextView) findViewById(R.id.textView1);
        try {
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

            //request.addProperty("prop1", "myprop");

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

            androidHttpTransport.call(SOAP_ACTION, envelope);

            Object result = (Object)envelope.getResponse();

            String[] results = (String[])  result;
            textView1.setText( ""+results[0]);
        }
        catch (Exception e) {
            textView1.setText(e.getMessage());
        }
        
        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment())
                    .commit();
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            return rootView;
        }
    }

}

22 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-12265-1397142254.jpg
gkaradagan
25.06.2014 - 06:22

Kodu tam incelemedim ama asynctask kullanıp yapınız buyuk ıhtımal ondandır hata