IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

webservice et googlemap position


Sujet :

Android

  1. #1
    Membre averti
    Inscrit en
    Février 2011
    Messages
    27
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 27
    Par défaut webservice et googlemap position
    bonsoir ,
    j'espere que vous serez capable de m'aider car je coince depuis plusieure heure su mon problem
    voila je voudrais recuprer les coordonné latitude longitude sur ma google map lorsque j'appuie sur l'ecran pour ensuite les stocker dans ma base de donné via webservice mais jgalere et jcomprend pas pourquoi

    Code du WebService
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
     
    package com.userlogin.ws;
     
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
     
    import org.omg.CORBA.SystemException;
     
    public class Login {
     
     
    //insertion position
     public String insertData(String Latitude,String Longitude){
     
    	  try{
     
    	   Class.forName("com.mysql.jdbc.Driver");
    	   Connection con = DriverManager.getConnection("jdbc:mysql://localhost/essai","root","");
    	   PreparedStatement statement =  con.prepareStatement("INSERT INTO essai(Latitude,Longitude) VALUES ('"+Latitude+"','"+Longitude+"');");
    	   int result = statement.executeUpdate();
     
    	  }
     
    	  catch(Exception exc){
        System.out.println(exc.getMessage());
        }
     
      return " merci";
      }
     
     }
    code java

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
     
    package com.example.geolocalisation;
     
     
    import org.ksoap2.SoapEnvelope;
    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 android.location.Location;
    import android.location.LocationListener;
    import android.location.LocationManager;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.AdapterView;
    import android.widget.AdapterView.OnItemSelectedListener;
    import android.widget.ArrayAdapter;
    import android.widget.Button;
    import android.widget.Spinner;
    import android.widget.TextView;
    import android.widget.Toast;
     
    import com.google.android.gms.maps.CameraUpdateFactory;
    import com.google.android.gms.maps.GoogleMap;
    import com.google.android.gms.maps.GoogleMap.OnMapClickListener;
    import com.google.android.gms.maps.SupportMapFragment;
    import com.google.android.gms.maps.model.LatLng;
    import com.google.android.gms.maps.model.Marker;
    import com.google.android.gms.maps.model.MarkerOptions;
    import com.google.android.maps.GeoPoint;
     
    public class MainActivity extends FragmentActivity implements LocationListener {
    	private final String NAMESPACE = "http://ws.userlogin.com";
        private final String URL = "http://192.168.1.4:8085/Login/services/Login?wsdl";
        private final String SOAP_ACTION = "http://ws.userlogin.com/insertData";
        private final String METHOD_NAME = "insertData";
    	private TextView l,l1;
    	private GoogleMap myMap;
    	private GeoPoint p;
    	private Spinner geo_type;
    	private LocationManager Lm;
    	private LocationListener ll;
    	private int x=0;
    	private double lat,longi;
    	private Button valider;
    	public String latitude,longitude,str;
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
    		 SupportMapFragment myMapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map); //stokage de la map
             myMap = myMapFragment.getMap(); //chargement de la map
             myMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); //chargement du type de la map
             myMap.setMyLocationEnabled(true); // afficher la position de l'utilisateur
             myMap.getUiSettings().setCompassEnabled(true);
             Lm=(LocationManager)getSystemService(LOCATION_SERVICE);
             l=(TextView)findViewById(R.id.textView1);
             l1=(TextView)findViewById(R.id.textView2);
             valider=(Button)findViewById(R.id.button1);
             myMap.setOnMapClickListener(new OnMapClickListener() {
     
     			@Override
     			public void onMapClick(LatLng point) {
     
     			Toast.makeText(getApplicationContext(), point.toString(), Toast.LENGTH_SHORT).show();
     			if(x==0){
     			Marker mark=myMap.addMarker(new MarkerOptions().position(point).title("Votre magasin est ici"));
     			lat=mark.getPosition().latitude;
     			longi=mark.getPosition().longitude;
     			l.setText(Double.toString(lat));
     			l1.setText(Double.toString(longi)); 
     
     			x=1;
     			}
     			else {
     				myMap.clear();
     				Marker mark=myMap.addMarker(new MarkerOptions().position(point).title("Votre magasin est ici"));
     				lat=mark.getPosition().latitude;
     				longi=mark.getPosition().longitude;
     				l.setText(Double.toString(lat));
     				l1.setText(Double.toString(longi)); 
     			}
     			myMap.animateCamera(CameraUpdateFactory.newLatLng(point));
     
     			}
     		}); 
             geo_type=(Spinner)findViewById(R.id.type_affichage);
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.type_affichage,android.R.layout.simple_spinner_item);
    		 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    		 geo_type.setAdapter(adapter);
    		 geo_type.setOnItemSelectedListener(new OnItemSelectedListener() {
     
    			@Override
    			public void onItemSelected(AdapterView<?> arg0, View arg1,
    					int arg2, long arg3) {
    			String ty=geo_type.getSelectedItem().toString();
     
    			if (ty.equals("Terrain")){
    			myMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
    			}
     
    			if (ty.equals("Hybrid")){
    			myMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
    			}
     
    			if (ty.equals("Normal")){
    				myMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);	
    			}
     
    			}
     
    			@Override
    			public void onNothingSelected(AdapterView<?> arg0) {
    				// TODO Auto-generated method stub
     
    			}
    		});
     
    		 valider.setOnClickListener(new OnClickListener() {
     
    			@Override
    			public void onClick(View v) {
    			insere();
     
    			}
    		});
     
     
     
     
          }
    	private void insere(){
    		new Thread(new Runnable() {
     
    			@Override
    			public void run() {
    				SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    				latitude=l.getText().toString();
    				longitude=l1.getText().toString();
     
    				PropertyInfo unameProp =new PropertyInfo();
    		        unameProp.setName("Latitude");//Define the variable name in the web service method
    		        unameProp.setValue(latitude);//set value for userName variable
    		        unameProp.setType(String.class);//Define the type of the variable
    		        request.addProperty(unameProp);//Pass properties to the variable
     
    		        PropertyInfo unameProp1 =new PropertyInfo();
    		        unameProp1.setName("Longitudee");//Define the variable name in the web service method
    		        unameProp1.setValue(longitude);//set value for userName variable
    		        unameProp1.setType(String.class);//Define the type of the variable
    		        request.addProperty(unameProp1);//Pass properties to the variable
     
    		        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    		        envelope.setOutputSoapObject(request);
    		        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
     
    		        try{
    		            androidHttpTransport.call(SOAP_ACTION, envelope);
    		               SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
    		            str=response.toString(); 
     
     
    		        }
    		        catch(Exception e){
     
    		        }
    		        runOnUiThread(new Runnable() {
     
    					@Override
    					public void run() {
    						// TODO Auto-generated method stub
     
    					}
    				});
    			}
    		}).start();
    	}
     
    	@Override
    	public void onLocationChanged(Location location) {
     
    		   LatLng latlng= new LatLng(location.getLatitude(), location.getLongitude());
    		   myMap.animateCamera(CameraUpdateFactory.newLatLng(latlng));
     
    	}
    	@Override
    	public void onProviderDisabled(String provider) {
    		// TODO Auto-generated method stub
     
    	}
     
    	@Override
    	public void onProviderEnabled(String provider) {
    		// TODO Auto-generated method stub
     
    	}
     
    	@Override
    	public void onStatusChanged(String provider, int status, Bundle extras) {
    		// TODO Auto-generated method stub
     
    	}
     
     
     
    }
    L'erreur est la suivante :

    [ERROR] 2
    java.lang.ArrayIndexOutOfBoundsException: 2
    at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:630)
    at org.apache.axis2.rpc.receivers.RPCUtil.processRequest(RPCUtil.java:153)
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:206)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    Svp aidez moi pcq jgalere severe l)

  2. #2
    Expert confirmé

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Par défaut
    Ton problème provient de ta variable request.

    Tu es sur de ton coup avec Longitudee ? avec deux ee ?

  3. #3
    Membre averti
    Inscrit en
    Février 2011
    Messages
    27
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 27
    Par défaut
    le prob venez du longitudee y'avais un E de trop xD

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 16/06/2014, 21h40
  2. GoogleMap et webservice
    Par zax-tfh dans le forum Services Web
    Réponses: 0
    Dernier message: 26/02/2010, 20h09
  3. Réponses: 1
    Dernier message: 10/06/2008, 23h30
  4. Réponses: 2
    Dernier message: 17/05/2002, 20h37
  5. FOnction api specifiant la position de la souris
    Par florent dans le forum C++Builder
    Réponses: 4
    Dernier message: 15/05/2002, 20h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo