Package org.apache.axis.message

Examples of org.apache.axis.message.SOAPBodyElement


                msgContext.setTargetService(targetService);
            } else {
                // No direct config, so try the namespace of the first body.
                reqMsg = msgContext.getRequestMessage();
                reqEnv = reqMsg.getSOAPEnvelope();
                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) {
                svc.setPropertyParent(myProperties);
            } else {
                msgContext.setPropertyParent(myProperties);
            }
        }

        if (log.isDebugEnabled()) {
            log.debug(JavaUtils.getMessage("targetService",
                    msgContext.getTargetService()));
        }

        // set up transport if there is one
        if (transport != null) {
            transport.setupMessageContext(msgContext, this, service.getEngine());
        }
        else
            msgContext.setTransportName( transportName );

        // For debugging - print request message
        if (log.isDebugEnabled()) {
            StringWriter writer = new StringWriter();
            try {
                SerializationContext ctx = new SerializationContextImpl(writer,
                                                                   msgContext);
                reqEnv.output(ctx);
                writer.close();
            } catch (Exception e) {
                log.debug(JavaUtils.getMessage("exceptionPrinting"), e);
            } finally {
                log.debug(writer.getBuffer().toString());
            }
        }

        service.getEngine().invoke( msgContext );

        if (transport != null)
            transport.processReturnedMessageContext(msgContext);

        Message resMsg = msgContext.getResponseMessage();

        if (resMsg == null)
            throw new AxisFault(JavaUtils.getMessage("nullResponse00"));

        /** This must happen before deserialization...
         */
        resMsg.setMessageType(Message.RESPONSE);

        SOAPEnvelope resEnv = (SOAPEnvelope)resMsg.getSOAPPart().
                getAsSOAPEnvelope();

        SOAPBodyElement respBody = resEnv.getFirstBody();
        if (respBody instanceof SOAPFaultElement) {
            throw ((SOAPFaultElement)respBody).getFault();
        }

        if (log.isDebugEnabled()) {
View Full Code Here


            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(new java.net.URL(opts.getURL()));

            SOAPEnvelope env = new SOAPEnvelope();
            SOAPBodyElement sbe = new SOAPBodyElement(XMLUtils.StringToElement("http://localhost:8080/LogTestService", "testMethod", ""));
            env.addBodyElement(sbe);

            env = new SignedSOAPEnvelope(env, "http://xml-security");

            System.out.println("\n============= Request ==============");
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] = clsLoader.loadClass("java.util.Vector");
            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] = clsLoader.loadClass("org.w3c.dom.Document");
                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] = clsLoader.loadClass("org.apache.axis.MessageContext");
            argObjects[0] = msgContext ;
            try {
                method = jc.getJavaClass().getMethod( methodName, argClasses );
            }   
            catch( NoSuchMethodException exp2 ) {
                // No match - just throw an error
                ////////////////////////////////////////////
                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) {
                    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 });
                    }
                    else continue;
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

        message.setMessageContext(new MessageContext(server));

        SOAPEnvelope envelope = (SOAPEnvelope) message.getSOAPPart().getAsSOAPEnvelope();
        assertNotNull("envelope", envelope);

        SOAPBodyElement respBody = envelope.getFirstBody();
        assertTrue("respBody should be a SOAPFaultElement", respBody
                        instanceof SOAPFaultElement);
        AxisFault aFault = ((SOAPFaultElement) respBody).getFault();

        assertNotNull("Fault should not be null", aFault);
View Full Code Here

            final DeserializationContext dser =
                new DeserializationContext(new InputSource(in), resMsg.getMessageContext(), null);
            dser.parse();
            final SOAPEnvelope responseEnvelope = dser.getEnvelope();

            final SOAPBodyElement bodyEl = responseEnvelope.getFirstBody();
            if (bodyEl == null) {
                return null;
            }

            final QName returnType = operation.getReturnType();
            if (XMLType.AXIS_VOID.equals(returnType)) {
                return null;
            }

            Object result = null;

            if (bodyEl instanceof RPCElement) {
                final RPCElement body = (RPCElement) bodyEl;
                body.setNeedDeser(true);
                Vector args = null;
                try {
                    args = body.getParams();
                } catch (final SAXException e) {
                    if (e.getException() != null) {
                        throw e.getException();
                    }
                    throw e;
                }

                final QName returnParamQName = operation.getReturnQName();
                if (args != null && args.size() > 0) {

                    if (returnParamQName == null) {
                        final RPCParam param = (RPCParam) args.get(0);
                        result = param.getObjectValue();
                    } else {
                        for (int i = 0; i < args.size(); i++) {
                            final RPCParam param = (RPCParam) args.get(i);
                            if (returnParamQName.equals(param.getQName())) {
                                result = param.getObjectValue();
                                break;
                            }
                        }
                    }

                }
            } else {
                try {
                    result = bodyEl.getValueAsType(returnType);
                } catch (final Exception e) {
                    result = bodyEl;
                }
            }
View Full Code Here

        if (env.getBody() == null) {
            env.addBody();
        }
        Name name = env.createName("", Constants.WSRM.NS_PREFIX_RM, Constants.WSRM.NS_URI_RM);
        SOAPBodyElement bodyElement = (SOAPBodyElement) env.getBody().addBodyElement(name);
        bodyElement.setName(Constants.WSRM.CREATE_SEQUENCE_RESPONSE);
        if (identifier != null) {
            identifier.toSOAPEnvelope(bodyElement);
        }
        if (accept != null)
            accept.toSOAPEnvelope(bodyElement);
View Full Code Here

        if (env.getBody() == null) {
            env.addBody();
        }

        Name name = env.createName("", Constants.WSRM.NS_PREFIX_RM, Constants.WSRM.NS_URI_RM);
        SOAPBodyElement bodyElement = (SOAPBodyElement) env.getBody().addBodyElement(name);

        bodyElement.setName(Constants.WSRM.TERMINATE_DEQUENCE);

        if (identifier != null) {
            identifier.toSOAPEnvelope(bodyElement);
        }
View Full Code Here

                }
            }

            iterator = (Iterator) env.getBody().getChildElements();

            SOAPBodyElement bodyElement;

            while (iterator.hasNext()) {
                bodyElement = (SOAPBodyElement) iterator.next();

                if (bodyElement.getName().equals(Constants.WSRM.CREATE_SEQUENCE)) {
                    createSequence = new CreateSequence();

                    createSequence.fromSOAPEnveploe(bodyElement);
                }

                if (bodyElement.getName().equals(Constants.WSRM.CREATE_SEQUENCE_RESPONSE)) {
                    createSequenceResponse = new CreateSequenceResponse();

                    createSequenceResponse.fromSOAPEnveploe(bodyElement);
                }

                if (bodyElement.getName().equals(Constants.WSRM.TERMINATE_DEQUENCE)) {
                    terminateSequence = new TerminateSequence();

                    terminateSequence.fromSOAPEnveploe(bodyElement);
                }
            }
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.