javax.net.ssl.SSLHandshakeException:javax.net.ssl.SSLProtocolException:SSL握手已中止:ssl = 0x52e57148:

时间:2016-03-07 10:50:53

标签: android web-services

从服务器获取响应时,我收到如下错误:

  

javax.net.ssl.SSLHandshakeException:javax.net.ssl.SSLProtocolException:SSL握手中止:ssl = 0x52e57148:SSL库失败,通常是协议错误

我的代码是:

private static String NAMESPACE = "https://tempuri.org/";
private static String URL = "https://192.168.1.6:4800/WebServices/UserLogin.asmx";
private static String SOAP_ACTION = "https://tempuri.org/";

public static String invokeWS(String jsonObjSend, String webMethName) {
    String resTxt = null;

    // Create request
    SoapObject request = new SoapObject(NAMESPACE, webMethName);
    // Property which holds input parameters
    PropertyInfo jsonObj = new PropertyInfo();
    // Set Name
    jsonObj.setName("jsdata");
    // Set Value
    jsonObj.setValue(jsonObjSend.toString());
    // Set dataType
    // jsonObj.setType(JSONObject.class);
    jsonObj.setType(String.class);
    // Add the property to request object
    request.addProperty(jsonObj);

    // Create envelope
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    new MarshalBase64().register(envelope);
    envelope.dotNet = true;
    // Set output SOAP object
    envelope.setOutputSoapObject(request);
    // Create HTTP call object
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        // Invole web service
        androidHttpTransport.call(SOAP_ACTION+webMethName, envelope);
        // Get the response

        SoapPrimitive  response = (SoapPrimitive ) envelope.getResponse();
        // Assign it to fahren static variable
        resTxt = response.toString();

        System.out.println("Response is: " + resTxt);

    } catch (Exception e) {
        e.printStackTrace();
        resTxt = "Null";
    }

    return resTxt;
}

1 个答案:

答案 0 :(得分:-6)

只需将https发送到http即可获得重新启动