You can create a JAX-RPC Web service client with
HCL Commerce with the following high-level tasks: create a new
EJB project and session bean, generate the Web service client proxy
code into the project, customize the bean to make the Web service
requests, and create a helper class to simplify calling the new session
bean.
Procedure
- Start
HCL Commerce Developer.
- Create the EJB project and client proxy:
- Right click .
- Click Next and accept the default
value.
- Under Client-Side Environment Selection,
change the Client type to EJB, enter the name
of your EJB project and ensure WC is selected
as the EAR project.
- Click Finish.
- Modify the default session bean to call the Web service:
- Modify the DefaultSession interface to extend the generated
Web service interface. That is, the PortType interface.
- Create a new class that implements the generated Web
service interface.
For example:
public SOAPElement startTransaction(InitialRequest initialRequest) throws RemoteException, ValidationErrorFault {
UsPortType service = new UsPortTypeProxy();
return service.startTransaction(initialRequest);
}
- Modify the bean class to extend from the newly created
class.
- Create a helper class to simplify calling the session bean:
- Create a new class in ExtensionsLogic.
- Add a helper method that simplifies calling the session
bean.
For example:
private DefaultSession getClient() {
try {
Context ctx = new InitialContext();
DefaultSessionHome = (DefaultSessionHome) ctx.lookup("ejb/ejbs/DefaultSessionHome");
DefaultSession service = home.create();
return service;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
HCL Commerce commands can create the above helper
class and call getClient().serviceName(). Security settings can be
specified on the deployment descriptor of the EJB project that contains
the new session bean.