Android:faultactor:调用webservice时出现'null'详细错误

时间:2013-05-27 08:58:10

标签: android web-services null asmx android-ksoap2

我正在开发一个应用程序,它从android获取位置详细信息并将其发送到vb.net webservice以将其插入数据库。 当我访问localhost webservice进行测试时,我成功地将位置详细信息插入到数据库中。 但是,当我打电话给实际的网络服务器,即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

我的Android代码调用了webservice ...

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();
        }
    }

0 个答案:

没有答案