문제

I m trying to send a complex object to me web service and return a string value but my logcat from android returns Null Refference

the full code ksoap2 send the object

    Questionnairekeyval qk = new Questionnairekeyval(5, 8, "Questionnaire1", "", "", "", "", "", "", "", "");


    PropertyInfo pi = new PropertyInfo();
    pi.setName("Questionnairekeyval");
    pi.setValue(qk);
    pi.setType(qk.getClass());
    request.addProperty(pi);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);

    envelope.dotNet = true;

    envelope.implicitTypes = true;
    // 2. Set the request parameters
    envelope.setOutputSoapObject(request);

    envelope.addMapping(WS_NAMESPACE, "Questionnairekeyval",
            new Questionnairekeyval().getClass());

    // 3. Create a HTTP Transport object to send the web service request
    HttpTransportSE httpTransport = new HttpTransportSE(WSDL_URL);
    // httpTransport.debug = true; // allows capture of raw request/respose
    // in
    // Logcat

    // 4. Make the web service invocation
    httpTransport.call(SOAP_ACTION, envelope);

    String result;

    if (envelope.bodyIn instanceof SoapFault) { // SoapFault =
                                                // FAILURE
        SoapFault soapFault = (SoapFault) envelope.bodyIn;
        throw new Exception(soapFault.getMessage());
    } else {
        // SoapObject = SUCCESS
        SoapPrimitive soapObject = (SoapPrimitive) envelope.getResponse();
        result = (soapObject).toString();

        Log.wtf("result SOAPObject", result + " " + soapObject);

    }

C# get the object and return a string

     [WebMethod]
    public String putAnswers(Questionnairekeyval reponse)
    {

        int a = reponse.idClient;
             return Convert.ToString(a);
   }
도움이 되었습니까?

해결책

Solved the name of the proprety in the java request it was Questionnairekeyval but in the webservice was reponse so its basicly that the problem why it returns null

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top