
        /**
        * VersionPortStub.java
        *
        * This file was auto-generated from WSDL
        * by the Apache Axis2 version: 0.95 Mar 23, 2006 (06:50:53 LKT)
        */
        package sample;

        

        /*
        *  VersionPortStub java implementation
        */

        public class VersionPortStub extends org.apache.axis2.client.Stub
        {
        //default axis home being null forces the system to pick up the mars from the axis2 library
        public static final java.lang.String AXIS2_HOME = null;
        protected static org.apache.axis2.description.AxisOperation[] _operations;
	
	private void populateAxisService(){

        //creating the Service
        _service = new org.apache.axis2.description.AxisService("VersionPort");
	

        //creating the operations
        org.apache.axis2.description.AxisOperation __operation;
	


        _operations = new org.apache.axis2.description.AxisOperation[1];
        
                   __operation = new org.apache.axis2.description.OutInAxisOperation();
                

            __operation.setName(new javax.xml.namespace.QName("http://org.apache.axis2/", "getVersion"));

	    

            _operations[0]=__operation;
            _service.addOperation(__operation);
        
        }



     public VersionPortStub(org.apache.axis2.context.ConfigurationContext configurationContext,
        java.lang.String targetEndpoint)
        throws java.lang.Exception {
       //To populate AxisService
       populateAxisService();
	
	
        _serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);
        _serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(
                targetEndpoint));
        
    }

    /**
     * Default Constructor
     */
    public VersionPortStub() throws java.lang.Exception {
        
                    this("http://localhost:8080/axis2/services/version" );
                
    }

    /**
     * Constructor taking the traget endpoint
     */
    public VersionPortStub(java.lang.String targetEndpoint) throws java.lang.Exception {
        this(org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_HOME,null),
                targetEndpoint);
    }



        
                    /**
                    * Auto generated method signature
                    * @see sample.VersionPort#getVersion
                        * @param param2
                    
                    */
                    public sample.VersionPortStub.GetVersionResponse getVersion(
                    sample.VersionPortStub.GetVersionRequest param2) throws java.rmi.RemoteException{

               org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName());
              _operationClient.getOptions().setAction("getVersion");
              _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);

              

              // create SOAP envelope with that payload
              org.apache.ws.commons.soap.SOAPEnvelope env = null;
                    
                                    //Style is Doc.
                                    
                                    
                                                 env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), param2, optimizeContent(new javax.xml.namespace.QName("http://org.apache.axis2/", "getVersion")));
                                            

        // create message context with that soap envelope
        org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext() ;
        _messageContext.setEnvelope(env);

        // add the message contxt to the operation client
        _operationClient.addMessageContext(_messageContext);

        //execute the operation client
        _operationClient.execute(true);

         
               org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(
                                           org.apache.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                org.apache.ws.commons.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
                
                
                           java.lang.Object object = fromOM(getElement(_returnEnv,"doc"),sample.VersionPortStub.GetVersionResponse.class);
                           return (sample.VersionPortStub.GetVersionResponse)object;
                    

                    }
            
                /**
                * Auto generated method signature for Asynchronous Invocations
                * @see sample.VersionPort#startgetVersion
                    * @param param2
                
                */
                public  void startgetVersion(
                sample.VersionPortStub.GetVersionRequest param2,final sample.VersionPortCallbackHandler callback) throws java.rmi.RemoteException{

                org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName());
          _operationClient.getOptions().setAction("getVersion");
          _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);

          

              // create SOAP envelope with that payload
              org.apache.ws.commons.soap.SOAPEnvelope env;
                    
                                    //Style is Doc.
                                    
                                                 env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), param2, optimizeContent(new javax.xml.namespace.QName("http://org.apache.axis2/", "getVersion")));
                                            

        // create message context with that soap envelope
        org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext() ;
        _messageContext.setEnvelope(env);

        // add the message contxt to the operation client
        _operationClient.addMessageContext(_messageContext);


                    
                           _operationClient.setCallback(new org.apache.axis2.client.async.Callback() {
                    public void onComplete(
                            org.apache.axis2.client.async.AsyncResult result) {
                        java.lang.Object object = fromOM(getElement(
                                result.getResponseEnvelope(), "doc"),
                               sample.VersionPortStub.GetVersionResponse.class);
                        callback.receiveResultgetVersion((sample.VersionPortStub.GetVersionResponse) object);
                    }

                    public void onError(java.lang.Exception e) {
                        callback.receiveErrorgetVersion(e);
                    }
                });
                        

          org.apache.axis2.util.CallbackReceiver _callbackReceiver = null;
        if ( _operations[0].getMessageReceiver()==null &&  _operationClient.getOptions().isUseSeparateListener()) {
           _callbackReceiver = new org.apache.axis2.util.CallbackReceiver();
          _operations[0].setMessageReceiver(
                    _callbackReceiver);
        }

           //execute the operation client
           _operationClient.execute(true);

                    }
                
	
    private javax.xml.namespace.QName[] opNameArray = null;
	private boolean optimizeContent(javax.xml.namespace.QName opName) {
        

        if (opNameArray == null) {
			return false;
		}
		for (int i = 0; i < opNameArray.length; i++) {
			if (opName.equals(opNameArray[i])) {
				return true;   
			}
		}
		return false;
	}
    //http://localhost:8080/axis2/services/version
        public static class GetVersionResponse
        implements org.apache.axis2.databinding.ADBBean{
        
                public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName(
                "http://org.apache.axis2/xsd",
                "getVersionResponse",
                "ns1");

            


            /**
            * field for _return
            */

            protected java.lang.String local_return ;
           
           

           /**
           * Auto generated getter method
           * @return java.lang.String
           */
           public  java.lang.String get_return(){
               return local_return;
           }

           
            
                    /**
                   * Auto generated setter method
                   * @param param _return
                   */
                   public void set_return(java.lang.String param){
                    
                   this.local_return=param;
                   }
                

        /**
        * databinding method to get an XML representation of this object
        *
        */
        public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName){


        
                 java.util.ArrayList elementList = new java.util.ArrayList();
                 java.util.ArrayList attribList = new java.util.ArrayList();

                
                             elementList.add(new javax.xml.namespace.QName("",
                                                                      "return"));
                            
                                elementList.add(
                                   org.apache.axis2.databinding.utils.ConverterUtil.convertToString(local_return));
                                

                return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName, elementList.toArray(), attribList.toArray());
            
            

        }

        /**
        * utility method to http://www.w3.org/2001/XMLSchema-instance
        */

    /**
      *  Factory class that keeps the parse method
      */
    public static class Factory{
        /**
        * static method to create the object
        */
        public static GetVersionResponse parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
        GetVersionResponse object = new GetVersionResponse();
        try {
        int event = reader.getEventType();

       //event better be a START_ELEMENT. if not we should go up to the start element here
        while (event!= javax.xml.stream.XMLStreamReader.START_ELEMENT) {
            event = reader.next();
        }

        
        if (!MY_QNAME.equals(reader.getName())){
                    throw new Exception("Wrong QName");
        }
        
                org.apache.axis2.databinding.utils.SimpleElementReaderStateMachine stateMachine1
                  = new org.apache.axis2.databinding.utils.SimpleElementReaderStateMachine();
                javax.xml.namespace.QName startQname1 = new javax.xml.namespace.QName(
                                     "",
                                    "return");
                stateMachine1.setElementNameToTest(startQname1);
                stateMachine1.read(reader);
                object.set_return(
                  
                     org.apache.axis2.databinding.utils.ConverterUtil.convertTostring(
                           stateMachine1.getText()));
                      
        } catch (javax.xml.stream.XMLStreamException e) {
             throw new java.lang.Exception(e);
        }

        return object;
        }
        }//end of factory class

        }
    
        public static class GetVersionRequest
        implements org.apache.axis2.databinding.ADBBean{
        
                public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName(
                "http://org.apache.axis2/xsd",
                "getVersionRequest",
                "ns1");

            

        /**
        * databinding method to get an XML representation of this object
        *
        */
        public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName){


        
                 java.util.ArrayList elementList = new java.util.ArrayList();
                 java.util.ArrayList attribList = new java.util.ArrayList();

                

                return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName, elementList.toArray(), attribList.toArray());
            
            

        }

        /**
        * utility method to http://www.w3.org/2001/XMLSchema-instance
        */

    /**
      *  Factory class that keeps the parse method
      */
    public static class Factory{
        /**
        * static method to create the object
        */
        public static GetVersionRequest parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
        GetVersionRequest object = new GetVersionRequest();
        try {
        int event = reader.getEventType();

       //event better be a START_ELEMENT. if not we should go up to the start element here
        while (event!= javax.xml.stream.XMLStreamReader.START_ELEMENT) {
            event = reader.next();
        }

        
        if (!MY_QNAME.equals(reader.getName())){
                    throw new Exception("Wrong QName");
        }
        
        } catch (javax.xml.stream.XMLStreamException e) {
             throw new java.lang.Exception(e);
        }

        return object;
        }
        }//end of factory class

        }
    
                    private  org.apache.ws.commons.om.OMElement  toOM(sample.VersionPortStub.GetVersionResponse param){
                        if (param instanceof org.apache.axis2.databinding.ADBBean){
                            org.apache.ws.commons.om.impl.builder.StAXOMBuilder builder = new org.apache.ws.commons.om.impl.builder.StAXOMBuilder
                            (org.apache.ws.commons.om.OMAbstractFactory.getOMFactory(), param.getPullParser(sample.VersionPortStub.GetVersionResponse.MY_QNAME));
                            org.apache.ws.commons.om.OMElement documentElement = builder.getDocumentElement();
                            ((org.apache.ws.commons.om.impl.OMNodeEx) documentElement).setParent(null); // remove the parent link
                            return documentElement;
                        }else{
                           
                           //todo finish this onece the bean serializer has the necessary methods
                            return null;
                        }
                    }

                    private  org.apache.ws.commons.soap.SOAPEnvelope toEnvelope(org.apache.ws.commons.soap.SOAPFactory factory, sample.VersionPortStub.GetVersionResponse param, boolean optimizeContent){
                        if (param instanceof org.apache.axis2.databinding.ADBBean){
                            org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new
                                    org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(sample.VersionPortStub.GetVersionResponse.MY_QNAME),
                                                                                     factory);
                            return builder.getEnvelope();
                        }else{
                           
                           //todo finish this onece the bean serializer has the necessary methods
                            return null;
                        }
                    }
                
                    private  org.apache.ws.commons.om.OMElement  toOM(sample.VersionPortStub.GetVersionRequest param){
                        if (param instanceof org.apache.axis2.databinding.ADBBean){
                            org.apache.ws.commons.om.impl.builder.StAXOMBuilder builder = new org.apache.ws.commons.om.impl.builder.StAXOMBuilder
                            (org.apache.ws.commons.om.OMAbstractFactory.getOMFactory(), param.getPullParser(sample.VersionPortStub.GetVersionRequest.MY_QNAME));
                            org.apache.ws.commons.om.OMElement documentElement = builder.getDocumentElement();
                            ((org.apache.ws.commons.om.impl.OMNodeEx) documentElement).setParent(null); // remove the parent link
                            return documentElement;
                        }else{
                           
                           //todo finish this onece the bean serializer has the necessary methods
                            return null;
                        }
                    }

                    private  org.apache.ws.commons.soap.SOAPEnvelope toEnvelope(org.apache.ws.commons.soap.SOAPFactory factory, sample.VersionPortStub.GetVersionRequest param, boolean optimizeContent){
                        if (param instanceof org.apache.axis2.databinding.ADBBean){
                            org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new
                                    org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(sample.VersionPortStub.GetVersionRequest.MY_QNAME),
                                                                                     factory);
                            return builder.getEnvelope();
                        }else{
                           
                           //todo finish this onece the bean serializer has the necessary methods
                            return null;
                        }
                    }
                

           /**
           *  get the default envelope
           */
           private org.apache.ws.commons.soap.SOAPEnvelope toEnvelope(org.apache.ws.commons.soap.SOAPFactory factory){
                return factory.getDefaultEnvelope();
           }


            private  java.lang.Object fromOM(org.apache.ws.commons.om.OMElement param,
            java.lang.Class type){

                try {
                       
                      if (sample.VersionPortStub.GetVersionResponse.class.equals(type)){
                           return sample.VersionPortStub.GetVersionResponse.Factory.parse(param.getXMLStreamReaderWithoutCaching());
                      }
                              
                      if (sample.VersionPortStub.GetVersionRequest.class.equals(type)){
                           return sample.VersionPortStub.GetVersionRequest.Factory.parse(param.getXMLStreamReaderWithoutCaching());
                      }
                              
                } catch (Exception e) {
                     throw new RuntimeException(e);
                }

                return null;
            }

        
   }



    