Invoking the SOAP Web service with Ajax: Building a Web Service client (3)

Source: Internet
Author: User
Tags soap resource string web services client websphere application server
Ajax|web|web Services | client

A simple example

I have provided an example project to illustrate the basic functionality of the Web Services JavaScript Library . the Web services that the demo uses, as shown in Listing 10, have been implemented in WebSphere application Server and provide a simple Hello world feature .

Listing 10. A simple Java-based "Hello World" Web service

package example;

public class HelloWorld {

public string SayHello (string name) {

Return "Hello" + name;



After implementing the service and deploying it to WebSphere application Server, the WSDL description of the service (listing 11) defines the SOAP message you need to pass (to invoke the Hello World Service).

Listing 11. Code Snippets for HELLOWORLD.WSDL

Message= "Impl:sayhellorequest"

Name= "Sayhellorequest"/>

Message= "Impl:sayhelloresponse"

Name= "Sayhelloresponse"/>

By using the Web services JavaScript Library, you can implement a method that invokes the Hello World Service, as shown in Listing 12 .

Listing 12. Use WS. Call calls the HelloWorld service



You can then invoke the Hello World Service anywhere in our WEB application by calling the SayHello function . please see listing.

Listing 13. Calling the SayHello function



The result of the successful call is shown in Figure 3 . running the example in Mozilla, Firefox, and Internet Explorer should get the same result .

Figure 3. The Hello world example in Firefox

Subsequent sections

Using the Web Services JavaScript Library, you can incorporate basic SOAP Web services into your Web application in a simple, browser-independent manner . in the next section of this series, you can explore not only how to use the library to invoke more advanced Web services based on the Web Services Resource Framework (Ws-resource framework) series specification, but also how to extend the Web service functionality and integrate it into a Web application The method in order .

Related Article

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn 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: and provide relevant evidence. A staff member will contact you within 5 working days.