Integrate Jbilling with your own application
Posted By Ankit Gupta | 02-Jul-2014
Today I am writing about how to integrate jbilling with your own application.
Jbilling can be integrated by using web service interface provided by Jbilling.
Spring http invoker is a method of exposing and using web services which is supported by Jbilling.
Jbilling provides an interface for web service IWebServicesSessionBean and implementation is given in WebServicesSessionSpringBean.
So to integrate the jbilling, following steps are required :
1. Copy IWebServicesSessionBean interface along with package structure in your own project.
This will allow you to access web service interface in your own project.
2. In Jbilling project,you will find resources.xml in which write following code :
<bean name="httpinvoker.ApiService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="webServicesSession"></property>
<property name="serviceInterface" value="com.sapienter.jbilling.server.util.IWebServicesSessionBean"></property>
This configuration will expose web service through httpinvoker.ApiService and can be used by another projects.
3. In your own project,copy following in resources.xml or create new file with this name under grails-app/config/spring if not already present
<bean id="iWebServicesSessionBean" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean" lazy-init="true",
<property name="serviceUrl" value="http://localhost:9090/jbilling/httpinvoker/ApiService"/>
<property name="serviceInterface" value="com.sapienter.jbilling.server.util.IWebServicesSessionBean"/>
here replace localhost:9090/jbilling with your server where jbilling is running.
4. Now you can use the interface to call the Jbilling web service APIs.
In this way,when you call some interface API then it will call the Jbilling web service by calling httpinvoker/ApiService and will return data accordingly.
In some APIs,you may need to pass data transfer objects,in that case you have to copy those classes also from Jbilling along with package structure in your project.
If you want to avoid copy of all classes then you have one option of extending IWebServicesSessionBean interface in jbilling and then write APIs which takes only primitive data as input, then prepare data transfer object form this data and call actual API.