Android, KSoap2 and .NET Web Service w/ parameters = NULL result

后端 未结 5 1146
情书的邮戳
情书的邮戳 2021-01-12 23:00

Apparently this is a fairly often experienced issue. I\'m not sure entirely where the problem lies, or what needs to be adjusted, but for the life of me I cannot retrieve an

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 23:31

    In You DOT NET WEB SERVICE see the function below:

    [SoapRpcMethod]
    [WebMethod]
    public Complex GetComplex(string Name)
    {
        Complex myObj = new Complex();
        if (Name == "" || Name == null ) Name = "empty param";
        myObj.name = "Return FRom My " + Name;
        myObj.value = 888;
        return myObj;
    }
    

    WHEN YOU USE [SoapRpcMethod] because of return Complex type. IN YOUR JAVA Programe:

    SoapObject rpc4 = new SoapObject(serviceNamespace, "GetComplex");
    
    rpc4.addProperty("Name", "Johnson TONG");
    

    Below codes are also working too

    PropertyInfo pi = new PropertyInfo();
    pi.name= "Name";
    pi.type = PropertyInfo.STRING_CLASS;
    
    rpc4.addProperty(pi, "Johnson");
    
    int MyCount = rpc4.getPropertyCount();
    SoapSerializationEnvelope envelope4 = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope4.bodyOut = rpc4;
    envelope4.dotNet = false; // <--
    

    Don't ever use envelope4.dotNet = true this will always passing null value to the Server for reason that I don't know.

    envelope4.setOutputSoapObject(rpc4);
    envelope4.addMapping("http://tempuri.org/encodedTypes", "Complex", new Complex().getClass());
    HttpTransport ht4 = new HttpTransport(serviceUrl);
    ht4.setXmlVersionTag("");
    ht4.debug = true;
    

提交回复
热议问题