Android Studio calls the. NET webservice__.net

Source: Internet
Author: User
Tags thread class

1. First I do is also simple webserivce and can debug pass, so a new empty site:

The name can be taken casually.

2. It's a good idea to create a Web form so that you have an initial page when you publish it, so there's no initial page.

The inside text writes casually: initial index

3. Create a new WebService service: Easy to test to return a few words on the good:

The above is the creation of C # VS WebService, the following is the play: Android Studio starts

You need to download and import the Jar tool class package before you write the code.

Google provides a ksoap2-android project for developing Web service clients for the Android platform, but the project is not directly integrated into the Android platform and requires developers to download them themselves. For Android apps, add ksoap2-android run as follows:

1.1 Login to Http://simpligility.github.io/ksoap2-android/getting-started.html site, drop down one until the following interface. (another: Goodbye, Google Code, hello, GitHub)

At this point the latest is 3.6.1, and I'm downloading 3.3.0.

1.2 Switch to Project panel

  

Copy and paste the Ksoap2jar package directly into the App->libs directory

  

Right-click Add as Library ..., pop-up dialog box, OK on the line.

  

An error was returned while calling Webserivce: The server did not recognize the value of the HTTP header soapaction: http://tempuri.org/HelloWorld/... Omitted.

If the request and response sample for SOAP 1.2 is so SoapEnvelope also need to change: 12 If not try 11 or ten;
another error: Android.os.NetworkOnMainThreadException  : The reason that network requests are mainthread in the
OnCreate () method is that it is not possible to use the network access search reason at the same time,
since the Honeycomb SDK (3.0), Google no longer allows network requests (HTTP, Socket) and other related operations directly in the main thread class, in fact should not do so,
directly in the UI thread for network operations, blocking the UI, the user experience is quite bad.
now my code has solved this problem so that it can be invoked without thread, simple test can be, if the large items please query I will not say more.

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.