Integrate Jbilling with your own application
Posted By : Ankit Gupta | 02-Jul-2014
Hello friends,
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>
</bean>
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"/>
</bean>
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.
Thanks
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Ankit Gupta
Ankit is a lead java developer well experienced in development of web and enterprise level applications. He has good exposure to enterprise frameworks like Drools , Opta-planner , jBilling and graph databases like Neo4J etc.