Android development tutorial-Build a Java WebService

Source: Internet
Author: User

Hi everyone!

Today, I will share with you how to build a Web Service for Android development. It will inevitably involve client development. How can we implement a server and a client, and transmit data to each other. Even when someone else's service is called, you can know how it is implemented.

WebService is generally divided into. NET and Java versions. Today we mainly implement the Java version of WebService, And the. NET version is relatively simple.

As an example, smile easily:

Boeing 777 is the first aircraft ever designed and manufactured completely in computer virtual reality. The equipment used is completely provided by IBM. Before the test flight, the president of Boeing warmly invited IBM's technical supervisor to participate in the test flight, but the supervisor said, "Ah, I am very honored. Unfortunately, it was my wife's birthday, so..."
As soon as Boeing heard it, he got angry: "I haven't told you the test flight date yet !"

What is WebServices?

It is a construction application.ProgramThe universal model can be implemented in any operating system that supports network communication. It is a new Web Application Branch and is a self-contained, self-described, and modular application, it can be released, located, and called through the Web. Web Service is an application component that logically provides data and services for other applications. each application accesses the Web Service through the network protocol and some standard data formats (HTTP, XML, and SOAP). The results are obtained through the internal execution of the web service. web services can execute any function from simple requests to complex business processing. After deployment, other Web service applications can discover and call the services deployed by the application.

Key Technologies and rules

The following key technologies and rules are used to build and use web services:

1. xml: Standard Method for describing data.

2. Soap: Indicates the Information Exchange Protocol.

3. WSDL: Web Service Description Language.

4. UDDI: General description, discovery, and integration. It is a platform-independent, XML-based protocol used to describe commerce on the Internet.

XML

The Extensible Markup Language (XML) is the basic format for data representation on the Web service platform. In addition to ease of creation and analysis,XML is not only platform-independent, but also vendor-independent.. Independence is more important than technical superiority: software vendors will not choose a technology invented by competitors.

Soap

Soap isStandard Web service communication protocol, Soap is the abbreviation of Simple Object Access protocoll, Simple Object Access Protocol.It is a standardized XML Message format for message transmission..

WSDL

The full name of WSDL is Web Service Description Language,Is a Web Service Description Language Based on XML format.. The main purpose is that the Web service provider transfers all relevant content of its Web Service, such as the transmission mode, service method interface, interface parameters, and service path of the provided service, generate a complete document and publish it to the user. You can use this WSDL document to create a SOAP request message and send it to the WebService provider over HTTP. After the Web service completes the service request, it returns the soap Response Message to the requester, the service requestor then parses the soap returned message into something that he can understand based on the WSDL document.

UDDI

Register and publish the Web service with UDDI,UDDI is a standard for creating registry services so that you can register and publish your web services for users to search for. However, when a service provider wants to publish its web services to the worldIn order to find its service externally, the service provider can register its web service to the corresponding UDDI commercial registration website. Currently, four UDDI commercial registration websites, such as IBM, are available globally. Because the url uri of the web service has been given in the WSDL file, the external interface can call the corresponding web service directly through the URI provided by the WSDL. Therefore, UDDI is not a necessary web service component, and the service provider can not register it.

Create and release your own WS

1. Install myeclipse

2. Configure Tomcat

Open myeclipse

Menu Bar-> file-> New-> Web Service Project

Here, we use the JAX-WS method.

JAX-WS

Jax-WS is only available in Java 1.6. The new WebService mode is used to configure WebService Based on annotations. It is similar to the WebService in ASP, which is much more difficult than xfire.

Rest (JAX-RS)

Use less

Xfire (expired)

Tedious Configuration

Create packages and class libraries in the service to implement your own business.

We created a user management system, which naturally needs to be used to manage users.

Publish WS

 

After WS is published, configure tomcat.

In the displayed form, expand myeclipse> servers> tomcat.

 

 

Right-click the project and choose add library file.

At this point, all steps start deployment after configuration is complete.

Start Tomcat

Find the deployment icon in the toolbar.

Deployment complete. Open ie for testing.

Create a client for testing

In this case, the library file required by WS is generated in the project.

Create a call test class

At this point, our ws configuration + test is complete. In fact, it is not difficult. Even if there are many steps, it is complicated and easy to forget, you can use it as a memorandum for future reference!

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.