Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8429165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:15:33+00:00 2026-06-10T05:15:33+00:00

I am new to Android applications. The code that I am using is working

  • 0

I am new to Android applications. The code that I am using is working on another computer which has Linux. But on my computer there is Windows 7 and the code is not working. It can not connect to webservice. Please help me.

Here is code:

package com.example.marport;

import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
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.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

public class Giriscikis extends Activity {

    final static String NAMESPACE = "http://webservice.marport.dcat.com/";
    final static String METHOD_NAME = "gateOut";
    final static String METHOD_NAME2 = "gateIn";
    final static String SOAP_ACTION = "http://webservice.marport.dcat.com/gateOut";
    final static String SOAP_ACTION2 = "http://webservice.marport.dcat.com/gateIn";
    final static String URL = "http://192.168.1.164:8070/test/services/MarportWebServicePort";

    private EditText cikis;
    private EditText giris;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.giriscikis);

        cikis = (EditText) findViewById(R.id.etCikis);
        giris = (EditText) findViewById(R.id.etGiris);

        SoapObject Request=new SoapObject(NAMESPACE,METHOD_NAME);
        SoapObject Request2 = new SoapObject(NAMESPACE, METHOD_NAME2);

        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        SoapSerializationEnvelope soapEnvelope2 = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        soapEnvelope.dotNet = false;
        soapEnvelope2.dotNet = false;

        soapEnvelope.setOutputSoapObject(Request);
        soapEnvelope2.setOutputSoapObject(Request2);

        HttpTransportSE aht = new HttpTransportSE(URL);

        try {
            aht.call(SOAP_ACTION, soapEnvelope);
            aht.call(SOAP_ACTION2, soapEnvelope2);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        try {
            SoapPrimitive result=(SoapPrimitive) soapEnvelope.getResponse();
            SoapPrimitive result2 = (SoapPrimitive) soapEnvelope2.getResponse();
            giris.setText(result2.toString());
            cikis.setText(result.toString());
        } catch (SoapFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

Here are the exceptions:

08-24 08:25:40.928: E/AndroidRuntime(631): FATAL EXCEPTION: main
08-24 08:25:40.928: E/AndroidRuntime(631): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.marport/com.example.marport.Giriscikis}: android.os.NetworkOnMainThreadException
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.os.Looper.loop(Looper.java:137)
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.app.ActivityThread.main(ActivityThread.java:4745)
08-24 08:25:40.928: E/AndroidRuntime(631):  at java.lang.reflect.Method.invokeNative(Native Method)
08-24 08:25:40.928: E/AndroidRuntime(631):  at java.lang.reflect.Method.invoke(Method.java:511)
08-24 08:25:40.928: E/AndroidRuntime(631):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-24 08:25:40.928: E/AndroidRuntime(631):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-24 08:25:40.928: E/AndroidRuntime(631):  at dalvik.system.NativeStart.main(Native Method)
08-24 08:25:40.928: E/AndroidRuntime(631): Caused by: android.os.NetworkOnMainThreadException
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.io.IoBridge.connectErrno(IoBridge.java:144)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.io.IoBridge.connect(IoBridge.java:112)
08-24 08:25:40.928: E/AndroidRuntime(631):  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
08-24 08:25:40.928: E/AndroidRuntime(631):  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
08-24 08:25:40.928: E/AndroidRuntime(631):  at java.net.Socket.connect(Socket.java:842)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
08-24 08:25:40.928: E/AndroidRuntime(631):  at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
08-24 08:25:40.928: E/AndroidRuntime(631):  at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:76)
08-24 08:25:40.928: E/AndroidRuntime(631):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:146)
08-24 08:25:40.928: E/AndroidRuntime(631):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
08-24 08:25:40.928: E/AndroidRuntime(631):  at com.example.marport.Giriscikis.onCreate(Giriscikis.java:53)
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.app.Activity.performCreate(Activity.java:5008)
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-24 08:25:40.928: E/AndroidRuntime(631):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-24 08:25:40.928: E/AndroidRuntime(631):  ... 11 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:15:34+00:00Added an answer on June 10, 2026 at 5:15 am

    The application force stop because..

    Caused by: android.os.NetworkOnMainThreadException
    

    The exception that is thrown when an application attempts to perform a networking operation on its main thread. Find much info on this NetworkOnMainThreadException

    Solution:

    Use AsyncTask and put your network related operation in doInVBackground() of it..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Android development and working on an Android application that requires the
I am working on an Android app that has multiple screens the user will
I am working on an Android Honeycomb (v3.0) application that has a requirement of
I am nearing completion of a project I am working on using Android, but
I am currently working on an Android application which has an ask a question
I am working on an Android Honeycomb (v3.0) application that has a requirement of
I'm new at Eclipse and the Android applications making so here comes a very
i am creating a new android application.i am using the table layout. I have
Hello i am new in android and i am developing one application in which
I am working on an Android application in which I want to integrate foursquare

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.