Getting started with WebSphere ESB: Create and release pojo (2)

Source: Internet
Author: User

Figure 5. Associate an interface with the generated service component



 

Now the interface is associated with the component. We can use the "generate implementation" option to generate the implementation framework.

Figure 6. New Service component generation and implementation



 

Figure 7. Add the implementation to the generated framework



 

We need to add the implementation of the convert method to the above class, as shown below:

Listing 1. Convert method implementation



Public double convert (double Celsius ){

Double dcelsius = Celsius. doublevalue ();

Double Fahr;

Fahr = (0.9/0.5) * dcelsius) + 32 );

Return New Double (Fahr );

}

Associate service components with independent references

Next, we will create an independent reference and associate it with the service component so that the JSP client can access the component through the independent reference.

Figure 8. Create an independent reference



 

You can use the "add reference" button to associate temperatureconverterinterface. WSDL with an independent reference. By default, the independent reference is named temperatureconverterinterfacepartner.

Figure 9. Connecting independent references to service components



 

Create a client and access the service through independent references

Next, we need to develop the client JSP to test the service components. This JSP will allow users to enter the degree Celsius value. Then JSP will pass the value to the service to convert it to Fahrenheit, and finally display the result.

Figure 10. New JSP file template



 

The following servicemanager class is used to call components through JSP.

List 2. jsp implementation



String cel = request. getparameter ("Celcius ");

If (cel! = NULL & cel. Length ()> 0 ){

Try {

Servicemanager = new servicemanager ();

Service = (service) servicemanager. locateservice

("Temperatureconverterinterfacepartner ");

Double celdouble = double. valueof (CEL );

Dataobject respobject = (dataobject) service. Invoke ("convert", celdouble );

If (respobject! = NULL ){

Out. println (respobject. getdouble ("Fahrenheit "));

}

} Catch (exception e ){

// Handele it

}

}

Package and deploy applications in WebSphere ESB

Components and clients are now ready and can be packaged and deployed in WebSphere ESB for testing. Export the application as integration module ear, as shown below.

Figure 11. Export a project as an integration module



 

Figure 12. Export the integration module



 

Deploy the ear file in WebSphere ESB through the Admin console and access its "url" in the browser ".

Figure 13. Final output



 

Conclusion

Through this article, you have learned how to use the bottom-up method (from interface to implementation) to create a service component and how to publish it in IBM WebSphere ESB. In addition, I learned how to access this service component from the client through independent references.

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.