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 wsdl
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





				

/> Result:





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

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.