Package org.apache.axis.message

Examples of org.apache.axis.message.SOAPBodyElement


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

            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 ;

            // We know we have one param.  OK, is it a Vector?
            if (params[0] == Vector.class) {
                // Yes, invoke away!
                argObjects[0] = bodies ;
                Element[] result = (Element[]) method.invoke( obj, argObjects );
                if ( result != null ) {
                    for ( int i = 0 ; i < result.length ; i++ ) {
                        if(result[i] != null)
                            resEnv.addBodyElement( new SOAPBodyElement(result[i]));
                    }
                }
                return ;
            } else if (params[0] == Document.class) {
                // Not a Vector, but a Document!  Invoke away!
                argObjects[0] = doc;

                // !!! WANT TO MAKE THIS SAX-CAPABLE AS WELL?
                Document retDoc = (Document) method.invoke( obj, argObjects );
                if ( retDoc != null ) {
                    SOAPBodyElement el = new SOAPBodyElement(retDoc.getDocumentElement());
                    resEnv.addBodyElement(el);
                }
            } else {
                // Neither - must be a bad method.
                throw new AxisFault(
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

            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

        // Add a custom element of our own creation
        tokenRequest.addCustomElementNS("http://testElementNs.testElementNs", "te:TestElement");

        // Create a SOAP body and set the XML element of the token request (a <RequestSecurityToken> element)
        // as its only child
        SOAPBodyElement sbe = new SOAPBodyElement(tokenRequest.getElement());

        // Add the body element to the SOAP envelope
        env.addBodyElement(sbe);

        System.out.println("\n============= Request ==============");
        System.out.println(XMLUtils.DocumentToString(env.getAsDocument()));
   
        // This is where we actually invoke the service, sending the request we've constructed
        // Assuming we did everything right, it will return to us a SOAP envelope containing the response
        SOAPEnvelope response = call.invoke(env);

        System.out.println("\n============= Response ==============");
        XMLUtils.PrettyElementToStream(response.getAsDOM(), System.out);
   
        // Find the <RequestSecurityTokenResponse> element the SOAP body should contain
        SOAPBodyElement responseBody = response.getBodyByName(TrustConstants.WST_NS, TrustConstants.RESPONSE_TAG);

        // Construct a Java object from the XML
        RequestSecurityTokenResponse tokenResponse = new RequestSecurityTokenResponse(responseBody.getAsDOM());

        System.out.println("\n------- RequestSecurityTokenResponse object ------------- \n" + tokenResponse);
    }
View Full Code Here

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

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

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

            Object result = null;

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

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

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

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

        // Add a custom element of our own creation
        tokenRequest.addCustomElementNS("http://testElementNs.testElementNs", "te:TestElement");

        // Create a SOAP body and set the XML element of the token request (a <RequestSecurityToken> element)
        // as its only child
        SOAPBodyElement sbe = new SOAPBodyElement(tokenRequest.getElement());

        // Add the body element to the SOAP envelope
        env.addBodyElement(sbe);

        System.out.println("\n============= Request ==============");
        System.out.println(XMLUtils.DocumentToString(env.getAsDocument()));
   
        // This is where we actually invoke the service, sending the request we've constructed
        // Assuming we did everything right, it will return to us a SOAP envelope containing the response
        SOAPEnvelope response = call.invoke(env);

        System.out.println("\n============= Response ==============");
        XMLUtils.PrettyElementToStream(response.getAsDOM(), System.out);
   
        // Find the <RequestSecurityTokenResponse> element the SOAP body should contain
        SOAPBodyElement responseBody = response.getBodyByName(TrustConstants.WST_NS, TrustConstants.RESPONSE_TAG);

        // Construct a Java object from the XML
        RequestSecurityTokenResponse tokenResponse = new RequestSecurityTokenResponse(responseBody.getAsDOM());

        System.out.println("\n------- RequestSecurityTokenResponse object ------------- \n" + tokenResponse);
    }
View Full Code Here

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

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

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

            Object result = null;

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

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

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

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

        setupCall(call);

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

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

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

        SOAPBodyElement body = (SOAPBodyElement) result.elementAt(0);
    }
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.