java.io.IOException:HTTP请求失败,HTTP状态:500(ksoap2)

Luc*_*irl 5 java android ksoap android-ksoap2

我正在使用KSOAP2,将请求发送到服务器时出现java.io.IOException:HTTP请求失败,HTTP状态:该行中为500 httpTransport.call(SOAP_ACTION, envelope),但是服务器正常工作,我已经使用SoapUI对其进行了检查。可能是什么问题?

public class SOAPClient
{
    private static final int TIMEOUT_SOCKET = 180000;

    public static SoapObject get(Context context, String methodName, ArrayList<Pair<String, ?>> args) throws Exception
    {
        final String URL = PrefHelper.getSOAPUrl(context);
        final String NAMESPACE = PrefHelper.getSOAPNamespace(context);
        final String SOAP_ACTION = methodName; //NAMESPACE + "#" + "mapx" + ":" + methodName;

        SoapObjectEve request = new SoapObjectEve(NAMESPACE, methodName);

        if (args != null) {
            for (Pair<String, ?> arg : args) {
                if (arg.first != null) {
                    request.addProperty(arg.first, arg.second);
                }
            }
        }

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        new MarshalBase64().register(envelope);
        envelope.setOutputSoapObject(request);

        envelope.implicitTypes = true;

        HttpTransportSE httpTransport = new HttpTransportSE(URL, TIMEOUT_SOCKET);
        httpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
        try 
        {
            httpTransport.call(SOAP_ACTION, envelope);
            AppLog.e(httpTransport.requestDump+"requestDump");


        }
        catch (ConnectTimeoutException e) {
            AppLog.e(e.getMessage());
            throw new Exception(context.getString(R.string.node_unavailable));
        }
        catch (SocketTimeoutException e) {
            AppLog.e(e.getMessage());
            throw new Exception(context.getString(R.string.timeout));
        }
        catch (Exception e) {
            e.printStackTrace();
            AppLog.e(e.getMessage());

            AppLog.e(httpTransport.requestDump+"requestDump");
            throw new Exception(context.getString(R.string.warning_error_get_data) + e.getMessage() == null ? "" : " " + e.getMessage());
        }

        AppLog.i(httpTransport.requestDump+"requestDump");

        SoapObject soapObj = null;

        try {
            soapObj = (SoapObject) envelope.getResponse();
        }
        catch (Exception e) {

            String response = ((SoapPrimitive) envelope.getResponse()).toString();
            boolean res = Boolean.valueOf(response);

            soapObj = new SoapObject();
            soapObj.addProperty("response", res);
            soapObj.addProperty("msg", "");
            soapObj.addProperty("data", null);

        }
        AppLog.e(httpTransport.responseDump+"responseDump");
        return soapObj;
    }
}
Run Code Online (Sandbox Code Playgroud)