Search in sources :

Example 86 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class WSDLToSoapProcessor method setSoapOperationExtElement.

private void setSoapOperationExtElement(BindingOperation bo) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    final SoapOperation soapOperation;
    try {
        soapOperation = SOAPBindingUtil.createSoapOperation(extReg, isSOAP12());
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
        throw new ToolException(msg, wse);
    }
    soapOperation.setStyle((String) env.get(ToolConstants.CFG_STYLE));
    soapOperation.setSoapActionURI("");
    bo.addExtensibilityElement(soapOperation);
}
Also used : Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) ToolException(org.apache.cxf.tools.common.ToolException)

Example 87 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class WSDLToSoapProcessor method doAppendBinding.

private void doAppendBinding() throws ToolException {
    if (binding == null) {
        binding = wsdlDefinition.createBinding();
        binding.setQName(new QName(wsdlDefinition.getTargetNamespace(), (String) env.get(ToolConstants.CFG_BINDING)));
        binding.setUndefined(false);
        binding.setPortType(portType);
    }
    setSoapBindingExtElement();
    addBindingOperation();
    wsdlDefinition.addBinding(binding);
    WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
    Writer outputWriter = getOutputWriter(NEW_FILE_NAME_MODIFIER);
    try {
        wsdlWriter.writeWSDL(wsdlDefinition, outputWriter);
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_WRITE_WSDL", LOG, wse.getMessage());
        throw new ToolException(msg);
    }
    try {
        outputWriter.close();
    } catch (IOException ioe) {
        Message msg = new Message("PORTTYPE_NOT_EXIST", LOG);
        throw new ToolException(msg);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) WSDLWriter(javax.wsdl.xml.WSDLWriter) ToolException(org.apache.cxf.tools.common.ToolException) IOException(java.io.IOException) WSDLWriter(javax.wsdl.xml.WSDLWriter) Writer(java.io.Writer)

Example 88 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class WSDLToSoapProcessor method setSoapFaultExtElement.

private void setSoapFaultExtElement(BindingFault bf) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    final SoapFault soapFault;
    try {
        soapFault = SOAPBindingUtil.createSoapFault(extReg, isSOAP12());
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
        throw new ToolException(msg, wse);
    }
    soapFault.setName(bf.getName());
    soapFault.setUse((String) env.get(ToolConstants.CFG_USE));
    if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE)) && env.optionSet(ToolConstants.CFG_NAMESPACE)) {
        soapFault.setNamespaceURI((String) env.get(ToolConstants.CFG_NAMESPACE));
    }
    bf.addExtensibilityElement(soapFault);
}
Also used : SoapFault(org.apache.cxf.binding.soap.wsdl.extensions.SoapFault) Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException)

Example 89 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class UniqueBodyValidator method isValidEndpoint.

private boolean isValidEndpoint(EndpointInfo endpoint) {
    BindingInfo binding = endpoint.getBinding();
    Map<QName, QName> uniqueNames = new HashMap<>();
    Map<QName, Set<String>> actions = new HashMap<>();
    Collection<BindingOperationInfo> bos = binding.getOperations();
    for (BindingOperationInfo bo : bos) {
        OperationInfo op = binding.getInterface().getOperation(bo.getName());
        if (op.getInput() != null && op.getInput().getMessagePartsNumber() == 1) {
            MessagePartInfo part = op.getInput().getFirstMessagePart();
            if (part.getElementQName() == null) {
                continue;
            }
            QName mName = part.getElementQName();
            String action = getWSAAction(op.getInput());
            QName opName = uniqueNames.get(mName);
            Set<String> opActions = actions.get(mName);
            if (opName != null && opActions != null && !opActions.contains(action)) {
                opName = null;
            }
            if (opName != null) {
                Message msg = new Message("NON_UNIQUE_BODY", LOG, endpoint.getName(), op.getName(), opName, mName);
                addErrorMessage(msg.toString());
                return false;
            }
            uniqueNames.put(mName, op.getName());
            if (action != null) {
                if (opActions == null) {
                    opActions = new HashSet<>();
                    actions.put(mName, opActions);
                }
                opActions.add(action);
            }
        }
        for (BindingFaultInfo fault : bo.getFaults()) {
            if (fault.getFaultInfo().getMessagePartsNumber() > 1) {
                Message msg = new Message("FAULT_WITH_MULTIPLE_PARTS", LOG, fault.getFaultInfo().getName().getLocalPart());
                addErrorMessage(msg.toString());
                return false;
            }
        }
    }
    return true;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Set(java.util.Set) HashSet(java.util.HashSet) Message(org.apache.cxf.common.i18n.Message) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo)

Example 90 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class WrapperStyleNameCollisionValidator method handleErrors.

private void handleErrors(QName e1, WrapperElement e2) {
    Message msg = new Message("WRAPPER_STYLE_NAME_COLLISION", LOG, e2.getElementName(), e1, e2.getSchemaTypeName());
    addErrorMessage(msg.toString());
}
Also used : Message(org.apache.cxf.common.i18n.Message)

Aggregations

Message (org.apache.cxf.common.i18n.Message)201 ToolException (org.apache.cxf.tools.common.ToolException)69 IOException (java.io.IOException)45 QName (javax.xml.namespace.QName)42 Fault (org.apache.cxf.interceptor.Fault)34 XMLStreamException (javax.xml.stream.XMLStreamException)27 JAXBException (javax.xml.bind.JAXBException)23 ArrayList (java.util.ArrayList)19 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)17 Element (org.w3c.dom.Element)17 File (java.io.File)16 WSDLException (javax.wsdl.WSDLException)15 Method (java.lang.reflect.Method)14 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)13 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)12 InputStream (java.io.InputStream)11 HashMap (java.util.HashMap)11 List (java.util.List)11 Map (java.util.Map)11 ServiceConstructionException (org.apache.cxf.service.factory.ServiceConstructionException)11