Skip to content

Crate New Forex RESTful Service

Sachin Bhosale edited this page Aug 21, 2017 · 11 revisions
  1. Create RESTful Service project com.digital.banking.forex.rest from OCB Templates - Refer page

  2. Create new FxRate java bean to store Forex Rate. Refer sample FxRate bean here

  3. Create new ForexServiceImpl class or refactor existing ProductServiceImpl class to use FxRate bean.

  4. Add Sample Forex Rates - refer sample forex rates

  5. If you have created new class for service, then add new <jaxrs:server> bean for ForexServiceImpl. Or if existing ProductServiceImpl is updated then you can update <jaxrs:server> bean accordingly.

	<jaxrs:server id="foreRestService" address="/forexes">
		<jaxrs:providers>
			<ref bean="jaxbXmlProvider" />
			<ref bean="jsonProvider" />
		</jaxrs:providers>
		<jaxrs:serviceBeans>
			<ref bean="forexServiceImpl" />
		</jaxrs:serviceBeans>
	</jaxrs:server>
  • Note the <ref bean="forexServiceImpl> and address="/forexex" changes
  1. If you have added new package, you need to add the package in component-scan as show below
<context:component-scan base-package="<pkg1>,<pkg2>" />
  1. Now open launch.bndrun and resolve to get all runtime dependencies.

  2. Click on Run OSGi to run the service.

  3. Open browser and go to http://localhost:8888/services/forexes to see the service running