2015-01-30 1 views
0
SoapObject request = new SoapObject(NAMESPACE, "api_vps_get_service"); 
// Property which holds input parameters 
PropertyInfo unamePI = new PropertyInfo(); 

// Set token 
unamePI.setName("token"); 
// Set Value 
unamePI.setValue(token); 
// Set dataType 
unamePI.setType(String.class); 
// Add the property to request object 
request.addProperty(unamePI); 

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

try { 

    // Invoke web service 
    androidHttpTransport.call(SOAP_ACTION+"api_vps_get_service", envelope); 
    // Get the response 

    SoapObject response=(SoapObject)envelope.bodyIn; 


    String reponses = response.toString(); 
    Log.i("reponse", String.valueOf(reponses)); 

} catch (Exception e) { 
    //Assign Error Status true in static variable 'errored' 
    Home.errored = true; 
    e.printStackTrace(); 
} 

난이 오류 java.lang.ClassCastException가 무엇입니까 캐스팅 할 수 없습니다 org.ksoap2.SoapFault은 조직 캐스팅 할 수 없습니다. ksoap2.serialization.SoapObject 내가 시도한 SoapPrimitive 응답 = (SoapPrimitive) envelope.getResponse(); 또한 Object 응답 = (Object) envelope.getResponse(); 하지만 아무도 성공하지 못하는 이유는 무엇입니까?java.lang.ClassCastException가이 : org.ksoap2.SoapFault은 org.ksoap2.serialization.SoapObject

답변

1

서버에서 오류가 발생했습니다. 따라서 SoapObject도 SoapPrimitive도 없습니다.

if (envelope.bodyIn instanceof SoapFault) 
{ 
    final SoapFault sf = (SoapFault) envelope.bodyIn; 
    ... // Stuff 
} 

이 여기에 설명되어 있습니다 : 당신은 그런 SoapFoult 먼저 확인해야 https://code.google.com/p/ksoap2-android/issues/detail?id=177

+0

SOAPFault에 - faultCode를 'SOAP-ENV : 서버'으로, faultString : '결과를 직렬화 할 수없는'faultactor을 : '' 세부 사항 : [email protected] ​​ 이제이게 무슨 뜻입니까? – hena12

+0

메소드 이름에 문제가 발생했습니다. – hena12

+0

어쨌든 객체 유형을 확인하지 않고 결과를 전송하는 것은 좋지 않습니다. 서버는 때때로 우리가 얻고 자하는 것이 아닌 뭔가를 보낸다. – mmprog

관련 문제