Click here to Skip to main content
15,171,729 members
Home / Discussions / Android
   

Android

 
AnswerRe: Method not returning expected value Pin
Eddy Vluggen23-Feb-17 4:35
professionalEddy Vluggen23-Feb-17 4:35 
GeneralRe: Method not returning expected value Pin
Davidw196924-Feb-17 17:41
MemberDavidw196924-Feb-17 17:41 
AnswerRe: Method not returning expected value Pin
Jochen Arndt23-Feb-17 4:45
professionalJochen Arndt23-Feb-17 4:45 
GeneralRe: Method not returning expected value Pin
Richard MacCutchan23-Feb-17 6:45
mveRichard MacCutchan23-Feb-17 6:45 
AnswerRe: Method not returning expected value Pin
Davidw196924-Feb-17 17:52
MemberDavidw196924-Feb-17 17:52 
AnswerRe: Method not returning expected value Pin
Richard MacCutchan23-Feb-17 4:58
mveRichard MacCutchan23-Feb-17 4:58 
GeneralRe: Method not returning expected value Pin
Davidw196924-Feb-17 17:53
MemberDavidw196924-Feb-17 17:53 
QuestionAndroid and C# Web Services Pin
Member 1155786814-Feb-17 23:41
MemberMember 1155786814-Feb-17 23:41 
Hi guys
The scenario that I find myself is this:
Development Tools: Android 2.2.3 study
Phone: Xiaomi MI4 LTE Android 6.0.1 API 23
Soap Lib: Ksoap2-android-2.5.2.jar

I want to create an app that connects to a web service in c #

The web services server is defined as follows:
webservices1.asmx


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Services.Protocols;

namespace WebServicesGPS
{
    /// <summary>
    /// Descrizione di riepilogo per WebService1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // Per consentire la chiamata di questo servizio Web dallo script utilizzando ASP.NET AJAX, rimuovere il commento dalla riga seguente. 
    // [System.Web.Script.Services.ScriptService]
    public class WebService1 : System.Web.Services.WebService
    {

        [WebMethod]
        public string GetCoordinates(string car,string lat,string lng)
        {
            string retcode = "OK";
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ToString());
            try
            {
                con.Open();

                string sql_select = "Insert into GPSTrackerCar " +
                            "(data,car,lat,lng)" +
                        "values (" +
                            "GetDate()" +
                            "," + car + 
                            "," + lat.ToString().Replace(",",".") +
                            "," + lng.ToString().Replace(",", ".") +
                        ")";

                SqlCommand cmd = new SqlCommand(sql_select, con);
                int i = cmd.ExecuteNonQuery();
                if (i != 1)
                    throw new Exception("Nessuna riga aggiornata");

            }
            catch(Exception ex)
            {
                retcode = ex.Message;
            }
            return retcode;
        }
    }
}


The Android client is very simple and has been defined as follows:
package com.callwebservices.callwebservices;

Java
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.ksoap2.serialization.PropertyInfo;

public class MainActivity extends AppCompatActivity {

    private   static String   SOAP_ACTION =   "http://tempuri.org/GetCoordinates";
    private   static String   WSDL_TARGET_NAMESPACE =   "http://tempuri.org";
    private   static String   OPERATION_NAME =  "GetCoordinates";
    private   static String  SOAP_ADDRESS =   "myWebServices_URL";

    EditText tvData1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final Context context = this.getApplicationContext();
        tvData1 = (EditText) findViewById(R.id.tvData1);
        Button BtnStart = (Button) (findViewById(R.id.BtnStart));
        BtnStart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,     OPERATION_NAME);
                PropertyInfo propertyInfo = new PropertyInfo();
                propertyInfo.type = PropertyInfo.STRING_CLASS;
                String car = "a";
                request.addAttribute("car",car);

                propertyInfo = new PropertyInfo();
                propertyInfo.type = PropertyInfo.STRING_CLASS;
                String lat = "1";
                request.addAttribute("lat",lat);

                propertyInfo = new PropertyInfo();
                propertyInfo.type = PropertyInfo.STRING_CLASS;
                String lng = "1";
                request.addAttribute("lat",lng);

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

                envelope.setOutputSoapObject(request);

                HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS,9000);
                httpTransport.debug = true;

                try  {
                    httpTransport.call(SOAP_ACTION, envelope);
                    Object response = envelope.getResponse();
                    tvData1.setText(response.toString());
                }  catch (Exception exception)   {
                    tvData1.setText(exception.toString()+"  Or enter number is not Available!");
                }
            }
        });
    }
}



The problem is that the event on_click of the button the result is an exception:
java.net.SocketTimeoutException


02-15 10:36:48.626 2774-4338/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.callwebservices.callwebservices/.MainActivity} from uid 2000 on display 0
02-15 10:36:48.684 2774-4810/? I/ActivityManager: Start proc 14510:com.callwebservices.callwebservices/u0a144 for activity com.callwebservices.callwebservices/.MainActivity
02-15 10:36:48.809 4491-4547/? D/WtProcessController: set foreground process size 1 pid:14510pacakgeName:com.callwebservices.callwebservices
02-15 10:36:48.848 14510-14510/? W/System: ClassLoader referenced unknown path: /data/app/com.callwebservices.callwebservices-1/lib/arm
02-15 10:36:48.851 14510-14510/? I/InstantRun: Instant Run Runtime started. Android package is com.callwebservices.callwebservices, real application class is null.
02-15 10:36:48.961 14510-14510/? W/System: ClassLoader referenced unknown path: /data/app/com.callwebservices.callwebservices-1/lib/arm
02-15 10:36:49.363 14510-14529/com.callwebservices.callwebservices D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-15 10:36:49.368 14510-14510/com.callwebservices.callwebservices D/ActivityThreadInjector: clearCachedDrawables.
02-15 10:36:49.407 14510-14529/com.callwebservices.callwebservices I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013_msm8974_refs/tags/AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013__release_AU (I48a9d37399)
                                                                                 OpenGL ES Shader Compiler Version: E031.29.00.00
                                                                                 Build Date: 11/17/16 Thu
                                                                                 Local Branch: 
                                                                                 Remote Branch: refs/tags/AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013
                                                                                 Local Patches: NONE
                                                                                 Reconstruct Branch: NOTHING
02-15 10:36:49.409 14510-14529/com.callwebservices.callwebservices I/OpenGLRenderer: Initialized EGL, version 1.4
02-15 10:36:49.547 2774-2810/? I/ActivityManager: Displayed com.callwebservices.callwebservices/.MainActivity: +874ms
02-15 10:36:49.548 2774-2810/? I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord{79e81e u0 com.callwebservices.callwebservices/.MainActivity t6491} time:181733619
02-15 10:37:00.067 4491-4547/? W/WtProcessController: do not trim { PackageName :com.callwebservices.callwebservices Pid: 14510 Uid: 10144 Start by: activity Score:90 Old score:90 state:0 mBackgroundTimeInMillis:1487151408690 WakelockCount:0 wakelogsize:0  ActivityDestroied:false Activity size: 1 PackageInfo:{WhetstonePackageInfo#PacakgeName:com.callwebservices.callwebservices uid:10144 uiMemoryThresold:0 nonUiMemoryThresold:0 Flag:1073747136,0x400014c0 [,TRIMHEAPS,SOFT_RESET,ZRAM,FLAG_DEAL_SCHEDULE] Type:0[] } tasknum:6491}
02-15 10:37:09.393 14510-14510/com.callwebservices.callwebservices W/System: ClassLoader referenced unknown path: /system/framework/tcmclient.jar
02-15 10:37:09.403 4455-4689/? I/XiaomiFirewall: firewall pkgName:com.callwebservices.callwebservices, result:0x0



filtering for the word: Socket in logcat:

-15 09:56:50.003 3877-3877/? D/wpa_supplicant: CTRL_IFACE monitor nt successfully to /data/misc/wifi/sockets/wpa_ctrl_2774-2\x00
02-15 09:56:50.152 4362-4362/? W/Binder:2774_8: type=1400 audit(0.0:65555): avc: denied { ioctl } for path="socket:[3659894]" dev="sockfs" ino=3659894 

ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-15 09:56:50.152 4362-4362/? W/Binder:2774_8: type=1400 audit(0.0:65556): avc: denied { ioctl } for path="socket:[3659894]" dev="sockfs" ino=3659894 

ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0



Any suggestions?
Many thanks in advance
SuggestionRe: Android and C# Web Services Pin
Richard Deeming15-Feb-17 3:39
mveRichard Deeming15-Feb-17 3:39 
QuestionAndroid: High Pass filter Pin
Himanshu Bhutani13-Feb-17 2:36
MemberHimanshu Bhutani13-Feb-17 2:36 
QuestionRe: Android: High Pass filter Pin
David Crow13-Feb-17 3:41
MemberDavid Crow13-Feb-17 3:41 
AnswerRe: Android: High Pass filter Pin
Nick_314159265415-Apr-17 4:55
MemberNick_314159265415-Apr-17 4:55 
QuestionAndroid Day of Week Calculator Pin
Pavlex49-Feb-17 10:50
MemberPavlex49-Feb-17 10:50 
AnswerRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:02
MemberDavid Crow9-Feb-17 11:02 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:09
MemberPavlex49-Feb-17 11:09 
GeneralRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:12
MemberDavid Crow9-Feb-17 11:12 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:15
MemberPavlex49-Feb-17 11:15 
SuggestionRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:23
MemberDavid Crow9-Feb-17 11:23 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:32
MemberPavlex49-Feb-17 11:32 
GeneralRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:36
MemberDavid Crow9-Feb-17 11:36 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:38
MemberPavlex49-Feb-17 11:38 
GeneralRe: Android Day of Week Calculator Pin
Richard MacCutchan9-Feb-17 22:07
mveRichard MacCutchan9-Feb-17 22:07 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 22:39
MemberPavlex49-Feb-17 22:39 
GeneralRe: Android Day of Week Calculator Pin
Richard MacCutchan9-Feb-17 23:20
mveRichard MacCutchan9-Feb-17 23:20 
GeneralRe: Android Day of Week Calculator Pin
David Crow10-Feb-17 3:08
MemberDavid Crow10-Feb-17 3:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.