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 .