0

Android から位置情報を取得し、それを vb.net Web サービスに送信してデータベースに挿入するアプリケーションを開発しています。テスト目的で localhost Web サービスにアクセスしているときに、場所の詳細をデータベースに正常に挿入しています。しかし、実際の Web サーバー、つまりhttp://www.enoxonline.in/webservice.asmx?op=SetLocationForAndroidを呼び出すと、次の例外が発生します。

05-27 12:21:37.477: I/System.out(276): SetLocationForAndroid{Latitude=37.422005; Longitude=-122.084095; sAddress=Charleston Road, Mountain View, San Jose; sLocality=California; sCountry=United States; sUserId=1004; }
05-27 12:21:39.998: E/Error :(276): Exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: Object reference not set to an instance of an object.
05-27 12:21:39.998: E/Error :(276):    at WebService.SetLocationForAndroid(String Latitude, String Longitude, String sAddress, String sLocality, String sCountry, String sUserId)
05-27 12:21:39.998: E/Error :(276):    --- End of inner exception stack trace ---
05-27 12:21:39.998: W/System.err(276): SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: Object reference not set to an instance of an object.
05-27 12:21:40.008: W/System.err(276):    at WebService.SetLocationForAndroid(String Latitude, String Longitude, String sAddress, String sLocality, String sCountry, String sUserId)
05-27 12:21:40.008: W/System.err(276):    --- End of inner exception stack trace ---' faultactor: 'null' detail: org.kxml2.kdom.Node@43e626e0

私は非常に多くの投稿を調べましたが、問題について明確な考えがありませんでした/誰かが間違っていることを教えてもらえますか?

私のWebサービスコード:

<WebMethod()> _
    Public Function SetLocationForAndroid(ByVal Latitude As String, ByVal Longitude As String, ByVal sAddress As String, ByVal sLocality As String, ByVal sCountry As String, ByVal sUserId As String) As String

        Dim sdr As New DataSet()
        Dim dt As New DataTable()
        Dim dl As New DL.clsDataLayer
        Dim strquery As String

        Dim sLatitude As Double = CDbl(Latitude)
        Dim sLongitude As Double = CDbl(Longitude)

        'Dim longitude = xDoc.SelectSingleNode("/GeocodeResponse/result/geometry/location/lng").InnerText
        Try
            With dl
                '.SqlQuery = "INSERT INTO MAP (LATITUDE,LONGITUDE,SERVER_DATE,ADDRESS,LOCALITY,COUNTRY,USER_ID,WEB_ENTRY) VALUES (" + dLatitude.ToString() + "," + dLongitude.ToString() + ",getdate(),'" + sAddress.Replace("'", "''") + "','" + sLocality.Replace("'", "''") + "','" + sCountry.Replace("'", "''") + "','" + sUserId + "',0 )"
                .SqlQuery = "INSERT INTO MAP (LATITUDE,LONGITUDE,SERVER_DATE,ADDRESS,LOCALITY,COUNTRY,USER_ID,WEB_ENTRY) VALUES (" + sLatitude.ToString + "," + sLongitude.ToString + ",getdate(),'" + sAddress.Replace("'", "''") + "','" + sLocality.Replace("'", "''") + "','" + sCountry.Replace("'", "''") + "','" + sUserId + "',0 )"
                strquery = "INSERT INTO MAP (LATITUDE,LONGITUDE,SERVER_DATE,ADDRESS,LOCALITY,COUNTRY,USER_ID,WEB_ENTRY) VALUES (" + sLatitude.ToString + "," + sLongitude.ToString + ",getdate(),'" + sAddress.Replace("'", "''") + "','" + sLocality.Replace("'", "''") + "','" + sCountry.Replace("'", "''") + "','" + sUserId + "',0 )"
                sdr = .fnGetData
            End With
            Return strquery

            'Dim conn As New SqlConnection
            'conn.ConnectionString = "Data Source = 62.75.229.51; Initial Catalog = Silver_WebPH; User id =Silver_Webph; password =sbyadmin1"
            'Dim strSql As String = "INSERT INTO MAP (LATITUDE,LONGITUDE,SERVER_DATE,ADDRESS,LOCALITY,COUNTRY,USER_ID,WEB_ENTRY) VALUES (" + sLatitude.ToString + "," + sLongitude.ToString + ",getdate(),'" + sAddress.Replace("'", "''") + "','" + sLocality.Replace("'", "''") + "','" + sCountry.Replace("'", "''") + "','" + sUserId + "',0 )"
            'conn.Open()
            'Dim cmd As New SqlCommand
            'cmd.Connection = conn
            'cmd.CommandText = strSql
            'cmd.CommandType = CommandType.Text
            'cmd.ExecuteNonQuery()
            'Return True
        Catch ioEx As IO.IOException
            ' Handle other non-specific IO Exceptions here.
            Throw New Exception(ioEx.Message.ToString)
        Return strquery     
            'Return ioEx.Message.ToString

        Catch ex As Exception
            ' Handle any other non-IO Exception here.
            Throw New Exception(ex.Message.ToString)
        Return strquery     
            'Return ex.Message.ToString
        End Try

    End Function

Webサービスを呼び出す私のAndroidコード...

private String sendLocation(String latitude, String longitude, String sAddress, String sLocality, String sCountry, String sUserId)
    {
/*      final String NAMESPACE = "http://tempuri.org/";
        final String URL = "http://10.0.2.2:25722/NewLocationMap/Service.asmx";
        final String SOAP_ACTION = "http://tempuri.org/SetLocationForAndroid";
        final String METHOD_NAME = "SetLocationForAndroid";
*/  
        final String NAMESPACE = "http://www.enoxonline.in/";
        final String URL = "http://www.enoxonline.in/webservice.asmx";
        final String SOAP_ACTION = "http://tempuri.org/SetLocationForAndroid";
        final String METHOD_NAME = "SetLocationForAndroid";     

        try
        {
            SoapObject request = new SoapObject (NAMESPACE, METHOD_NAME);
            PropertyInfo pi = new PropertyInfo();
            pi.setType(String.class);
            pi.setName("Latitude");
            pi.setValue(latitude);
            request.addProperty(pi);
//          request.addProperty("Latitude",latitude);
            pi = new PropertyInfo();
            pi.setType(String.class);
            pi.setName("Longitude");
            pi.setValue(longitude);
            request.addProperty(pi);
//          request.addProperty("Longitude", longitude);
            pi = new PropertyInfo();
            pi.setType(String.class);
            pi.setName("sAddress");
            pi.setValue(sAddress);
            request.addProperty(pi);
//          request.addProperty("Longitude", longitude);
            pi = new PropertyInfo();
            pi.setType(String.class);
            pi.setName("sLocality");
            pi.setValue(sLocality);
            request.addProperty(pi);
//          request.addProperty("Longitude", longitude);
            pi = new PropertyInfo();
            pi.setType(String.class);
            pi.setName("sCountry");
            pi.setValue(sCountry);
            request.addProperty(pi);
//          request.addProperty("Longitude", longitude);
            pi = new PropertyInfo();
            pi.setType(String.class);
            pi.setName("sUserId");
            pi.setValue(sUserId);
            request.addProperty(pi);
//          request.addProperty("sUserId", UserId);


            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.xsd = NAMESPACE;
            envelope.enc = "http://schemas.datacontract.org/2004/07/Entity";
            envelope.setAddAdornments(false);
            envelope.implicitTypes = true;
            envelope.setOutputSoapObject(request);
            System.out.println(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            androidHttpTransport.call(SOAP_ACTION, envelope);
            return envelope.getResponse().toString();
        }
        catch(Exception ex)
        {
            Log.e("Error : " , "Exception: " + ex.getMessage());
            ex.printStackTrace();
            return ex.getMessage();
        }
    }
4

0 に答える 0