Examples of ObjectMessageContext


Examples of org.objectweb.celtix.context.ObjectMessageContext

                    opInfo = wsdlCache.getOperationInfo(opName);
                    break;
                }
            }
        }
        ObjectMessageContext objMsgContext = clientBinding.createObjectContext();

        boolean hasInOut = false;
        int inOutCount = 0;
        Object realArgs[] = new Object[args.length];
        if (opInfo.getParamsLength() == 0) {
            //REVISIT - opInfo doesn't return the needed info for the wrapped doc/lit case.
            //Bug in Celtix
            realArgs = args;
        } else {
            for (int x = 0; x < args.length; x++) {
                if (opInfo.getWebParam(x).mode() == Mode.IN) {
                    realArgs[x] = args[x];
                } else {
                    realArgs[x] = new Holder<Object>(args[x]);
                    inOutCount++;
                    hasInOut = true;
                }
            }
        }

        objMsgContext.setMessageObjects(realArgs);

        boolean isOneway = opInfo.isOneWay();
        DataBindingCallback callback = new SCADataBindingCallback(opInfo, typeHelper,
                                                                  wsBinding.getResourceLoader(),
                                                                  hasInOut);

        try {
            if (isOneway) {
                clientBinding.invokeOneWay(objMsgContext,
                        callback);
            } else {
                objMsgContext = clientBinding.invoke(objMsgContext,
                        callback);
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        if (objMsgContext.getException() != null) {
            //REVISIT - Exceptions
            /*
            if (isValidException(objMsgContext)) {
                throw (Exception)objMsgContext.getException();
            } else {
                throw new ProtocolException(objMsgContext.getException());
            }
            */
            throw new ProtocolException(objMsgContext.getException());
        }

        if (hasInOut) {
            Object ret[] = new Object[inOutCount + 1];
            ret[0] = objMsgContext.getReturn();
            inOutCount = 1;
            for (int x = 0; x < args.length; x++) {
                if (opInfo.getWebParam(x).mode() != Mode.IN) {
                    Holder<?> holder = (Holder<?>)realArgs[x];
                    ret[inOutCount] = holder.value;
                    inOutCount++;
                }
            }
            return ret;
        }
        return objMsgContext.getReturn();
    }
View Full Code Here

Examples of org.objectweb.celtix.context.ObjectMessageContext

       
        DataWriter<Node> writer = callback.createWriter(Node.class);
        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        Element element = doc.createElement("ROOT");
       
        ObjectMessageContext objCtx = new ObjectMessageContextImpl();
        objCtx.setMessageObjects(new Object[] {"Hello"});
        writer.writeWrapper(objCtx , false, element);
       
        assertEquals("Value not written", "Hello", element.getFirstChild().getTextContent().trim());
       
        DataReader<Node> reader = callback.createReader(Node.class);
        reader.readWrapper(objCtx , true, element);
       
        assertEquals("Hello", objCtx.getReturn());
    }
View Full Code Here

Examples of org.objectweb.celtix.context.ObjectMessageContext

            corbaCtx.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.TRUE);

            QName operationName = new QName(request.operation());
            corbaCtx.put(MessageContext.WSDL_OPERATION, operationName);

            ObjectMessageContext objectCtx = serverBinding.createObjectContext();
            DataBindingCallback.Mode mode = sbeCallback.getServiceMode();
            DataBindingCallback callback =
                sbeCallback.getDataBindingCallback((QName)corbaCtx.get(MessageContext.WSDL_OPERATION),
                                                   objectCtx,
                                                   mode);
            callback.initObjectContext(objectCtx);
            objectCtx.putAll(corbaCtx);

            // Get the WSDL definition for the operation being invoked
            // TODO: Verify that two operations can't be overloaded.
            OperationType opElement = CorbaUtils.getCorbaOperationType(operationName.getLocalPart(),
                                                                       serverBinding.getBus(),
                                                                       serverBinding.getEndpointReference());
            if (opElement == null) {
                throw new CorbaBindingException("Unable to locate operation type definition");
            }

            List<ParamType> paramTypes = opElement.getParam();
            List<CorbaTypeMap> typeMaps =
                ((CorbaBindingImpl)serverBinding.getBindingImpl()).getCorbaTypeMaps();

            // Build a list of streamables that correspond to the values that should be contained in the
            // argument list of the ServerRequest, build the correct NVList and retreive the arguments
            CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];
            NVList list = prepareDIIArgsList(corbaCtx, objectCtx, arguments, paramTypes, typeMaps, callback);
            request.arguments(list);

            serverBinding.getBindingImpl().unmarshal(corbaCtx, objectCtx, callback);

            boolean isOneWay = callback.isOneWay();
            doCeltixInvocation(callback, objectCtx);

            corbaCtx.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.FALSE);
            if (!isOneWay) {
                if (objectCtx.getException() != null) {
                    serverBinding.getBindingImpl().marshalFault(objectCtx, corbaCtx, callback);
                    Any exAny = orb.create_any();
                    exAny.insert_Streamable(corbaCtx.getMessage().getStreamableException());
                    request.set_exception(exAny);
                } else {
View Full Code Here

Examples of org.objectweb.celtix.context.ObjectMessageContext

                    break;
                }
            }
        }

        ObjectMessageContext objMsgContext = clientBinding.createObjectContext();

        boolean hasInOut = false;
        int inOutCount = 0;
        Object realArgs[];
        Object argsArray[];
        if (args.getClass().isArray()) {
            argsArray = (Object[]) args;
            realArgs = new Object[Array.getLength(args)];
        } else {
            argsArray = new Object[0];
            realArgs = new Object[0];
        }

        if (opInfo.getParamsLength() == 0) {
            // REVISIT - opInfo doesn't return the needed info for the wrapped doc/lit case.
            // Bug in Celtix
            realArgs = argsArray;
        } else {
            for (int x = 0; x < argsArray.length; x++) {
                if (opInfo.getWebParam(x).mode() == WebParam.Mode.IN) {
                    realArgs[x] = argsArray[x];
                } else {
                    realArgs[x] = new Holder<Object>(argsArray[x]);
                    inOutCount++;
                    hasInOut = true;
                }
            }
        }
        objMsgContext.setMessageObjects(realArgs);
        boolean isOneway = opInfo.isOneWay();
        DataBindingCallback callback = new SCADataBindingCallback(opInfo, hasInOut, typeHelper);
        try {
            if (isOneway) {
                clientBinding.invokeOneWay(objMsgContext, callback);
            } else {
                objMsgContext = clientBinding.invoke(objMsgContext, callback);
            }
        } catch (IOException e) {
            throw new InvocationTargetException(e);
        }

        if (objMsgContext.getException() != null) {
            // REVISIT - Exceptions
            /*
             * if (isValidException(objMsgContext)) { throw
             * (Exception)objMsgContext.getException(); } else { throw new
             * ProtocolException(objMsgContext.getException()); }
             */
            throw new InvocationTargetException(objMsgContext.getException());
        }

        if (hasInOut) {
            Object ret[] = new Object[inOutCount + 1];
            ret[0] = objMsgContext.getReturn();
            inOutCount = 1;
            for (int x = 0; x < argsArray.length; x++) {
                if (opInfo.getWebParam(x).mode() != WebParam.Mode.IN) {
                    Holder<?> holder = (Holder<?>) realArgs[x];
                    ret[inOutCount] = holder.value;
                    inOutCount++;
                }
            }
            return ret;
        }
        return objMsgContext.getReturn();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.