Exposing REST + JSON endpoint using WEF

I wanted to figure out how to create a REST + JSON end point using WEF. So i decided to create a simple Java class that has sayHello(name) method, this method takes name as input and when you invoke it it returns Hello name as output These are the steps that i followed
  • I did create a HelloWorldService.java class like this
    
    package com.webspherenotes.wef;
    
    public class HelloWorldService {
    
      public String sayHello(String name){
        System.out.println("Inside HelloWorldService.sayHello() Name = " + name);
        return "Hello " + name;
      }
    }
    
    
  • Next i did create one empty model and i did name it HelloWorldServiceProvider.model
  • THen in the HelloWorldServiceProvider.model i did add one Linked Java Object that points to HelloWorldService class like this
  • Define HelloWorldService using Service Definition builder like this
  • Now define sayHello() operation in the HelloWorldService using Service Operation builder like this
  • With this we have a Service Provider model, Now we need to consumer it and expose it as REST Service, For that create another empty model called HelloWorldRESTService.model
  • Add Service Consumer builder in the HelloWorldServiceConsumer.model like this
  • Add a REST Service Enable builder in this model and expose it as JSON like this
  • Now your application is ready so publish it on server
Next right click on the HelloWorldRESTService.model and run it as active model, you should get a web page like this
The HelloWorldService has only one operation sayHello so you get only one method listed here, select that method, you should get a page that lets you invoke the service
On this page enter a name and click on invoke service button and you should get JSON result like this

1 comment:

Unknown said...

Nice post and great content.
Avast Customer Support is here to help you out with the whole procedure to Download Avast Antivirus online, We not only fix your Avast Support related issues but will guide with how to get started with your new Avast product once it gets installed successfully. We at Avast Tech Support provides service to protect your PC from potential online threats and external attacks like viruses, Trojans, malwares, spywares and phishing scams. And Avast Refund. Call on our Avast Phone Number

Gmail Customer service is a third party technical support service for Gmail users when they face any technical issue or error in their Gmail account. Our Gmail Customer Support team solves issues like forgot Gmail account password, Gmail configuration or Sync issues, recover deleted emails and many more. Toll Free number (800) 986-9271

How you install or reinstall Office 365 or Office 2016 depends on whether your Office product is part of an Office for home or Office for business plan. If you're not sure what you have, see what office com setup products are included in each plan and then follow the steps for your product. The steps below also apply if you're installing a single, stand-alone Office application such as Access 2016 or Visio 2016. Need Help with office setup Enter Product Key? Call 1-800-000-0000 Toll Free
Norton Tech Support is a third party service provider and not in any way associated with Norton or any of its partner companies. We offer support for Norton products and sell subscription based additional warranty on computer and other peripheral devices. Call our Toll Free number 1 855 966 3855
Other Services
Norton Toll Free , Office-Setup , office.com/setup.