Search in sources :

Example 1 with Fault

use of javax.wsdl.Fault in project carbon-business-process by wso2.

the class SOAPUtils method buildSoapDetail.

private static OMElement buildSoapDetail(final BPELMessageContext bpelMessageContext, final MessageExchange odeMessageContext) throws AxisFault {
    Element message = odeMessageContext.getResponse().getMessage();
    QName faultName = odeMessageContext.getFault();
    Operation operation = odeMessageContext.getOperation();
    SOAPFactory soapFactory = bpelMessageContext.getSoapFactoryForCurrentMessageFlow();
    if (faultName.getNamespaceURI() == null) {
        return toFaultDetail(message, soapFactory);
    }
    Fault f = operation.getFault(faultName.getLocalPart());
    if (f == null) {
        return toFaultDetail(message, soapFactory);
    }
    // For faults, there will be exactly one part.
    Part p = (Part) f.getMessage().getParts().values().iterator().next();
    if (p == null) {
        return toFaultDetail(message, soapFactory);
    }
    Element partEl = DOMUtils.findChildByName(message, new QName(null, p.getName()));
    if (partEl == null) {
        return toFaultDetail(message, soapFactory);
    }
    Element detail = DOMUtils.findChildByName(partEl, p.getElementName());
    if (detail == null) {
        return toFaultDetail(message, soapFactory);
    }
    return OMUtils.toOM(detail, soapFactory);
}
Also used : QName(javax.xml.namespace.QName) Part(javax.wsdl.Part) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) SOAPFault(org.apache.axiom.soap.SOAPFault) Fault(javax.wsdl.Fault) AxisFault(org.apache.axis2.AxisFault) BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) SOAPFactory(org.apache.axiom.soap.SOAPFactory)

Example 2 with Fault

use of javax.wsdl.Fault in project tesb-studio-se by Talend.

the class PublishMetadataRunnable method process.

@SuppressWarnings("unchecked")
private void process(Definition wsdlDefinition, Collection<XmlFileConnectionItem> selectTables) throws Exception, CoreException {
    List<IFile> tempFiles = new ArrayList<IFile>();
    try {
        File wsdlFile = null;
        String baseUri = wsdlDefinition.getDocumentBaseURI();
        URI uri = new URI(baseUri);
        if ("file".equals(uri.getScheme())) {
            wsdlFile = new File(uri.toURL().getFile());
        } else {
            Map<String, InputStream> load = new WSDLLoader().load(baseUri, "tempWsdl" + "%d.wsdl");
            InputStream inputStream = load.remove(WSDLLoader.DEFAULT_FILENAME);
            String name = File.createTempFile("tESBConsumer", ".wsdl").getName();
            IFile tempWsdlFile = createTempFile(name, inputStream);
            tempFiles.add(tempWsdlFile);
            wsdlFile = new File(tempWsdlFile.getLocation().toPortableString());
            // TESB-19040:save import wsdl files
            if (!load.isEmpty()) {
                for (Map.Entry<String, InputStream> importWsdl : load.entrySet()) {
                    tempFiles.add(createTempFile(importWsdl.getKey(), importWsdl.getValue()));
                }
            }
        }
        if (populationUtil == null) {
            populationUtil = new WSDLPopulationUtil();
            populationUtil.loadWSDL("file://" + wsdlFile.getAbsolutePath());
        }
        final Set<QName> portTypes = new HashSet<QName>();
        final Set<QName> alreadyCreated = new HashSet<QName>();
        for (Binding binding : (Collection<Binding>) wsdlDefinition.getAllBindings().values()) {
            final QName portType = binding.getPortType().getQName();
            if (portTypes.add(portType)) {
                for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) {
                    Operation oper = operation.getOperation();
                    Input inDef = oper.getInput();
                    if (inDef != null) {
                        Message inMsg = inDef.getMessage();
                        if (inMsg != null) {
                            // fix for TDI-20699
                            List<QName> messageParts = getMessageParts(inMsg);
                            if (messageParts.isEmpty()) {
                                continue;
                            }
                            for (QName messagePart : messageParts) {
                                if (alreadyCreated.add(messagePart)) {
                                    XsdMetadataUtils.createMetadataFromXSD(messagePart, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
                                }
                            }
                        }
                    }
                    Output outDef = oper.getOutput();
                    if (outDef != null) {
                        Message outMsg = outDef.getMessage();
                        if (outMsg != null) {
                            List<QName> messageParts = getMessageParts(outMsg);
                            if (messageParts.isEmpty()) {
                                continue;
                            }
                            for (QName messagePart : messageParts) {
                                if (alreadyCreated.add(messagePart)) {
                                    XsdMetadataUtils.createMetadataFromXSD(messagePart, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
                                }
                            }
                        }
                    }
                    for (Fault fault : (Collection<Fault>) oper.getFaults().values()) {
                        Message faultMsg = fault.getMessage();
                        if (faultMsg != null) {
                            List<QName> messageParts = getMessageParts(faultMsg);
                            if (messageParts.isEmpty()) {
                                continue;
                            }
                            for (QName messagePart : messageParts) {
                                if (alreadyCreated.add(messagePart)) {
                                    XsdMetadataUtils.createMetadataFromXSD(messagePart, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
                                }
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        throw e;
    } finally {
        for (IFile tempFile : tempFiles) {
            tempFile.delete(true, null);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) Message(javax.wsdl.Message) ArrayList(java.util.ArrayList) Fault(javax.wsdl.Fault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) URI(java.net.URI) BindingOperation(javax.wsdl.BindingOperation) Input(javax.wsdl.Input) WSDLPopulationUtil(org.talend.repository.services.utils.WSDLPopulationUtil) Output(javax.wsdl.Output) WSDLLoader(org.talend.utils.wsdl.WSDLLoader) HashSet(java.util.HashSet) Binding(javax.wsdl.Binding) InputStream(java.io.InputStream) QName(javax.xml.namespace.QName) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) Collection(java.util.Collection) IFile(org.eclipse.core.resources.IFile) File(java.io.File) Map(java.util.Map)

Example 3 with Fault

use of javax.wsdl.Fault in project tomee by apache.

the class HeavyweightOperationInfoBuilder method buildOperationInfo.

public JaxRpcOperationInfo buildOperationInfo() throws OpenEJBException {
    if (operationInfo != null) {
        return operationInfo;
    }
    operationInfo = new JaxRpcOperationInfo();
    operationInfo.name = operationName;
    // Binding style rpc/encoded, doc/lit, wrapped, etc.
    operationInfo.bindingStyle = bindingStyle;
    // Operation style one way, request response, etc/
    operationInfo.operationStyle = operationStyle;
    // Java method name
    operationInfo.javaMethodName = methodMapping.getJavaMethodName();
    // 
    // Map the parameters
    // 
    mapParameters();
    // 
    if (methodMapping.getWsdlReturnValueMapping() != null) {
        mapReturnType();
    }
    // Validate output mapping is complete
    if (outputMessage != null && bindingStyle.isWrapped()) {
        Part inputPart = getWrappedPart(outputMessage);
        QName wrapperName = inputPart.getElementName();
        XmlElementInfo wraperElement = schemaInfo.elements.get(wrapperName);
        XmlTypeInfo wrapperType = schemaInfo.types.get(wraperElement.xmlType);
        Set<String> expectedOutParams = new HashSet<>();
        for (XmlElementInfo expectedOutParam : wrapperType.elements.values()) {
            expectedOutParams.add(expectedOutParam.qname.getLocalPart());
        }
        if (!outParamNames.equals(expectedOutParams)) {
            throw new OpenEJBException("Not all wrapper children were mapped to parameters or a return value for operation " + operationName);
        }
    } else if (null != outputMessage) {
        if (!outParamNames.equals(outputMessage.getParts().keySet())) {
            throw new OpenEJBException("Not all output message parts were mapped to parameters or a return value for operation " + operationName);
        }
    }
    // 
    for (Fault fault : faults) {
        JaxRpcFaultInfo faultInfo = mapFaults(fault);
        operationInfo.faults.add(faultInfo);
    }
    return operationInfo;
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) Part(javax.wsdl.Part) QName(javax.xml.namespace.QName) Fault(javax.wsdl.Fault) HashSet(java.util.HashSet)

Example 4 with Fault

use of javax.wsdl.Fault in project cxf by apache.

the class OperationVisitor method createFaultMessage.

private void createFaultMessage(CorbaTypeImpl corbaType, Operation operation, BindingOperation bindingOperation, QName elementQName) {
    String exceptionName = corbaType.getQName().getLocalPart();
    Definition faultDef = manager.getWSDLDefinition(elementQName.getNamespaceURI());
    if (faultDef == null) {
        faultDef = definition;
    }
    Message faultMsg = faultDef.getMessage(new QName(faultDef.getTargetNamespace(), exceptionName));
    if (faultMsg == null) {
        throw new RuntimeException("Fault message for exception " + exceptionName + " not found");
    }
    // porttype - operation - fault
    Fault fault = definition.createFault();
    fault.setMessage(faultMsg);
    fault.setName(faultMsg.getQName().getLocalPart());
    operation.addFault(fault);
    // binding - operation - corba:operation - corba:raises
    RaisesType raisesType = new RaisesType();
    raisesType.setException(new QName(typeMap.getTargetNamespace(), exceptionName));
    corbaOperation.getRaises().add(raisesType);
    // binding - operation - fault
    BindingFault bindingFault = definition.createBindingFault();
    bindingFault.setName(faultMsg.getQName().getLocalPart());
    bindingOperation.addBindingFault(bindingFault);
    // add the fault element namespace to the definition
    String nsURI = elementQName.getNamespaceURI();
    manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);
}
Also used : RaisesType(org.apache.cxf.binding.corba.wsdl.RaisesType) Message(javax.wsdl.Message) BindingFault(javax.wsdl.BindingFault) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) BindingFault(javax.wsdl.BindingFault) Fault(javax.wsdl.Fault)

Example 5 with Fault

use of javax.wsdl.Fault in project cxf by apache.

the class WSDLRefValidator method collectValidationPointsForPortTypes.

private void collectValidationPointsForPortTypes() {
    for (QName ptName : portTypeRefNames) {
        PortType portType = getPortType(ptName);
        if (portType == null) {
            vResults.addError(new Message("NO_PORTTYPE", LOG, ptName));
            continue;
        }
        XNode vPortTypeNode = getXNode(portType);
        for (Operation operation : getOperations(portType).values()) {
            XNode vOperationNode = getOperationXNode(vPortTypeNode, operation.getName());
            if (operation.getInput() == null) {
                vResults.addError(new Message("WRONG_MEP", LOG, operation.getName(), portType.getQName()));
                continue;
            }
            javax.wsdl.Message inMsg = operation.getInput().getMessage();
            if (inMsg == null) {
                addWarning("Operation " + operation.getName() + " in PortType: " + portType.getQName() + " has no input message");
            } else {
                XNode vInMsgNode = getXNode(inMsg);
                vInMsgNode.setFailurePoint(getInputXNode(vOperationNode, operation.getInput().getName()));
                vNodes.add(vInMsgNode);
                messageRefNames.add(inMsg.getQName());
            }
            if (operation.getOutput() != null) {
                javax.wsdl.Message outMsg = operation.getOutput().getMessage();
                if (outMsg == null) {
                    addWarning("Operation " + operation.getName() + " in PortType: " + portType.getQName() + " has no output message");
                } else {
                    XNode vOutMsgNode = getXNode(outMsg);
                    vOutMsgNode.setFailurePoint(getOutputXNode(vOperationNode, operation.getOutput().getName()));
                    vNodes.add(vOutMsgNode);
                    messageRefNames.add(outMsg.getQName());
                }
            }
            for (Iterator<?> iter = operation.getFaults().values().iterator(); iter.hasNext(); ) {
                Fault fault = (Fault) iter.next();
                javax.wsdl.Message faultMsg = fault.getMessage();
                XNode vFaultMsgNode = getXNode(faultMsg);
                vFaultMsgNode.setFailurePoint(getFaultXNode(vOperationNode, fault.getName()));
                vNodes.add(vFaultMsgNode);
                messageRefNames.add(faultMsg.getQName());
            }
        }
    }
}
Also used : XMessage(org.apache.cxf.tools.validator.internal.model.XMessage) Message(org.apache.cxf.common.i18n.Message) QName(javax.xml.namespace.QName) XNode(org.apache.cxf.tools.validator.internal.model.XNode) Fault(javax.wsdl.Fault) XFault(org.apache.cxf.tools.validator.internal.model.XFault) Operation(javax.wsdl.Operation) XOperation(org.apache.cxf.tools.validator.internal.model.XOperation) BindingOperation(javax.wsdl.BindingOperation) PortType(javax.wsdl.PortType) XPortType(org.apache.cxf.tools.validator.internal.model.XPortType)

Aggregations

Fault (javax.wsdl.Fault)18 Operation (javax.wsdl.Operation)10 BindingOperation (javax.wsdl.BindingOperation)9 QName (javax.xml.namespace.QName)9 BindingFault (javax.wsdl.BindingFault)8 Message (javax.wsdl.Message)7 Input (javax.wsdl.Input)6 Output (javax.wsdl.Output)6 Binding (javax.wsdl.Binding)5 Part (javax.wsdl.Part)5 PortType (javax.wsdl.PortType)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 BindingInput (javax.wsdl.BindingInput)3 BindingOutput (javax.wsdl.BindingOutput)3 SOAPFault (org.apache.axiom.soap.SOAPFault)3 AxisFault (org.apache.axis2.AxisFault)3 Definition (javax.wsdl.Definition)2