Call the KSOAP2 Library in Android to access the service side of the WebService service returns anytype{}

Source: Internet
Author: User

Recently in the graduation design, involving the Android access to the Web Service server database, and return a value, when I put the Web service test passed, want to write a simple Android test program, to implement server-side database access, through the web A Serch () method in the service, and then finds that each return value is a anytype{},logcat:

The online collection of a lot of information, the reason is actually very simple answer, is because the server return value is shown in Null,logcat anytype{}, found the reason, the solution is also said, including these methods:

{The workaround refers to a meter from the blog Park user's Day line, here to express thanks}

1. Simply add the Soaprpcserviceattribute attribute to the class attribute of the WebService.
[SoapRpcService (Routingstyle=soapserviceroutingstyle.soapaction)]

2. The parameter name must be the same as the argument name in the WebService method, because WS automatically changes the parameter name to ARG0, Arg1, and all call parameters need to be modified.

3. No "/" after NAMESPACE

It is hereby stated that:

Method One I do not know where to add, to see bloggers in the solution of the problem, said the method of a plus, directly reported abnormal, I did not control.

Method Two is my key to solve the problem, look at my logcat, the incoming parameter is username = 10010, so after passing the variable is username (now I think so), and WebService will automatically change the name of the parameter to arg0, arg1 ... So the parameters are different, resulting in the return of the result becomes null, showing return anytype{}.

        // You need to pass in a parameter        when calling a method // To be consistent with the Web service, it needs to be set to arg0 because the Web service automatically converts it to arg0 arg1        Rpc.addproperty ("arg0", username);

And another reason is that

            // set whether to call the dotnet developed WebService, the server is. NET needs to be set to True,java no            false

My server is written in Java, so this property should be set to false.

At this point, my problem has been solved!!!

Call the KSOAP2 Library in Android to access the service side of the WebService service returns anytype{}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.