Monday, August 10, 2015

Axis2 web service client sample for getting values using web service stub,[you need to pass authentication only if secured the WS]

/* Say this CxLastBill class constructor creates object with Status and Cusomner's lastBillMin */
private Long lastBillMin = null;//getter & setter in code
private String status = null;//getter & setter in code

 public CxLastBill(HashMap hm, String cxRef) {//hm map has authentication and EP,cxRef is the request parameter 
 //Http Authentication 
HttpTransportProperties.Authenticator basicAuthentication = new HttpTransportProperties.Authenticator(); basicAuthentication.setPassword(hm.get("RBMPD")); basicAuthentication.setUsername(hm.get("RBMUS")); 

//Call End point Runtime and set some properties for request
    ECAAccountStub proxy;
    try {
        proxy = new ECAAccountStub(hm.get("RBMEP"));//Endpoint
        proxy._getServiceClient()
                .getOptions()
                .setProperty(
                        org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
                        Boolean.FALSE);
        proxy._getServiceClient()
                .getOptions()
                .setProperty(
                        org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
                        basicAuthentication);

       
        /*
       
        Code implementation
        ie, Set inputs and get Outputs for client requirement
       
        cxRef is used for query the data
       
        Ex:  QueryAccountInput
             queryAccountOutput  
       
        */

        setLastBillMin(queryAccountOutputObject.getLastBillMny());//get last Bill money from response value
        setStatus("OK");
    } catch (Exception e) {
        // TODO: handle exception
        setStatus("ERROR: " + e.getMessage());
    }

        Ref :
        http://wiki.servicenow.com/index.php?title=Java_Apache_Axis2_Web_Services_Client_Examples#gsc.tab=0

Monday, October 6, 2014

Create web service project(Implementation as server)



1. First need to create dynamic web project  [You can finish the project after  get bellow screen] also Add the Axis2 facet. Right-click your project and click Properties > Project Facets > Modify project > Axis2 Web Services

 


2. Then, We need to create wsdl file for sample scenario[say sample wsdl file name MyFirst.wsdl file]

 



3. Right click on MyFirst.wsdl to create stub, Need to add web server runtime (Jboss/tomcat..etc) and web service runtime(Axis2) .
 

Select Finish.
Generated Skelton class is used for to future modification [to add custom logic for custom methods in wsdl] for released API (It can be survived as Server).
It Will be deployed in attached server[In this case server is  Tomcat]..


 
This site providing you to JAVA Language easy way. I think if you are beginner to JAVA refer this to implements you knowledge using only with very simplest codes.