0

httpTransport.call这行代码有excetion,但是ex为null

private static String CallServiceMethod(String methodName,String Json) throws Exception
 {      
Object response = null;
        try
        {       
        SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,methodName);

        PropertyInfo propertyInfo = new PropertyInfo();
        propertyInfo.setName("Json");
        propertyInfo.setValue(Json);
        propertyInfo.setType(String.class);
        request.addProperty(propertyInfo);

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

        envelope.setOutputSoapObject(request);
        HttpTransportSE httpTransport = new HttpTransportSE(SystemConfiguration.ServiceUrl);        
        httpTransport.call(WSDL_TARGET_NAMESPACE + methodName, envelope); //Error
        response = envelope.getResponse();
        }
        catch (Exception ex)
        {
            //TODO:Log
            String x = ex.getMessage(); //why ex is null???
        }
        return response.toString();

    }  
4

2 回答 2

0

有时收到的异常可能为空......所以在通过日志值打印时

Log.d(TAG, "add some string here" + ex.toString());

避免空指针异常

于 2013-08-21T04:19:10.553 回答
0

尝试使用类似的东西 -

catch(Exception ex)
{
    Toast.makeText(this, "Exception ex1  = " + ex.toString(), Toast.LENGTH_LONG).show();
     Log.d(TAG, "Exception ex1  = " + ex.toString());
     return  "Exception ex1  = " + ex.toString();
}
  `
于 2013-08-21T04:15:39.090 回答