javax.wsdl.BindingFault Java Examples

The following examples show how to use javax.wsdl.BindingFault. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLToSoapProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void setSoapFaultExtElement(BindingFault bf) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    SoapFault soapFault = null;
    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);
}
 
Example #2
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static List<SoapFault> getBindingOperationSoapFaults(BindingOperation bop) {
    List<SoapFault> faults = new ArrayList<>();
    for (Object obj : bop.getBindingFaults().values()) {
        if (!(obj instanceof BindingFault)) {
            continue;
        }
        BindingFault faultElement = (BindingFault) obj;
        for (Object flt : faultElement.getExtensibilityElements()) {
            SoapFault fault = getSoapFault(flt);
            if (fault != null) {
                faults.add(fault);
            }
        }
    }
    return faults;
}
 
Example #3
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static List<SOAPFault> getBindingOperationSoapFaults(BindingOperation bop) {
    List<SOAPFault> faults = new ArrayList<>();
    for (Object obj : bop.getBindingFaults().values()) {
        if (!(obj instanceof BindingFault)) {
            continue;
        }
        BindingFault faultElement = (BindingFault) obj;
        for (Object flt : faultElement.getExtensibilityElements()) {
            SOAPFault fault = getSoapFault(flt);
            if (fault != null) {
                faults.add(fault);
            }
        }
    }
    return faults;
}
 
Example #4
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #5
Source File: WSDLToCorbaBinding.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addBindingOperations(Definition definition, PortType portType, Binding binding)
    throws Exception {

    List<Operation> ops = CastUtils.cast(portType.getOperations());
    for (Operation op : ops) {
        try {
            BindingOperation bindingOperation = definition.createBindingOperation();
            addCorbaOperationExtElement(bindingOperation, op);
            bindingOperation.setName(op.getName());
            if (op.getInput() != null) {
                BindingInput bindingInput = definition.createBindingInput();
                bindingInput.setName(op.getInput().getName());
                bindingOperation.setBindingInput(bindingInput);
            }
            if (op.getOutput() != null) {
                BindingOutput bindingOutput = definition.createBindingOutput();
                bindingOutput.setName(op.getOutput().getName());
                bindingOperation.setBindingOutput(bindingOutput);
            }
            // add Faults
            if (op.getFaults() != null && op.getFaults().size() > 0) {
                Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
                for (Fault fault : faults) {
                    BindingFault bindingFault = definition.createBindingFault();
                    bindingFault.setName(fault.getName());
                    bindingOperation.addBindingFault(bindingFault);
                }
            }
            bindingOperation.setOperation(op);
            binding.addBindingOperation(bindingOperation);
        } catch (Exception ex) {
            LOG.warning("Operation " + op.getName() + " not mapped to CORBA binding.");
        }
    }
}
 
Example #6
Source File: WSDLToSoapProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addSoapFaults(Operation op, BindingOperation bindingOperation) throws ToolException {
    Map<String, Fault> faults = CastUtils.cast(op.getFaults());
    for (Fault fault : faults.values()) {
        BindingFault bf = wsdlDefinition.createBindingFault();
        bf.setName(fault.getName());
        setSoapFaultExtElement(bf);
        bindingOperation.addBindingFault(bf);
    }
}
 
Example #7
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SoapFault createSoapFault(ExtensionRegistry extReg, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(BindingFault.class,
                                                         new QName(WSDLConstants.NS_SOAP12,
                                                                   "fault"));
    } else {
        extElement = extReg.createExtension(BindingFault.class,
                                                       new QName(WSDLConstants.NS_SOAP11,
                                                                 "fault"));
    }
    return getSoapFault(extElement);
}
 
Example #8
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void buildBindingFault(Definition def, BindingOperation bindingOperation,
                               Collection<BindingFaultInfo> bindingFaultInfos) {
    BindingFault bindingFault = null;
    for (BindingFaultInfo bindingFaultInfo
        : bindingFaultInfos) {
        bindingFault = def.createBindingFault();
        addDocumentation(bindingFault, bindingFaultInfo.getDocumentation());
        bindingFault.setName(bindingFaultInfo.getFaultInfo().getFaultName().getLocalPart());
        bindingOperation.addBindingFault(bindingFault);
        addExtensibilityAttributes(def, bindingFault, bindingFaultInfo.getExtensionAttributes());
        addExtensibilityElements(def, bindingFault, getWSDL11Extensors(bindingFaultInfo));
    }

}
 
Example #9
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPFault createSoapFault(ExtensionRegistry extReg, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(BindingFault.class,
                                                         new QName(WSDLConstants.NS_SOAP12,
                                                                   "fault"));
    } else {
        extElement = extReg.createExtension(BindingFault.class,
                                                       new QName(WSDLConstants.NS_SOAP11,
                                                                 "fault"));
    }
    return getSoapFault(extElement);
}
 
Example #10
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static void addSoapFaults(Operation op, BindingOperation bindingOperation, Definition wsdlDefinition,
                                  ExtensionRegistry extReg) throws Exception {
    Map<String, Fault> faults = CastUtils.cast(op.getFaults());
    for (Fault fault : faults.values()) {
        BindingFault bf = wsdlDefinition.createBindingFault();
        bf.setName(fault.getName());
        setSoapFaultExtElement(bf, extReg);
        bindingOperation.addBindingFault(bf);
    }
}
 
Example #11
Source File: LightWeightMappingValidator.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
protected void visit(BindingFault bindingFault) {
    SOAPBody body = getSOAPBody(bindingFault.getExtensibilityElements());
    String encoding = body.getUse();
    if (encoding == null || !encoding.equals("encoded")) {
        context.addFailure(new ValidationFailure("The use attribute of the binding fault operation must be 'encoded': " + bindingFault.getName()));
    }
}
 
Example #12
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void addOperationSOAPBinding( Definition localDef, Operation wsdlOp, Binding bind ) {
	try {
		// creating operation binding
		BindingOperation bindOp = localDef.createBindingOperation();
		bindOp.setName( wsdlOp.getName() );

		// adding soap extensibility elements
		SOAPOperation soapOperation = (SOAPOperation) extensionRegistry.createExtension( BindingOperation.class,
			new QName( NameSpacesEnum.SOAP.getNameSpaceURI(), "operation" ) );
		soapOperation.setStyle( "document" );
		// NOTA-BENE: Come settare SOAPACTION? jolie usa SOAP1.1 o 1.2? COme usa la SoapAction?
		soapOperation.setSoapActionURI( wsdlOp.getName() );
		bindOp.addExtensibilityElement( soapOperation );
		bindOp.setOperation( wsdlOp );

		// adding input
		BindingInput bindingInput = localDef.createBindingInput();
		SOAPBody body = (SOAPBody) extensionRegistry.createExtension( BindingInput.class,
			new QName( NameSpacesEnum.SOAP.getNameSpaceURI(), "body" ) );
		body.setUse( "literal" );
		bindingInput.addExtensibilityElement( body );
		bindOp.setBindingInput( bindingInput );

		// adding output
		BindingOutput bindingOutput = localDef.createBindingOutput();
		bindingOutput.addExtensibilityElement( body );
		bindOp.setBindingOutput( bindingOutput );

		// adding fault
		if( !wsdlOp.getFaults().isEmpty() ) {
			for( Object o : wsdlOp.getFaults().entrySet() ) {
				BindingFault bindingFault = localDef.createBindingFault();
				SOAPFault soapFault = (SOAPFault) extensionRegistry.createExtension( BindingFault.class,
					new QName( NameSpacesEnum.SOAP.getNameSpaceURI(), "fault" ) );
				soapFault.setUse( "literal" );
				String faultName = ((Entry) o).getKey().toString();
				bindingFault.setName( faultName );
				soapFault.setName( faultName );
				bindingFault.addExtensibilityElement( soapFault );
				bindOp.addBindingFault( bindingFault );
			}
		}

		bind.addBindingOperation( bindOp );

	} catch( WSDLException ex ) {
		ex.printStackTrace();
	}

}
 
Example #13
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 4 votes vote down vote up
private static void setSoapFaultExtElement(BindingFault bf, ExtensionRegistry extReg) throws Exception {
    SOAPFault soapFault = SOAPBindingUtil.createSoapFault(extReg, false);
    soapFault.setName(bf.getName());
    soapFault.setUse(useLiteral);
    bf.addExtensibilityElement(soapFault);
}
 
Example #14
Source File: AbstractWSDLBindingFactory.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected BindingInfo initializeBindingInfo(ServiceInfo service, Binding binding, BindingInfo bi) {
    bi.setName(binding.getQName());
    copyExtensors(bi, binding, null);

    for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
        String inName = null;
        String outName = null;
        if (bop.getBindingInput() != null) {
            inName = bop.getBindingInput().getName();
        }
        if (bop.getBindingOutput() != null) {
            outName = bop.getBindingOutput().getName();
        }
        String portTypeNs = binding.getPortType().getQName().getNamespaceURI();
        QName opName = new QName(portTypeNs,
                                 bop.getName());
        BindingOperationInfo bop2 = bi.getOperation(opName);
        if (bop2 == null) {
            bop2 = bi.buildOperation(opName, inName, outName);
            if (bop2 != null) {
                bi.addOperation(bop2);
            }
        }
        if (bop2 != null) {
            copyExtensors(bop2, bop, bop2);
            if (bop.getBindingInput() != null) {
                copyExtensors(bop2.getInput(), bop.getBindingInput(), bop2);
            }
            if (bop.getBindingOutput() != null) {
                copyExtensors(bop2.getOutput(), bop.getBindingOutput(), bop2);
            }
            for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
                if (StringUtils.isEmpty(f.getName())) {
                    throw new IllegalArgumentException("wsdl:fault and soap:fault elements"
                                                       + " must have a name attribute.");
                }
                copyExtensors(bop2.getFault(new QName(service.getTargetNamespace(), f.getName())),
                              bop.getBindingFault(f.getName()), bop2);
            }
        }
    }
    return bi;
}
 
Example #15
Source File: WsdlVisitor.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void walkTree() {
    begin();
    try {
        visit(definition);
        for (Iterator iterator = definition.getImports().entrySet().iterator(); iterator.hasNext(); ) {
            Map.Entry entry = (Map.Entry) iterator.next();
            String namespaceURI = (String) entry.getKey();
            List importsForNamespace = (List) entry.getValue();
            for (Iterator iterator1 = importsForNamespace.iterator(); iterator1.hasNext(); ) {
                Import anImport = (Import) iterator1.next();
                visit(anImport);
            }
        }
        visit(definition.getTypes());
        Collection messages = definition.getMessages().values();
        for (Iterator iterator = messages.iterator(); iterator.hasNext(); ) {
            Message message = (Message) iterator.next();
            visit(message);
            Collection parts = message.getParts().values();
            for (Iterator iterator2 = parts.iterator(); iterator2.hasNext(); ) {
                Part part = (Part) iterator2.next();
                visit(part);
            }
        }
        Collection services = definition.getServices().values();
        for (Iterator iterator = services.iterator(); iterator.hasNext(); ) {
            Service service = (Service) iterator.next();
            visit(service);
            Collection ports = service.getPorts().values();
            for (Iterator iterator1 = ports.iterator(); iterator1.hasNext(); ) {
                Port port = (Port) iterator1.next();
                visit(port);
                Binding binding = port.getBinding();
                visit(binding);
                List bindingOperations = binding.getBindingOperations();
                for (int i = 0; i < bindingOperations.size(); i++) {
                    BindingOperation bindingOperation = (BindingOperation) bindingOperations.get(i);
                    visit(bindingOperation);
                    visit(bindingOperation.getBindingInput());
                    visit(bindingOperation.getBindingOutput());
                    Collection bindingFaults = bindingOperation.getBindingFaults().values();
                    for (Iterator iterator2 = bindingFaults.iterator(); iterator2.hasNext(); ) {
                        BindingFault bindingFault = (BindingFault) iterator2.next();
                        visit(bindingFault);
                    }

                }
                PortType portType = binding.getPortType();
                visit(portType);
                List operations = portType.getOperations();
                for (int i = 0; i < operations.size(); i++) {
                    Operation operation = (Operation) operations.get(i);
                    visit(operation);
                    {
                        Input input = operation.getInput();
                        visit(input);
                    }
                    {
                        Output output = operation.getOutput();
                        visit(output);
                    }
                    Collection faults = operation.getFaults().values();
                    for (Iterator iterator2 = faults.iterator(); iterator2.hasNext(); ) {
                        Fault fault = (Fault) iterator2.next();
                        visit(fault);
                    }

                }
            }
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    } finally {
        end();
    }
}
 
Example #16
Source File: WsdlVisitor.java    From tomee with Apache License 2.0 4 votes vote down vote up
protected void visit(BindingFault bindingFault) {
}