Package org.apache.axis.message

Examples of org.apache.axis.message.SOAPBodyElement


                boolean isStream = ((SOAPPart)reqMsg.getSOAPPart()).isBodyStream();
               
                if (reqMsg != null && !isStream) {
                    reqEnv = reqMsg.getSOAPEnvelope();

                    SOAPBodyElement body = reqEnv.getFirstBody();

                    if (body != null) {
                        if ( body.getNamespaceURI() == null ) {
                            throw new AxisFault("Call.invoke",
                                                Messages.getMessage("cantInvoke00", body.getName()),
                                                null, null);
                        } else {
                            msgContext.setTargetService(body.getNamespaceURI());
                        }
                    }
                }
            }
        }
View Full Code Here


         */
        resMsg.setMessageType(Message.RESPONSE);

        SOAPEnvelope resEnv = resMsg.getSOAPEnvelope();

        SOAPBodyElement respBody = resEnv.getFirstBody();
        if (respBody instanceof SOAPFault) {
            //we got a fault
            if(operation == null ||
                    operation.getReturnClass() == null ||
                    operation.getReturnClass() !=
View Full Code Here

    {
      // pull the uddi request xml element from
      // the body of the soapRequest

      SOAPEnvelope env = soapRequest.getSOAPEnvelope();
      SOAPBodyElement requestBody = env.getFirstBody();
      request = requestBody.getAsDOM();

      // make the monitor inspect the SOAP Body
      // DOM element
      if (monitor != null)
        monitor.inspectUDDIRequest(request);

      // grab the function name from this element -
      // we'll need this to lookup the xml handler
      // to use to unmarshal the xml into a juddi
      // object.

      function = request.getLocalName();

      // grab the generic value - we'll need it in
      // the event that an exception is thrown.

      generic = request.getAttribute("generic");
      if (generic == null)
        generic = IRegistry.UDDI_V2_GENERIC;

      // lookup the appropriate xml handler, throw
      // an UnsupportedException if one could not be
      // located.

      IHandler requestHandler = maker.lookup(function);
      if (requestHandler == null)
        throw new UnsupportedException("The request " +
          "type is unknown: " +function);

      // unmarshal the raw xml into an associated
      // jUDDI request object.

      RegistryObject uddiRequest = requestHandler.unmarshal(request);

      // make the monitor inspect the UDDI request
      // object
      if (monitor != null)
        monitor.inspectRegistryObject(uddiRequest);

      // Determine if this message came from through
      // the Publish, Inquiry or Admin API and handle
      // it appropriately.

      Object juddiServlet = messageContext.getProperty("transport.http.servlet");

      // confirm that the the appropriate endpoint
      // was used to invoke the selected jUDDI/UDDI
      // function.

      if((juddiServlet instanceof InquiryServlet) &&
         (!(uddiRequest instanceof org.apache.juddi.datatype.request.Inquiry)))
      {
        throw new RegistryException("Inquiry API " +
          "does not support function: "+function);
      }
      else if (juddiServlet instanceof PublishServlet &&
         (!(uddiRequest instanceof org.apache.juddi.datatype.request.Publish) &&
          !(uddiRequest instanceof org.apache.juddi.datatype.request.SecurityPolicy)))
      {
        throw new RegistryException("Publish API " +
          "does not support function: "+function);
      }
      else if ((juddiServlet instanceof AdminServlet) &&    // Admin
         (!(uddiRequest instanceof org.apache.juddi.datatype.request.Admin)))
      {
        throw new RegistryException("Admin API " +
          "does not support function: "+function);
      }

      // grab a reference to the shared jUDDI registry
      // instance (make sure it's running) and execute
      // the requested UDDI function.

      RegistryObject uddiResponse = null;
     
      RegistryEngine registry = RegistryServlet.getRegistry();
      if ((registry != null) && (registry.isAvailable()))
        uddiResponse = registry.execute(uddiRequest);
      else
        throw new BusyException("The Registry is unavailable");

      // create a new 'temp' XML element. This
      // element is used as a container in which
      // to marshal the UDDI response into.

      Document document = XMLUtils.createDocument();
      Element element = document.createElement("temp");

      // lookup the appropriate response handler
      // and marshal the juddi object into the
      // appropriate xml format (we only support
      // uddi v2.0 at this time) attaching results
      // to the temporary 'temp' element.

      IHandler responseHandler = maker.lookup(uddiResponse.getClass().getName());
      responseHandler.marshal(uddiResponse,element);

      // grab a reference to the 'temp' element's
      // only child here (this has the effect of
      // discarding the temp element) and appending
      // this child to the soap response body.

      response = (Element)element.getFirstChild();
    }
    catch(RegistryException rex)
    {
      log.error(rex.getMessage(),rex);

      String fCode = rex.getFaultCode();
      String fString = rex.getFaultString();
      String fActor = rex.getFaultActor();

      DispositionReport dispRpt = rex.getDispositionReport();
      if (dispRpt != null)
      {
        dispRpt.setGeneric(generic);
        dispRpt.setOperator(Config.getOperator());
      }

      if (monitor != null)
        monitor.addMonitorFault(fString);

      response = createFault(fCode,fString,fActor,dispRpt);
    }
    catch(AxisFault axf)
    {
      log.error(axf.getMessage(),axf);

      String fCode = String.valueOf(axf.getFaultCode());
      String fString = axf.getFaultString();
      String fActor = axf.getFaultActor();

      if (monitor != null)
        monitor.addMonitorFault(fString);

      response = createFault(fCode,fString,fActor,null);
    }
    catch(Exception ex)
    {
      log.error(ex.getMessage(),ex);

      String fCode = null;
      String fString = ex.getMessage();
      String fActor = null;

      if (monitor != null)
        monitor.addMonitorFault(fString);

      response = createFault(fCode,fString,fActor,null);
    }
    finally
    {
      // write the monitored information to the currently
      // configured 'Monitor' implemneted registry (the
      // default Monitor implementation writes the monitored
      // information to a database table via JDBC).

      if (monitor != null)
        monitor.log();
    }

    try {
      SOAPBodyElement soapRespBody = new SOAPBodyElement(response);
      SOAPEnvelope soapRespEnv = soapResponse.getSOAPEnvelope();
      soapRespEnv.addBodyElement(soapRespBody);
    }
    catch(AxisFault af) {
      af.printStackTrace();
View Full Code Here

            env.addNamespaceDeclaration("xsi", "http://www.w3.org/1999/XMLSchema-instance");
            env.addNamespaceDeclaration("xsd", "http://www.w3.org/1999/XMLSchema");

            //build the body
            Name bodyName = env.createName(BODYELEMENT, "x", URN);
            SOAPBodyElement body = new SOAPBodyElement(bodyName);

            //set the format to soap2
            Element e = XMLUtils.StringToElement("", "format", "soap2");
            SOAPElement sbe = new SOAPBodyElement(e);
            body.addChildElement(sbe);

            //add all the parameters to the body
            for (Iterator i = parameters.iterator(); i.hasNext();) {
                Parameter p = (Parameter) i.next();
                e = XMLUtils.StringToElement("", p.getName(), p.getValue().toString());
                sbe = new SOAPBodyElement(e);
                body.addChildElement(sbe);
            }

            //put the body in the envelope
            env.addBodyElement(body);
View Full Code Here

            return null;
          }
        }

        resEnv = (SOAPEnvelope)resMsg.getSOAPEnvelope();
        SOAPBodyElement bodyEl = resEnv.getFirstBody();
        if (bodyEl instanceof RPCElement) {
            try {
                resArgs = ((RPCElement) bodyEl).getParams();
            } catch (Exception e) {
                log.error(JavaUtils.getMessage("exception00"), e);
                throw AxisFault.makeFault(e);
            }

            if (resArgs != null && resArgs.size() > 0) {

                // If there is no return, then we start at index 0 to create the outParams Map.
                // If there IS a return, then we start with 1.
                int outParamStart = 0;

                // If we have resArgs and the returnType is specified, then the first
                // resArgs is the return.  If we have resArgs and neither returnType
                // nor paramXMLTypes are specified, then we assume that the caller is
                // following the non-JAX-RPC AXIS shortcut of not having to specify
                // the return, in which case we again assume the first resArgs is
                // the return.
                // NOTE 1:  the non-JAX-RPC AXIS shortcut allows a potential error
                // to escape notice.  If the caller IS NOT following the non-JAX-RPC
                // shortcut but instead intentionally leaves returnType and params
                // null (ie., a method that takes no parameters and returns nothing)
                // then, if we DO receive something it should be an error, but this
                // code passes it through.  The ideal solution here is to require
                // this caller to set the returnType to void, but there's no void
                // type in XML.
                // NOTE 2:  we should probably verify that the resArgs element
                // types match the expected returnType and paramXMLTypes, but I'm not
                // sure how to do that since the resArgs value is a Java Object
                // and the returnType and paramXMLTypes are QNames.

                // GD 03/15/02 : We're now checking for invalid metadata
                // config at the top of this method, so don't need to do it
                // here.  Check for void return, though.
                if (!XMLType.AXIS_VOID.equals(returnType)) {
                    RPCParam param = (RPCParam)resArgs.get(0);
                    result = param.getValue();
                    outParamStart = 1;
                }

                for (int i = outParamStart; i < resArgs.size(); i++) {
                    RPCParam param = (RPCParam) resArgs.get(i);

                    Class javaType = getJavaTypeForQName(param.getQName());
                    Object value = param.getValue();

                    // Convert type if needed
                    if (javaType != null &&
                           !javaType.isAssignableFrom(value.getClass())) {
                        value = JavaUtils.convert(value, javaType);
                    }

                    outParams.put(param.getQName(), value);
                    outParamsList.add(value);
                }
            }
        } else {
            // This is a SOAPBodyElement, try to treat it like a return value
            try {
                result = bodyEl.getValueAsType(returnType);
            } catch (Exception e) {
                // just return the SOAPElement
                result = bodyEl;
            }
View Full Code Here

                // If we have headers to insert, do so now.
                for (int i = 0 ; myHeaders != null && i < myHeaders.size() ; i++ )
                    reqEnv.addHeader((SOAPHeaderElement)myHeaders.get(i));

                SOAPBodyElement body = reqEnv.getFirstBody();

                // Does this make any sense to anyone?  If not, we should remove it.
                // --Glen 03/16/02
                //if ( body.getPrefix() == null )       body.setPrefix( "m" );
                if ( body.getNamespaceURI() == null ) {
                    throw new AxisFault("Call.invoke",
                                        JavaUtils.getMessage("cantInvoke00", body.getName()),
                                        null, null);
                } else {
                    msgContext.setTargetService(body.getNamespaceURI());
                }
            }

            SOAPService svc = msgContext.getService();
            if (svc != null) {
View Full Code Here

         */
        resMsg.setMessageType(Message.RESPONSE);

        SOAPEnvelope resEnv = (SOAPEnvelope)resMsg.getSOAPEnvelope();

        SOAPBodyElement respBody = resEnv.getFirstBody();
        if (respBody instanceof SOAPFault) {
            throw ((SOAPFault)respBody).getFault();
        }
    }
View Full Code Here

        Document doc = null ;
       
        if (bodyOnlyService) {
            // dig out just the body, and pass it with the MessageContext
            Vector                bodies  = reqEnv.getBodyElements();
            SOAPBodyElement       reqBody = reqEnv.getFirstBody();
            NoSuchMethodException exp2 = null ;

            doc = reqBody.getAsDOM().getOwnerDocument();

            Vector newBodies = new Vector();
            for (int i = 0 ; i < bodies.size() ; i++ )
                newBodies.add( ((SOAPBodyElement)bodies.get(i)).getAsDOM() );
            bodies = newBodies ;

            /* If no methodName was specified during deployment then get it */
            /* from the root of the Body element                            */
            /* Hmmm, should we do this????                                  */
            /****************************************************************/
            if ( methodName == null || methodName.equals("") ) {
                Element root = doc.getDocumentElement();
                if ( root != null ) methodName = root.getLocalName();
            }

            // Try the "right" one first, if this fails then default back
            // to the old ones - those should be removed eventually.
            /////////////////////////////////////////////////////////////////
            argClasses = new Class[1];
            argObjects = new Object[1];
            argClasses[0] = ClassUtils.forName("java.util.Vector", true, clsLoader);
            argObjects[0] = bodies ;

            try {
                method = jc.getJavaClass().getMethod( methodName, argClasses );
                Element[] result = (Element[]) method.invoke( obj, argObjects );       
                if ( result != null ) {
                    for ( int i = 0 ; i < result.length ; i++ )
                        resEnv.addBodyElement( new SOAPBodyElement(result[i]));
                }
                return ;
            } catch( NoSuchMethodException exp ) {
                exp2 = exp;
            }

            if ( method == null ) {
              // Try the the simplest case first - just Document as the param
              /////////////////////////////////////////////////////////////////
                argClasses = new Class[1];
                argObjects = new Object[1];
                argClasses[0] = ClassUtils.forName("org.w3c.dom.Document", true, clsLoader);
                argObjects[0] = doc ;

                try {
                    method = jc.getJavaClass().getMethod( methodName, argClasses );
                } catch( NoSuchMethodException exp ) {
                    exp2 = exp;
                }
            }

            if ( method == null ) {
                String oldmsg = exp2.getMessage();
                oldmsg = oldmsg == null ? "" : oldmsg;
                String msg = oldmsg + JavaUtils.getMessage("triedClass00",
                        jc.getJavaClass().getName(), methodName);
                throw new NoSuchMethodException(msg);
            }
        } else {
            // pass *just* the MessageContext (maybe don't even parse!!!)
            argClasses = new Class[1];
            argObjects = new Object[1];
            argClasses[0] = ClassUtils.forName("org.apache.axis.MessageContext", true, clsLoader);
            argObjects[0] = msgContext ;
            try {
                method = jc.getJavaClass().getMethod( methodName, argClasses );
            }   
            catch( NoSuchMethodException exp2 ) {
                // No match - just throw an error
                //
                // We do not log the error here, this is
                // treated as a catch-rethrow as:
                // 1) it's clear where the exception is generated (try-block above)
                // 2) we are adding detail to the exception's message.
                ////////////////////////////////////////////

                String oldmsg = exp2.getMessage();
                oldmsg = oldmsg == null ? "" : oldmsg;
                String msg = oldmsg + JavaUtils.getMessage("triedClass00",
                        jc.getJavaClass().getName(), methodName);
                throw new NoSuchMethodException(msg);
            }
        }
       
       
        // !!! WANT TO MAKE THIS SAX-CAPABLE AS WELL.  Some people will
        //     want DOM, but our examples should mostly lean towards the
        //     SAX side of things....

        Document retDoc = (Document) method.invoke( obj, argObjects );       
        if ( retDoc != null ) {
            SOAPBodyElement el = new SOAPBodyElement(retDoc.getDocumentElement());
            resEnv.addBodyElement(el);
        }
    }
View Full Code Here

            // we're probably a non-wrapped doc/lit service.  In this case,
            // we deserialize the element, and create an RPCElement "wrapper"
            // around it which points to the correct method.
            // FIXME : There should be a cleaner way to do this...
            if (!(bodies.get(bNum) instanceof RPCElement)) {
                SOAPBodyElement bodyEl = (SOAPBodyElement)bodies.get(bNum);
                // igors: better check if bodyEl.getID() != null
                // to make sure this loop does not step on SOAP-ENC objects
                // that follow the parameters! FIXME?
                if (bodyEl.isRoot() && operation != null && bodyEl.getID() == null) {
                    ParameterDesc param = operation.getParameter(bNum);
                    // at least do not step on non-existent parameters!
                    if(param != null) {
                        Object val = bodyEl.getValueAsType(param.getTypeQName());
                        body = new RPCElement("",
                                              operation.getName(),
                                              new Object [] { val });
                    }
                }
View Full Code Here

       
        call.setUseSOAPAction( true);
        call.setSOAPActionURI( "AdminService");

        Vector result = null ;
        Object[]  params = new Object[] { new SOAPBodyElement(input) };
        result = (Vector) call.invoke( params );

        input.close();

        if (result == null || result.isEmpty())
            throw new AxisFault(JavaUtils.getMessage("nullResponse00"));

        SOAPBodyElement body = (SOAPBodyElement) result.elementAt(0);
        return body.toString();
    }
View Full Code Here

TOP

Related Classes of org.apache.axis.message.SOAPBodyElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.