Package org.apache.cxf.service.factory

Examples of org.apache.cxf.service.factory.ServiceConstructionException


    }

    protected void initializeWSDLOperationsForProvider() {
        Class<?> c = getProviderParameterType(getServiceClass());
        if (c == null) {
            throw new ServiceConstructionException(new Message("INVALID_PROVIDER_EXC", LOG));
        }

        if (getEndpointInfo() == null
            && isFromWsdl()) {
            //most likely, they specified a WSDL, but for some reason
            //did not give a valid ServiceName/PortName.  For provider,
            //we'll allow this since everything is bound directly to
            //the invoke method, however, this CAN cause other problems
            //such as addresses in the wsdl not getting updated and such
            //so we'll WARN about it.....
            List<QName> enames = new ArrayList<QName>();
            for (ServiceInfo si : getService().getServiceInfos()) {
                for (EndpointInfo ep : si.getEndpoints()) {
                    enames.add(ep.getName());
                }
            }
            LOG.log(Level.WARNING, "COULD_NOT_FIND_ENDPOINT",
                    new Object[] {getEndpointName(), enames});
        }

        try {
            Method invoke = getServiceClass().getMethod("invoke", c);
            QName catchAll = new QName("http://cxf.apache.org/jaxws/provider", "invoke");

            // Bind every operation to the invoke method.
            for (ServiceInfo si : getService().getServiceInfos()) {
                si.setProperty("soap.force.doclit.bare", Boolean.TRUE);
                if (!isFromWsdl()) {
                    for (EndpointInfo ei : si.getEndpoints()) {
                        ei.setProperty("soap.no.validate.parts", Boolean.TRUE);
                    }
                }
                for (BindingInfo bind : si.getBindings()) {
                    for (BindingOperationInfo bop : bind.getOperations()) {
                        OperationInfo o = bop.getOperationInfo();
                        if (bop.isUnwrappedCapable()) {
                            //force to bare, no unwrapping
                            bop.getOperationInfo().setUnwrappedOperation(null);
                            bop.setUnwrappedOperation(null);
                        }
                        if (o.getInput() != null) {
                            if (o.getInput().getMessageParts().isEmpty()) {
                                MessagePartInfo inf = o.getInput().addMessagePart(o.getName());
                                inf.setConcreteName(o.getName());
                                bop.getInput().setMessageParts(o.getInput().getMessageParts());
                            }
                            for (MessagePartInfo inf : o.getInput().getMessageParts()) {
                                inf.setTypeClass(c);
                                break;
                            }
                        }
                        if (o.getOutput() != null) {
                            if (o.getOutput().getMessageParts().isEmpty()) {
                                MessagePartInfo inf = o.getOutput().addMessagePart(o.getName());
                                inf.setConcreteName(new QName(o.getName().getNamespaceURI(),
                                                              o.getName().getLocalPart() + "Response"));
                                bop.getOutput().setMessageParts(o.getOutput().getMessageParts());
                            }
                            for (MessagePartInfo inf : o.getOutput().getMessageParts()) {
                                inf.setTypeClass(c);
                                break;
                            }
                        }
                        getMethodDispatcher().bind(o, invoke);
                    }
                    BindingOperationInfo bop = bind.getOperation(catchAll);
                    if (bop == null) {
                        OperationInfo op = bind.getInterface().getOperation(catchAll);
                        if (op == null) {
                            op = bind.getInterface().addOperation(catchAll);
                            String name = catchAll.getLocalPart();
                            MessageInfo mInfo = op.createMessage(new QName(catchAll.getNamespaceURI(),
                                                                           name + "Request"),
                                                                           MessageInfo.Type.INPUT);
                            op.setInput(catchAll.getLocalPart() + "Request", mInfo);
                            MessagePartInfo mpi = mInfo.addMessagePart("parameters");
                            mpi.setElement(true);
                            mpi.setTypeClass(c);
                            mpi.setTypeQName(XMLSchemaQNames.XSD_ANY);

                            mInfo = op.createMessage(new QName(catchAll.getNamespaceURI(),
                                                               name + "Response"),
                                                               MessageInfo.Type.OUTPUT);
                            op.setOutput(name + "Response", mInfo);
                            mpi = mInfo.addMessagePart("parameters");
                            mpi.setElement(true);
                            mpi.setTypeClass(c);
                            mpi.setTypeQName(XMLSchemaQNames.XSD_ANY);

                            BindingOperationInfo bo = new BindingOperationInfo(bind, op);
                            op.setProperty("operation.is.synthetic", Boolean.TRUE);
                            bo.setProperty("operation.is.synthetic", Boolean.TRUE);
                            bind.addOperation(bo);
                        }
                    }
                }
            }
        } catch (SecurityException e) {
            throw new ServiceConstructionException(e);
        } catch (NoSuchMethodException e) {
            throw new ServiceConstructionException(e);
        }


    }
View Full Code Here


            Method getFaultInfo = exClass.getMethod("getFaultInfo", new Class[0]);

            return getFaultInfo.getReturnType();
        } catch (SecurityException e) {
            throw new ServiceConstructionException(e);
        } catch (NoSuchMethodException e) {
            //ignore for now
        }
        WebFault fault = exClass.getAnnotation(WebFault.class);
        if (fault != null && !StringUtils.isEmpty(fault.faultBean())) {
View Full Code Here

    private Method getDeclaredMethod(Class<?> endpointClass, Method method) {
        if (!method.getDeclaringClass().equals(endpointClass)) {
            try {
                method = endpointClass.getMethod(method.getName(), method.getParameterTypes());
            } catch (SecurityException e) {
                throw new ServiceConstructionException(e);
            } catch (NoSuchMethodException e) {
                return isWebMethod(method) ? method : null;
            }
        }
        return method;
View Full Code Here

           
            if (start) {
                server.start();
            }
        } catch (EndpointException e) {
            throw new ServiceConstructionException(e);
        } catch (BusException e) {
            throw new ServiceConstructionException(e);
        } catch (IOException e) {
            throw new ServiceConstructionException(e);
        } catch (Exception e) {
            throw new ServiceConstructionException(e);
        }

        applyFeatures();
        return server;
    }
View Full Code Here

            URIResolver resolver = new URIResolver(null, s, getClass());

            if (resolver.isResolved()) {
                return resolver.getURI().toURL();
            } else {
                throw new ServiceConstructionException(new Message("COULD_NOT_RESOLVE_URL", LOG, s));
            }
        } catch (IOException e) {
            throw new ServiceConstructionException(new Message("COULD_NOT_RESOLVE_URL", LOG, s), e);
        }
    }
View Full Code Here

                    added = addJaxbObjectFactory(e1);
                }
            }

            if (ctx == null) {
                throw new ServiceConstructionException(e1);
            } else {
                synchronized (JAXBCONTEXT_CACHE) {
                    JAXBCONTEXT_CACHE.put(contextClasses, cachedContextAndSchemas);
                }               
            }
        }
        ctx = cachedContextAndSchemas.getContext();
        if (LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, "CREATED_JAXB_CONTEXT", new Object[] {ctx, contextClasses});
        }
        setContext(ctx);

        for (ServiceInfo serviceInfo : service.getServiceInfos()) {
            SchemaCollection col = serviceInfo.getXmlSchemaCollection();

            if (col.getXmlSchemas().length > 1) {
                // someone has already filled in the types
                continue;
            }

            boolean schemasFromCache = false;
            Collection<DOMSource> schemas = getSchemas();
            if (schemas == null) {
                schemas = cachedContextAndSchemas.getSchemas();
                if (schemas != null) {
                    schemasFromCache = true;
                }
            } else {
                schemasFromCache = true;
            }
            Set<DOMSource> bi = new LinkedHashSet<DOMSource>();
            if (schemas == null) {
                schemas = new LinkedHashSet<DOMSource>();
                try {
                    for (DOMResult r : generateJaxbSchemas()) {
                        DOMSource src = new DOMSource(r.getNode(), r.getSystemId());
                        if (BUILT_IN_SCHEMAS.containsValue(r)) {
                            bi.add(src);
                        } else {
                            schemas.add(src);                           
                        }
                    }
                    //put any builtins at the end.   Anything that DOES import them
                    //will cause it to load automatically and we'll skip them later
                    schemas.addAll(bi);
                } catch (IOException e) {
                    throw new ServiceConstructionException(new Message("SCHEMA_GEN_EXC", LOG), e);
                }
            }
            for (DOMSource r : schemas) {
                if (bi.contains(r)) {
                    String ns = ((Document)r.getNode()).getDocumentElement().getAttribute("targetNamespace");
                    if (serviceInfo.getSchema(ns) != null) {
                        continue;
                    }
                }
                addSchemaDocument(serviceInfo,
                                  col,
                                 (Document)r.getNode(),
                                  r.getSystemId());
            }

            JAXBContext riContext;
            if (context.getClass().getName().contains("com.sun.xml.")) {
                riContext = context;
            } else {
                // fall back if we're using another jaxb implementation
                try {
                    riContext = JAXBUtils.createRIContext(contextClasses
                        .toArray(new Class[contextClasses.size()]), tns);
                } catch (JAXBException e) {
                    throw new ServiceConstructionException(e);
                }
            }

            JAXBSchemaInitializer schemaInit = new JAXBSchemaInitializer(serviceInfo, col, riContext,
                                                                         this.qualifiedSchemas);
View Full Code Here

    private Method getDeclaredMethod(Class<?> endpointClass, Method method) {
        if (!method.getDeclaringClass().equals(endpointClass)) {
            try {
                method = endpointClass.getMethod(method.getName(), (Class[])method.getParameterTypes());
            } catch (SecurityException e) {
                throw new ServiceConstructionException(e);
            } catch (NoSuchMethodException e) {
                return isWebMethod(method) ? method : null;
            }
        }
        return method;
View Full Code Here

                                   asyncHandlerParams.toArray(new Class<?>[asyncHandlerParams.size()]));

            getMethodDispatcher().bind(o, method, responseMethod, futureMethod);

        } catch (SecurityException e) {
            throw new ServiceConstructionException(e);
        } catch (NoSuchMethodException e) {
            getMethodDispatcher().bind(o, method);
        }

        // rpc out-message-part-info class mapping
View Full Code Here

                for (BindingInfo bi : si.getBindings()) {
                    bi.setProperty(AbstractBindingFactory.DATABINDING_DISABLED, Boolean.TRUE);
                }
            }
        } catch (SecurityException e) {
            throw new ServiceConstructionException(e);
        } catch (NoSuchMethodException e) {
            throw new ServiceConstructionException(e);
        }

       
    }
View Full Code Here

            Method getFaultInfo = exClass.getMethod("getFaultInfo", new Class[0]);

            return getFaultInfo.getReturnType();
        } catch (SecurityException e) {
            throw new ServiceConstructionException(e);
        } catch (NoSuchMethodException e) {
            //ignore for now
        }
        WebFault fault = exClass.getAnnotation(WebFault.class);
        if (fault != null && !StringUtils.isEmpty(fault.faultBean())) {
View Full Code Here

TOP

Related Classes of org.apache.cxf.service.factory.ServiceConstructionException

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.