Android uses WebService to generate java. Lang. classcastexception: org. ksoap2.serialization. soapprimitive error Solution

Source: Internet
Author: User
When developing Android WebService, users generally use the WebService server when they accept the returned values.

Soapobject = (soapobject) envelope. getresponse (); this is used to accept the returned value, but this method usually produces Java. lang. classcastexception: Org. ksoap2.serialization. soapprimitive.

 

Based on my actual operations and help from others, I finally solved this problem.

Use soapobject = (soapobject) envelope. getresponse (); and soapobject result = (soapobject) envelope. bodyin; both methods will report the value.

Java. Lang. classcastexception: org. ksoap2.serialization. soapprimitive. We can use object =

 

(Object) envelope. getresponse (); To solve this error.

However, I still have some questions about this. When I use WebService to query the weather, soapobject = (soapobject) envelope. getresponse () is correct and no error will occur. However, Java appears when I check whether QQ is online. lang. classcastexception: Org. ksoap2.serialization. for errors such as soapprimitive, WebService is also used. Why is there a difference? If you have the same question, leave a message to me.

Related Article

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.