Search in sources :

Example 26 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class WSDLServiceBuilderTest method assertPortTypeOperationMessageExtensions.

private void assertPortTypeOperationMessageExtensions(OperationInfo oi, boolean expectExtensions, boolean hasOutput, QName fault) {
    MessageInfo mi = oi.getInput();
    if (expectExtensions) {
        assertEquals(1, mi.getExtensionAttributes().size());
        assertNotNull(mi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertEquals(1, mi.getExtensors(UnknownExtensibilityElement.class).size());
        assertEquals(EXTENSION_ELEM, mi.getExtensor(UnknownExtensibilityElement.class).getElementType());
    } else {
        assertNull(mi.getExtensionAttributes());
        assertNull(mi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertNull(mi.getExtensors(UnknownExtensibilityElement.class));
        assertNull(mi.getExtensor(UnknownExtensibilityElement.class));
    }
    if (hasOutput) {
        mi = oi.getOutput();
        if (expectExtensions) {
            assertEquals(1, mi.getExtensionAttributes().size());
            assertNotNull(mi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertEquals(1, mi.getExtensors(UnknownExtensibilityElement.class).size());
            assertEquals(EXTENSION_ELEM, mi.getExtensor(UnknownExtensibilityElement.class).getElementType());
        } else {
            assertNull(mi.getExtensionAttributes());
            assertNull(mi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertNull(mi.getExtensors(UnknownExtensibilityElement.class));
            assertNull(mi.getExtensor(UnknownExtensibilityElement.class));
        }
    }
    if (null != fault) {
        FaultInfo fi = oi.getFault(fault);
        if (expectExtensions) {
            assertEquals(1, fi.getExtensionAttributes().size());
            assertNotNull(fi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertEquals(1, fi.getExtensors(UnknownExtensibilityElement.class).size());
            assertEquals(EXTENSION_ELEM, fi.getExtensor(UnknownExtensibilityElement.class).getElementType());
        } else {
            assertNull(fi.getExtensionAttributes());
            assertNull(fi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertNull(fi.getExtensors(UnknownExtensibilityElement.class));
            assertNull(fi.getExtensor(UnknownExtensibilityElement.class));
        }
    }
}
Also used : BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 27 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class ReflectionServiceFactoryBean method buildServiceFromClass.

protected void buildServiceFromClass() {
    Object o = getBus().getProperty("requireExplicitContractLocation");
    if (o != null && ("true".equals(o) || Boolean.TRUE.equals(o))) {
        throw new ServiceConstructionException(new Message("NO_WSDL_PROVIDED", LOG, getServiceClass().getName()));
    }
    if (LOG.isLoggable(Level.INFO)) {
        LOG.info("Creating Service " + getServiceQName() + " from class " + getServiceClass().getName());
    }
    populateFromClass = true;
    if (Proxy.isProxyClass(this.getServiceClass())) {
        LOG.log(Level.WARNING, "USING_PROXY_FOR_SERVICE", getServiceClass());
    }
    sendEvent(Event.CREATE_FROM_CLASS, getServiceClass());
    ServiceInfo serviceInfo = new ServiceInfo();
    SchemaCollection col = serviceInfo.getXmlSchemaCollection();
    col.getXmlSchemaCollection().setSchemaResolver(new CatalogXmlSchemaURIResolver(this.getBus()));
    col.getExtReg().registerSerializer(MimeAttribute.class, new MimeSerializer());
    ServiceImpl service = new ServiceImpl(serviceInfo);
    setService(service);
    setServiceProperties();
    serviceInfo.setName(getServiceQName());
    serviceInfo.setTargetNamespace(serviceInfo.getName().getNamespaceURI());
    sendEvent(Event.SERVICE_SET, getService());
    createInterface(serviceInfo);
    Set<?> wrapperClasses = this.getExtraClass();
    for (ServiceInfo si : getService().getServiceInfos()) {
        if (wrapperClasses != null && !wrapperClasses.isEmpty()) {
            si.setProperty(EXTRA_CLASS, wrapperClasses);
        }
    }
    initializeDataBindings();
    boolean isWrapped = isWrapped() || hasWrappedMethods(serviceInfo.getInterface());
    if (isWrapped) {
        initializeWrappedSchema(serviceInfo);
    }
    for (OperationInfo opInfo : serviceInfo.getInterface().getOperations()) {
        Method m = (Method) opInfo.getProperty(METHOD);
        if (!isWrapped(m) && !isRPC(m) && opInfo.getInput() != null) {
            createBareMessage(serviceInfo, opInfo, false);
        }
        if (!isWrapped(m) && !isRPC(m) && opInfo.getOutput() != null) {
            createBareMessage(serviceInfo, opInfo, true);
        }
        if (opInfo.hasFaults()) {
            // check to make sure the faults are elements
            for (FaultInfo fault : opInfo.getFaults()) {
                QName qn = (QName) fault.getProperty("elementName");
                MessagePartInfo part = fault.getFirstMessagePart();
                if (!part.isElement()) {
                    part.setElement(true);
                    part.setElementQName(qn);
                    checkForElement(serviceInfo, part);
                }
            }
        }
    }
    if (LOG.isLoggable(Level.FINE) || isValidate()) {
        ServiceModelSchemaValidator validator = new ServiceModelSchemaValidator(serviceInfo);
        validator.walk();
        String validationComplaints = validator.getComplaints();
        if (!"".equals(validationComplaints)) {
            if (isValidate()) {
                LOG.warning(validationComplaints);
            } else {
                LOG.fine(validationComplaints);
            }
        }
    }
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) UnwrappedOperationInfo(org.apache.cxf.service.model.UnwrappedOperationInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) Message(org.apache.cxf.common.i18n.Message) ServiceImpl(org.apache.cxf.service.ServiceImpl) QName(javax.xml.namespace.QName) ServiceModelSchemaValidator(org.apache.cxf.service.ServiceModelSchemaValidator) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) Method(java.lang.reflect.Method) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) MimeSerializer(org.apache.cxf.databinding.source.mime.MimeSerializer) CatalogXmlSchemaURIResolver(org.apache.cxf.catalog.CatalogXmlSchemaURIResolver) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection)

Aggregations

FaultInfo (org.apache.cxf.service.model.FaultInfo)27 QName (javax.xml.namespace.QName)12 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)11 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)11 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)11 OperationInfo (org.apache.cxf.service.model.OperationInfo)10 MessageInfo (org.apache.cxf.service.model.MessageInfo)8 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)7 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 Service (org.apache.cxf.service.Service)3 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)3 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)3 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 BindingFault (javax.wsdl.BindingFault)2 Fault (javax.wsdl.Fault)2 Input (javax.wsdl.Input)2 Output (javax.wsdl.Output)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2