Package javax.jws

Examples of javax.jws.WebResult


                getLocation("/wsdl2java_wsdl/cxf2944/cxf2944.wsdl"));
        env.put(ToolConstants.CFG_ALLOW_ELEMENT_REFS, "true");
        processor.setContext(env);
        processor.execute();
        Class<?> clz = classLoader.loadClass("org.apache.cxf.tools.fortest.cxf2944.WebResultService");
        WebResult webResult = AnnotationUtil.getWebResult(clz.getMethods()[0]);
        assertEquals("hello/name", webResult.targetNamespace());
        assertEquals("name", webResult.name());     
    }
View Full Code Here


    }

    @Override
    public String getResponseWrapperPartName(OperationInfo op, Method method) {
        method = getDeclaredMethod(method);
        WebResult webResult = getWebResult(method);
        ResponseWrapper rw = method.getAnnotation(ResponseWrapper.class);
        if (rw != null) {
            String pn = getWithReflection(ResponseWrapper.class, rw, "partName");
            if (pn != null) {
                return pn;
            }
        }
        int countOut = 0;
        int countHeaders = 0;
       
        if (webResult != null
            && webResult.header()) {
            countHeaders++;
        } else if (method.getReturnType() != Void.TYPE) {
            countOut++;
        }
       
View Full Code Here

        method = getDeclaredMethod(method);
       
        if (paramNumber >= 0) {
            return getParameterName(op, method, paramNumber, op.getOutput().size(), "return", false);
        } else {
            WebResult webResult = getWebResult(method);

            String tns = null;
            String local = null;
            if (webResult != null) {
                tns = webResult.targetNamespace();
                local = webResult.name();
            }
            if (tns == null || tns.length() == 0) {
                QName wrappername = getResponseWrapperName(op, method);
                if (wrappername != null) {
                    tns = wrappername.getNamespaceURI();
View Full Code Here

        method = getDeclaredMethod(method);
       
        if (paramNumber >= 0) {
            return getPartName(op, method, paramNumber, op.getOutput(), "return", false);
        } else {
            WebResult webResult = getWebResult(method);
            String tns = op.getOutput().getName().getNamespaceURI();
            String local = null;
            if (webResult != null) {
                if (Boolean.TRUE.equals(isRPC(method)) || isDocumentBare(method)) {
                    local = webResult.partName();
                }
                if (local == null || local.length() == 0) {
                    local = webResult.name();
                }
            }

            if (local == null || local.length() == 0) {
                if (Boolean.TRUE.equals(isRPC(method)) || !Boolean.FALSE.equals(isWrapped(method))) {
View Full Code Here

        method = getDeclaredMethod(method);
        if (j >= 0) {
            WebParam webParam = getWebParam(method, j);
            return webParam != null && webParam.header();
        } else {
            WebResult webResult = getWebResult(method);
            return webResult != null && webResult.header();
        }
    }
View Full Code Here

                        if (logical instanceof XMLType) {
                            ((XMLType)logical).setElementName(element);
                        }
                    }
                }
                WebResult result = method.getAnnotation(WebResult.class);
                if (result != null) {
                    QName element = new QName(result.targetNamespace(), result.name());
                    Object logical = operation.getOutputType().getLogical();
                    if (logical instanceof XMLType) {
                        ((XMLType)logical).setElementName(element);
                    }
                }
            }

            String operationName = getValue(webMethod.operationName(), operation.getName());
            operation.setName(operationName);

            RequestWrapper requestWrapper = method.getAnnotation(RequestWrapper.class);
            ResponseWrapper responseWrapper = method.getAnnotation(ResponseWrapper.class);
            if (requestWrapper == null) {
                continue;
            }

            String ns = getValue(requestWrapper.targetNamespace(), tns);
            String name = getValue(requestWrapper.localName(), operationName);
            QName inputWrapper = new QName(ns, name);

            ns = getValue(responseWrapper.targetNamespace(), tns);
            name = getValue(responseWrapper.localName(), operationName + "Response");

            QName outputWrapper = new QName(ns, name);

            List<ElementInfo> inputElements = new ArrayList<ElementInfo>();
            for (int i = 0; i < method.getParameterTypes().length; i++) {
                WebParam param = getAnnotation(method, i, WebParam.class);
                assert param != null;
                inputElements.add(new ElementInfo(new QName(param.targetNamespace(), param.name()), null));
            }

            List<ElementInfo> outputElements = new ArrayList<ElementInfo>();
            WebResult result = method.getAnnotation(WebResult.class);
            outputElements.add(new ElementInfo(new QName(result.targetNamespace(), result.name()), null));

            WrapperInfo wrapperInfo =
                new WrapperInfo(JAXB_DATABINDING, new ElementInfo(inputWrapper, null), new ElementInfo(outputWrapper,
                                                                                                       null),
                                inputElements, outputElements);
View Full Code Here

                        operation.getParameterModes().set(i, getParameterMode(param.mode()));
                    }
                    ParameterMode mode = operation.getParameterModes().get(i);
                }
       
                WebResult result = method.getAnnotation(WebResult.class);
                if (result != null) {
                    String ns = getValue(result.targetNamespace(), tns);
                    // Default to <operationName>Response for doc-bare
                    String name = getValue(result.name(), documentStyle ? operationName + "Response" : "return");
                    QName element = new QName(ns, name);
                    if (!operation.hasReturnTypeVoid()) {
                        List<DataType> outputDataTypes = operation.getOutputType().getLogical();                   
                        DataType returnDataType = outputDataTypes.get(0);
                        if (returnDataType instanceof XMLType) {
                            ((XMLType)returnDataType).setElementName(element);
                        }
                    }
                }
                // Rather than relying on null wrapper, we use a flag with a clearer meaning.
                operation.setNotSubjectToWrapping(true);
            } else {

                RequestWrapper requestWrapper = method.getAnnotation(RequestWrapper.class);
                String ns = requestWrapper == null ? tns : getValue(requestWrapper.targetNamespace(), tns);
                String name =
                    requestWrapper == null ? operationName : getValue(requestWrapper.localName(), operationName);
                String wrapperBeanName = requestWrapper == null ? "" : requestWrapper.className();
                if ("".equals(wrapperBeanName)) {
                    wrapperBeanName = CodeGenerationHelper.getPackagePrefix(clazz) + capitalize(method.getName());
                }

                DataType<XMLType> inputWrapperDT = null;

                final String inputWrapperClassName = wrapperBeanName;
                final String inputNS = ns;
                final String inputName = name;
                inputWrapperDT = AccessController.doPrivileged(new PrivilegedAction<DataType<XMLType>>() {
                    public DataType<XMLType> run() {
                        try {
                            Class<?> wrapperClass = Class.forName(inputWrapperClassName, false, clazz.getClassLoader());
                            QName qname = new QName(inputNS, inputName);
                            DataType dt = new DataTypeImpl<XMLType>(wrapperClass, new XMLType(qname, qname));
                            dataBindingExtensionPoint.introspectType(dt, operation);
                            // TUSCANY-2505
                            if (dt.getLogical() instanceof XMLType) {
                                XMLType xmlType = (XMLType)dt.getLogical();
                                xmlType.setElementName(qname);
                            }
                            return dt;
                        } catch (ClassNotFoundException e) {
                            GeneratedClassLoader cl = new GeneratedClassLoader(clazz.getClassLoader());
                            return new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, method, inputWrapperClassName, inputNS, inputName, true,
                                                             cl);
                        }
                    }
                });

                QName inputWrapper = inputWrapperDT.getLogical().getElementName();

                ResponseWrapper responseWrapper = method.getAnnotation(ResponseWrapper.class);
                ns = responseWrapper == null ? tns : getValue(responseWrapper.targetNamespace(), tns);
                name =
                    responseWrapper == null ? operationName + "Response" : getValue(responseWrapper.localName(),
                                                                                    operationName + "Response");
                wrapperBeanName = responseWrapper == null ? "" : responseWrapper.className();
                if ("".equals(wrapperBeanName)) {
                    wrapperBeanName =
                        CodeGenerationHelper.getPackagePrefix(clazz) + capitalize(method.getName()) + "Response";
                }

                DataType<XMLType> outputWrapperDT = null;
                final String outputWrapperClassName = wrapperBeanName;
                final String outputNS = ns;
                final String outputName = name;

                outputWrapperDT = AccessController.doPrivileged(new PrivilegedAction<DataType<XMLType>>() {
                    public DataType<XMLType> run() {
                        try {
                            Class<?> wrapperClass =
                                Class.forName(outputWrapperClassName, false, clazz.getClassLoader());
                            QName qname = new QName(outputNS, outputName);
                            DataType dt = new DataTypeImpl<XMLType>(wrapperClass, new XMLType(qname, qname));
                            dataBindingExtensionPoint.introspectType(dt, operation);
                            // TUSCANY-2505
                            if (dt.getLogical() instanceof XMLType) {
                                XMLType xmlType = (XMLType)dt.getLogical();
                                xmlType.setElementName(qname);
                            }
                            return dt;
                        } catch (ClassNotFoundException e) {
                            GeneratedClassLoader cl = new GeneratedClassLoader(clazz.getClassLoader());
                            return new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, method, outputWrapperClassName, outputNS, outputName,
                                                             false, cl);
                        }
                    }
                });
                QName outputWrapper = outputWrapperDT.getLogical().getElementName();

               
                //
                // Since JAX-WS specifies that the output wrapper bean consists of the return type output first followed
                // by any other outputs carried in Holder(s), let's look at the output first.
                //
                List<ElementInfo> outputElements = new ArrayList<ElementInfo>();
                WebResult result = method.getAnnotation(WebResult.class);
                // Default to "" for doc-lit-wrapped && non-header
                ns = result != null ? result.targetNamespace() : "";
                ns = getValue(ns, documentStyle && (result == null || !result.header()) ? "" : tns);
                name = result != null ? result.name() : "";
                name = getValue(name, "return");
                QName element = new QName(ns, name);

                if (!operation.hasReturnTypeVoid()) {
                    Object logical = operation.getOutputType().getLogical().get(0).getLogical();
View Full Code Here

        ResponseWrapper resposneWrapperAnn = AnnotationUtil.getPrivMethodAnnotation(method,
                                                                                    ResponseWrapper.class);

        assertEquals("sayHiResponse", resposneWrapperAnn.localName());

        WebResult webResultAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);

        assertEquals("responseType", webResultAnno.name());

        method = clz.getMethod("pingMe", new Class[] {});
        webMethodAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebMethod.class);
        if (webMethodAnno.operationName() != null
            && !"".equals(webMethodAnno.operationName())) {
View Full Code Here

        ResponseWrapper resposneWrapperAnn = AnnotationUtil.getPrivMethodAnnotation(method,
                                                                                    ResponseWrapper.class);

        assertEquals("sayHiResponse", resposneWrapperAnn.localName());

        WebResult webResultAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);

        assertEquals("responseType", webResultAnno.name());

        method = clz.getMethod("greetMe", new Class[] {String.class});
        assertEquals("String", method.getReturnType().getSimpleName());
        WebParam webParamAnn = AnnotationUtil.getWebParam(method, "requestType");
        //if is wrapped, tns should be empty
        assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http/types", webParamAnn.targetNamespace());
        //assertEquals("", webParamAnn.targetNamespace());
        method = clz.getMethod("greetMeOneWay", new Class[] {String.class});
        Oneway oneWayAnn = AnnotationUtil.getPrivMethodAnnotation(method, Oneway.class);
        assertNotNull("OneWay Annotation is not generated", oneWayAnn);
        assertEquals("void", method.getReturnType().getSimpleName());

        method = clz.getMethod("greetMeSometime", new Class[] {String.class});
        assertEquals("String", method.getReturnType().getSimpleName());

        method = clz.getMethod("testDocLitFault", new Class[] {java.lang.String.class});
        assertEquals("void", method.getReturnType().getSimpleName());
        assertEquals("Exception class is not generated ", 2, method.getExceptionTypes().length);

        method = clz.getMethod("testDocLitBare", new Class[] {java.lang.String.class});
        webResultAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);
        assertEquals("out", webResultAnno.partName());
        SOAPBinding soapBindingAnno = AnnotationUtil.getPrivMethodAnnotation(method, SOAPBinding.class);
        assertNotNull(soapBindingAnno);
        assertEquals(SOAPBinding.ParameterStyle.BARE, soapBindingAnno.parameterStyle());
        assertEquals("BareDocumentResponse", method.getReturnType().getSimpleName());
View Full Code Here

        Class<?> clz = classLoader.loadClass("org.apache.locator.LocatorService");

        Class<?> paraClass = classLoader.loadClass("org.apache.locator.types.QueryEndpoints");
        Method method = clz.getMethod("queryEndpoints", new Class[] {paraClass});
        WebResult webRes = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);
        assertEquals("http://apache.org/locator/types", webRes.targetNamespace());
        assertEquals("queryEndpointsResponse", webRes.name());
        WebParam webParamAnn = AnnotationUtil.getWebParam(method, "queryEndpoints");
        assertEquals("http://apache.org/locator/types", webParamAnn.targetNamespace());

        method = clz.getMethod("deregisterPeerManager", new Class[] {String.class});
        webParamAnn = AnnotationUtil.getWebParam(method, "node_id");
View Full Code Here

TOP

Related Classes of javax.jws.WebResult

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.