All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.axis2.jibx.template.JibXDatabindingTemplate.xsl Maven / Gradle / Ivy

There is a newer version: 1.8.2
Show newest version




  

    
  
    unknown
    
    

    
    
    
      
      
      
      
        private static javax.xml.namespace.QName[] qNameArray = {
        
          1">,new javax.xml.namespace.QName("","")
        
        };
      

        /**
        *  get the default envelope
        */
        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory) {
            return factory.getDefaultEnvelope();
        }
      
    
    
    
      
        
          
        
        
          
          
            true
          
          
          
            false
          
        
      
    
    
    
      
        
        
      
      
        
        
      
    
    
  
  
  
  
  

        private org.apache.axiom.om.OMElement toOM( param, org.apache.axiom.soap.SOAPFactory factory, boolean optimizeContent) {
            
        }
        
  
  
  

        private org.apache.axiom.om.OMElement toOM( param, boolean optimizeContent) {
            org.apache.axiom.om.OMFactory factory = org.apache.axiom.om.OMAbstractFactory.getOMFactory();
            
        }
  
  
  
            if (param instanceof org.jibx.runtime.IMarshallable){
                if (bindingFactory == null) {
                    throw new RuntimeException(bindingErrorMessage);
                }
                return (mappedChild(param, factory));
            } else if (param == null) {
                throw new RuntimeException("Cannot bind null value of type ");
            } else {
                throw new RuntimeException("No JiBX <mapping> defined for class ");
            }
  
  
  
        
        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory,  param, boolean optimizeContent, javax.xml.namespace.QName elementQName) {
            org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
            if (param != null){
                envelope.getBody().addChild(toOM(param, factory, optimizeContent));
            }
            return envelope;
        }

  
  
  
  
  
  
  
    
      public org.apache.axiom.soap.SOAPEnvelope (org.apache.axiom.om.OMElement element,  skel, org.apache.axiom.soap.SOAPFactory factory) throws org.apache.axis2.AxisFault
      , 
      {
          org.apache.axiom.soap.SOAPEnvelope envelope = null;
          try {
              org.jibx.runtime.impl.UnmarshallingContext uctx = getNewUnmarshalContext(element);
              uctx.next();
              int index;
    
    
    
    
    
      
      
        
        
              envelope = factory.getDefaultEnvelope();
              org.apache.axiom.om.OMElement wrapper = factory.createOMElement("", "", "");
        
            wrapper.declareDefaultNamespace("");
        
        
              addMappingNamespaces(factory, wrapper, "", "");
        
        
              wrapper.declareNamespace(factory.createOMNamespace("", ""));
        
              envelope.getBody().addChild(wrapper);
              [] results = skel.;
              if (results == null || results.length == 0) {
        
          
          
                  throw new org.apache.axis2.AxisFault("Missing required result");
          
        
              } else {
        
          
                  for (int i = 0; i < results.length; i++) {
                       result = results[i];
                      if (result == null) {
            
              
                          // just skip optional element
              
              
                          org.apache.axiom.om.OMElement child = factory.createOMElement("", "", "");
                          org.apache.axiom.om.OMNamespace xsins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
                          child.declareNamespace(xsins);
                          child.addAttribute("nil", "true", xsins);
                          wrapper.addChild(child);
              
              
                          throw new org.apache.axis2.AxisFault("Null value in result array not allowed unless element has nillable='true'");
              
            
                      } else {
                          if (bindingFactory == null) {
                              throw new RuntimeException(bindingErrorMessage);
                          }
            
              
                          wrapper.addChild(mappedChild(result, factory));
              
              
                          org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(result, _type_name, "", "", "", bindingNamespaceIndexes, bindingNamespacePrefixes, bindingFactory);
                          org.apache.axiom.om.OMElement child = factory.createOMElement(src);
                          wrapper.addChild(child);
              
            
                      }
                  }
          
          
                  for (int i = 0; i < results.length; i++) {
                       result = results[i];
                      org.apache.axiom.om.OMElement child = factory.createOMElement("", "", "");
            
              
                      child.setText(result.toString());
              
              
                      child.setText((result));
              
            
                      wrapper.addChild(child);
                  }
          
        
              }
      
    
      
      
        
        
              envelope = factory.getDefaultEnvelope();
              org.apache.axiom.om.OMElement wrapper = factory.createOMElement("", "", "");
        
            wrapper.declareDefaultNamespace("");
        
        
              addMappingNamespaces(factory, wrapper, "", "");
        
        
              wrapper.declareNamespace(factory.createOMNamespace("", ""));
        
              envelope.getBody().addChild(wrapper);
               result = skel.;
        
          
              if (result == null) {
            
              
                          // just skip optional element
              
              
                  org.apache.axiom.om.OMElement child = factory.createOMElement("", "", "");
                  org.apache.axiom.om.OMNamespace xsins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
                  child.declareNamespace(xsins);
                  child.addAttribute("nil", "true", xsins);
                  wrapper.addChild(child);
              
              
                  throw new org.apache.axis2.AxisFault("Missing required result");
              
            
              } else {
                  if (bindingFactory == null) {
                      throw new RuntimeException(bindingErrorMessage);
                  }
            
              
                  wrapper.addChild(mappedChild(result, factory));
              
              
                  org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(result, _type_name, "", "", "", bindingNamespaceIndexes, bindingNamespacePrefixes, bindingFactory);
                  org.apache.axiom.om.OMElement child = factory.createOMElement(src);
                  wrapper.addChild(child);
              
            
              }
          
          
              org.apache.axiom.om.OMElement child = factory.createOMElement("",  "", "");
            
              
              if (result == null) {
                  org.apache.axiom.om.OMNamespace xsins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
                  child.declareNamespace(xsins);
                  child.addAttribute("nil", "true", xsins);
              } else {
                
              }
              
              
                
              
            
              wrapper.addChild(child);
          
        
      
    
      
      
              skel.;
        
              envelope = factory.getDefaultEnvelope();
              envelope.getBody().addChild(factory.createOMElement("", "", ""));
        
      
      
    
          } catch (org.jibx.runtime.JiBXException e) {
              throw org.apache.axis2.AxisFault.makeFault(e);
          }
          return envelope;
      }
  
  
  
    
      
              child.setText(result.toString());
      
      
              child.setText((result.()));
      
    
  
  
  
  
    (
    
      , 
    
    )
  
  
  
  
    
      
        
      
      
        
      
    
  
  
  
  
  
  
  
    error
    
    
    
    []
    
    
        /**
    
         * Auto generated synchronous call method
         * 
         * @see .#
        
         * @param 
         */
        public void (
    
    
         * Auto generated asynchronous call method
         * 
         * @see .#start
        
         * @param 
    
      
         * @throws 
      
    
         */
        public void start(
    
        
          , [] 
        
    
        , final  _callback
    
            ) throws java.rmi.RemoteException
    
      
      , 
    
            {
    
            // create message context
            final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext();
            try {
                int _opIndex = ;
                javax.xml.namespace.QName opname = _operations[_opIndex].getName();
                org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(opname);
                _operationClient.getOptions().setAction("");
                _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
    
                // create SOAP envelope with the payload
                org.apache.axiom.soap.SOAPEnvelope env = createEnvelope(_operationClient.getOptions());
                org.apache.axiom.soap.SOAPFactory factory = getFactory(_operationClient.getOptions().getSoapVersionURI());
                org.apache.axiom.om.OMElement wrapper = factory.createOMElement("", "", "");
    
                wrapper.declareDefaultNamespace("");
    
    
                addMappingNamespaces(factory, wrapper, "", "");
    
    
                wrapper.declareNamespace(factory.createOMNamespace("", ""));
    
                env.getBody().addChild(wrapper);
                org.apache.axiom.om.OMElement child;
    
    
                // add SOAP headers
                _serviceClient.addHeadersToEnvelope(env);
                
                // set that envelope on the message context
                _messageContext.setEnvelope(env);
    
                // add the message context to the operation client
                _operationClient.addMessageContext(_messageContext);
    
    
               // execute the operation client
                _operationClient.execute(true);
                
      
                org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient
                    .getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                org.apache.axiom.om.OMElement _response = _returnMessageContext.getEnvelope().getBody().getFirstElement();
                if (_response != null && "".equals(_response.getLocalName()) &&
                    "".equals(_response.getNamespace().getNamespaceURI())) {
                    org.jibx.runtime.impl.UnmarshallingContext uctx = getNewUnmarshalContext(_response);
                    uctx.parsePastStartTag("", "");
                    int index;
        
                    return ;
                } else {
                    throw new org.apache.axis2.AxisFault("Missing expected return wrapper element {}");
                }
      
            } catch (Exception e) {
                Exception outex = convertException(e);
      
                if (outex instanceof ) {
                    throw ()outex;
                }
      
                // should never happen, but just in case
                throw new RuntimeException("Unexpected exception type: " +
                    outex.getClass().getName(), outex);
            } finally {
                _messageContext.getTransportOut().getSender().cleanup(_messageContext);
            }
        }
    
    
                _operationClient.setCallback(new org.apache.axis2.client.async.AxisCallback() {
                    public void onMessage(org.apache.axis2.context.MessageContext  msgCtx) {
                        try {
                            org.apache.axiom.om.OMElement result = msgCtx.getEnvelope().getBody().getFirstElement();
                            if (result != null && "".equals(result.getLocalName()) &&
                                "".equals(result.getNamespace().getNamespaceURI())) {
                                org.jibx.runtime.impl.UnmarshallingContext uctx = getNewUnmarshalContext(result);
                                uctx.parsePastStartTag("", "");
                                int index;
      
                                _callback.receiveResult();
                            } else {
                                throw new org.apache.axis2.AxisFault("Missing expected result wrapper element {}");
                            }
                        } catch (Exception e) {
                            onError(e);
                        } finally {
                            try {
                                _messageContext.getTransportOut().getSender().cleanup(_messageContext);
                            } catch (org.apache.axis2.AxisFault axisFault) {
                                onError(axisFault);
                            }   
                        }
                    }
                    public void onFault(org.apache.axis2.context.MessageContext  msgCtx) {
                        try {
                            org.apache.axiom.om.OMElement result = msgCtx.getEnvelope().getBody().getFirstElement();
                            if (result != null && "".equals(result.getLocalName()) &&
                                "".equals(result.getNamespace().getNamespaceURI())) {
                                org.jibx.runtime.impl.UnmarshallingContext uctx = getNewUnmarshalContext(result);
                                uctx.parsePastStartTag("", "");
                                int index;
      
                                _callback.receiveResult();
                            } else {
                                throw new org.apache.axis2.AxisFault("Missing expected result wrapper element {}");
                            }
                        } catch (Exception e) {
                            onError(e);
                        } finally {
                            try {
                                _messageContext.getTransportOut().getSender().cleanup(_messageContext);
                            } catch (org.apache.axis2.AxisFault axisFault) {
                                onError(axisFault);
                            }   
                        }
                    }

                    public void onError(Exception e) {
                        _callback.receiveError(e);
                    }
                    
                     public void onComplete(){
                     }
                });
                        
                org.apache.axis2.util.CallbackReceiver _callbackReceiver = null;
                if ( _operations[_opIndex].getMessageReceiver() == null && _operationClient.getOptions().isUseSeparateListener()) {
                    _callbackReceiver = new org.apache.axis2.util.CallbackReceiver();
                    _operations[_opIndex].setMessageReceiver(_callbackReceiver);
                }

                // execute the operation client
                _operationClient.execute(false);
                
            } catch (Exception e) {
                Exception outex = convertException(e);
                throw new RuntimeException("Unexpected exception type: " +
                    outex.getClass().getName(), outex);
            }
        }
    
  
  
  
  
  
  
  
  
  
  
    
      
        
      
      
        
      
    
  
  
  
  
    if ( == null || .length == 0) {
    
      
          // just skip optional element
      
      
        child = factory.createOMElement("", "", "");
        org.apache.axiom.om.OMNamespace xsins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
        child.declareNamespace(xsins);
        child.addAttribute("nil", "true", xsins);
        wrapper.addChild(child);
      
      
        throw new org.apache.axis2.AxisFault("Missing required value ");
      
    
    } else {
        for (int i = 0; i < .length; i++) {
             _item = [i];
    
      
            if (_item == null) {
                child = factory.createOMElement("", "", "");
                org.apache.axiom.om.OMNamespace xsins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
                child.declareNamespace(xsins);
                child.addAttribute("nil", "true", xsins);
                wrapper.addChild(child);
            } else {
        
            }
      
      
            if (_item == null) {
                throw new org.apache.axis2.AxisFault("Null value in array ");
            } else {
        
            }
      
      
        
      
    
        }
    }
  
  
  
  
    
      
        if ( == null) {
        
          
            // just skip optional element
          
          
            child = factory.createOMElement("", "", "");
            org.apache.axiom.om.OMNamespace xsins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
            child.declareNamespace(xsins);
            child.addAttribute("nil", "true", xsins);
            wrapper.addChild(child);
          
          
            throw new org.apache.axis2.AxisFault("Null value for ");
          
        
        } else {
        
        }
      
      
        
      
    
  
  
  
  
    
      
        child = factory.createOMElement("", "", "");
        child.setText();
      
      
        child = factory.createOMElement("", "", "");
        child.setText(.toString());
      
      
        child = factory.createOMElement("", "", "");
        child.setText(());
      
      
        if (bindingFactory == null) {
            throw new RuntimeException(bindingErrorMessage);
        }
        child = mappedChild(, factory);
      
      
        if (bindingFactory == null) {
            throw new RuntimeException(bindingErrorMessage);
        }
        org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(, _type_name, "", "", "", bindingNamespaceIndexes, bindingNamespacePrefixes, bindingFactory);
        child = factory.createOMElement(src);
      
    
        wrapper.addChild(child);
  
  
  
  _item.()
  
  
  
    
      
        
      
      
        
      
    
  
  
  
  
  
  
    
    private Exception convertException(Exception ex) throws java.rmi.RemoteException {
        if (ex instanceof org.apache.axis2.AxisFault) {
            org.apache.axis2.AxisFault f = (org.apache.axis2.AxisFault)ex;
            org.apache.axiom.om.OMElement faultElt = f.getDetail();
            if (faultElt != null) {
                if (faultExceptionNameMap.containsKey(faultElt.getQName())) {
                    try {
                        
                        // first create the actual exception
                        String exceptionClassName = (String)faultExceptionClassNameMap.get(faultElt.getQName());
                        Class exceptionClass = Class.forName(exceptionClassName);
                        Exception e = (Exception)exceptionClass.newInstance();
                        
                        // build the message object from the details
                        String messageClassName = (String)faultMessageMap.get(faultElt.getQName());
                        Class messageClass = Class.forName(messageClassName);
                        Object messageObject = fromOM(faultElt, messageClass);
                        java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage",
                            new Class[] { messageClass });
                        m.invoke(e, new Object[] { messageObject });
                        return e;
                        
                    } catch (ClassCastException e) {
                        // we cannot intantiate the class - throw the original
                        // Axis fault
                        throw f;
                    } catch (ClassNotFoundException e) {
                        // we cannot intantiate the class - throw the original
                        // Axis fault
                        throw f;
                    } catch (NoSuchMethodException e) {
                        // we cannot intantiate the class - throw the original
                        // Axis fault
                        throw f;
                    } catch (java.lang.reflect.InvocationTargetException e) {
                        // we cannot intantiate the class - throw the original
                        // Axis fault
                        throw f;
                    } catch (IllegalAccessException e) {
                        // we cannot intantiate the class - throw the original
                        // Axis fault
                        throw f;
                    } catch (InstantiationException e) {
                        // we cannot intantiate the class - throw the original
                        // Axis fault
                        throw f;
                    }
                } else {
                    throw f;
                }
            } else {
                throw f;
            }
            
        } else if (ex instanceof RuntimeException) {
            throw (RuntimeException)ex;
        } else if (ex instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException)ex;
        } else {
            throw org.apache.axis2.AxisFault.makeFault(ex);
        }
    }
    
  
  
  
  
  
  
  
    
    private static final org.jibx.runtime.IBindingFactory bindingFactory;
    private static final String bindingErrorMessage;
    private static final int[] bindingNamespaceIndexes;
    private static final String[] bindingNamespacePrefixes;
    
    static {
        org.jibx.runtime.IBindingFactory factory = null;
        String message = null;
        try {
    
      
            factory = org.jibx.runtime.BindingDirectory.getFactory("", "", .class.getClassLoader());
      
      
            factory = org.jibx.runtime.BindingDirectory.getFactory(.class);
      
      
            factory = new org.apache.axis2.jibx.NullBindingFactory();
      
    
            message = null;
        } catch (Exception e) { message = e.getMessage(); }
        bindingFactory = factory;
        bindingErrorMessage = message;
    
        int[] indexes = null;
        String[] prefixes = null;
        if (factory != null) {
            
            // check for xsi namespace included
            String[] nsuris = factory.getNamespaces();
            int xsiindex = nsuris.length;
            while (--xsiindex >= 0 &&
                !"http://www.w3.org/2001/XMLSchema-instance".equals(nsuris[xsiindex]));
            
            // get actual size of index and prefix arrays to be allocated
            int nscount = ;
            int usecount = nscount;
            if (xsiindex >= 0) {
                usecount++;
            }
            
            // allocate and initialize the arrays
            indexes = new int[usecount];
            prefixes = new String[usecount];
      
        
            indexes[] = nsIndex("", nsuris);
            prefixes[] = "";
      
            if (xsiindex >= 0) {
                indexes[nscount] = xsiindex;
                prefixes[nscount] = "xsi";
            }
            
        }
        bindingNamespaceIndexes = indexes;
        bindingNamespacePrefixes = prefixes;
    }
    
    private static int nsIndex(String uri, String[] uris) {
        for (int i = 0; i < uris.length; i++) {
            if (uri.equals(uris[i])) {
                return i;
            }
        }
        throw new IllegalArgumentException("Namespace " + uri + " not found in binding directory information");
    }
    
    private static void addMappingNamespaces(org.apache.axiom.soap.SOAPFactory factory, org.apache.axiom.om.OMElement wrapper, String nsuri, String nspref) {
        String[] nss = bindingFactory.getNamespaces();
        for (int i = 0; i < bindingNamespaceIndexes.length; i++) {
            int index = bindingNamespaceIndexes[i];
            String uri = nss[index];
            String prefix = bindingNamespacePrefixes[i];
            if (!nsuri.equals(uri) || !nspref.equals(prefix)) {
                wrapper.declareNamespace(factory.createOMNamespace(uri, prefix));
            }
        }
    }
    
    private static org.jibx.runtime.impl.UnmarshallingContext getNewUnmarshalContext(org.apache.axiom.om.OMElement param)
        throws org.jibx.runtime.JiBXException {
        if (bindingFactory == null) {
            throw new RuntimeException(bindingErrorMessage);
        }
        org.jibx.runtime.impl.UnmarshallingContext ctx =
            (org.jibx.runtime.impl.UnmarshallingContext)bindingFactory.createUnmarshallingContext();
        org.jibx.runtime.IXMLReader reader = new org.jibx.runtime.impl.StAXReaderWrapper(param.getXMLStreamReaderWithoutCaching(), "SOAP-message", true);
        ctx.setDocument(reader);
        ctx.toTag();
        return ctx;
    }
    
    private org.apache.axiom.om.OMElement mappedChild(Object value, org.apache.axiom.om.OMFactory factory) {
        org.jibx.runtime.IMarshallable mrshable = (org.jibx.runtime.IMarshallable)value;
        org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(mrshable, bindingFactory);
        return factory.createOMElement(src);
    }
    
    
    private static Object fromOM(org.apache.axiom.om.OMElement param, Class type) throws org.apache.axis2.AxisFault{
        try {
            org.jibx.runtime.impl.UnmarshallingContext ctx = getNewUnmarshalContext(param);
            return ctx.unmarshalElement(type);
        } catch (Exception e) {
             throw org.apache.axis2.AxisFault.makeFault(e);
        }
    }
  
  
  
  
          private static final String _type_name;
  
    
  
  
         _type_name =
             "{}:";
  
  
  
  
  
  
  
    []  = new [4];
      index = 0;
    
      
      while (uctx.getUnmarshaller("", "").isPresent(uctx)) {
      
      
      while (uctx.isAt("", "")) {
      
    
          if (index >= .length) {
               = ([])org.jibx.runtime.Utility.growArray();
          }
    
          if (uctx.attributeBoolean("http://www.w3.org/2001/XMLSchema-instance", "nil", false)) {
              uctx.skipElement();
          } else {
    
    [index++] = ();
    
              uctx.parsePastCurrentEndTag("", "");
    
    
          }
    
      }
       = ([])org.jibx.runtime.Utility.resizeArray(index, );
    
      if (index == 0) {
          throw new org.apache.axis2.AxisFault("Missing required element {}");
      }
    
  
  
  
  
      = null;
    
      
            if (uctx.getUnmarshaller("", "").isPresent(uctx)) {
      
      
            if (uctx.isAt("", "")) {
      
    
    
                if (uctx.attributeBoolean("http://www.w3.org/2001/XMLSchema-instance", "nil", false)) {
                    uctx.skipElement();
                } else {
    
     = ();
    
                uctx.parsePastCurrentEndTag("", "");
    
    
                }
    
    
      
            }
      
      
            } else {
                throw new org.apache.axis2.AxisFault("Missing required element {}");
            }
      
    
  
  
  
  
    
      
        uctx.parseElementText("", "")
      
      
        new (uctx.parseElementText("", ""))
      
      
        new ((uctx.parseElementText("", "")))
      
      
        (uctx.parseElementText("", ""))
      
      
        uctx.unmarshalElement()
      
      
        uctx.getUnmarshaller(_type_name).unmarshal(nullnew (), uctx)
      
    
  
  




© 2015 - 2025 Weber Informatics LLC | Privacy Policy