Knowledge base: Apia
|
Language: English
|
History
|
![]() |
|
![]() |
|
|
|
|
|
[ AHT00096 ] How to execute queries and business classes from a web service
Summary
It is desirable to be able to communicate from an external system with APIA as to establish an interaction, whether it is with the purpose of executing a business class or queries that are configured in APIA.
It is applied to
Procedure
The solution consists of creating a Java class in the external system, in which the necessary elements to establish the communication with APIA´s Web Service (WS) will be found. This class will contain the calling methods and the corresponding APIA´s API methods. To be able to make the call to a business class (execute Class) and/or a query (execute Query), it is necessary that there is a definite java bussines class and/or a query, respectively, in APIA, which will be called upon when the calling to APIA´s WS is executed. A java class will be executed from the external system to establish the communication with an APIA, and this class must implement "com.dogma.ws.gen.ApiaWSInterfaceService",for which it is necessary to implement the following methods:
public class ApiaWsTester extends org.apache.axis.client.Service implements com.dogma.ws.gen.ApiaWSInterfaceService {
private static final long serialVersionUID = 1L; //--- Constructors -------------------------- //--- Implemented methods ------------------- public ApiaWSInterface getApiaWS(URL portAddress) throws ServiceException { / /--- Overriden methods --------------------- throw new ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null": serviceEndpointInterface.getName())); public Remote getPort(QName portName,Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { public QName getServiceName() { public Iterator getPorts() { //--- Private methods ----------------------- The called upon method to establish the calling from the external system to the APIA´s business class:
//--- Public methods ------------------------ /** * Parameters: * envName - Enviroment Name * className - Name of class of business * user - User authenticated in WS * pwd - Password of user in WS */ public boolean executeClass(String envName, String className, String user, String pwd) throws RemoteException , ServiceException { ApiaWSSoapBindingStub binding = this.connect(); binding.setTimeout(60000);
boolean result = false; //--- Create parameters Parameter paramAddress = new Parameter(); //--- Set parameters //--- Create user authenticated in WS //--- Execute call to WS return result;
Java Business class executed when the APIA´s WS is called upon from the external system:
//--- I collect the data sent by parameter in ws String userName = this.getParameter("USER_NAME").getValueAsString(); String userAddress = this.getParameter("USER_ADDRESS").getValueAsString();
//--- Position with the received data the values of the corresponding attributes The called upon method to establish the call from the external system to APIA´s query (notice that this method uses the code´s first section described to establish the communication between the external system and APIA), in case the designed query in APIA has fields (filters) the numbers for them should be placed in parameters, taking into consideration that the name assigned to the parameter must correspond to the name of the field in the Query designed by APIA: //--- Public methods ------------------------ //--- Create parameters Parameter paramAddress = new Parameter(); //--- Set parameters //--- Create user authenticated in WS //--- Create user authenticated in WS //--- Execute call to WS //--- Successful execution
Results of the execution of this class:
--- QUERY RESULT --- - User1 -- AddressUser1 - - User2 -- AddressUser2 - Related elements
Related from
Suggested items
|
|