Java Code Examples for org.apache.cxf.service.model.BindingOperationInfo#getName()

The following examples show how to use org.apache.cxf.service.model.BindingOperationInfo#getName() . 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: SoapApiModelParser.java    From syndesis with Apache License 2.0 6 votes vote down vote up
private static ConnectorAction parseConnectorAction(final BindingOperationInfo bindingOperationInfo, final Map<String, Integer> idMap,
                                                    final String connectorId) throws ParserException {
    final OperationInfo operationInfo = bindingOperationInfo.getOperationInfo();
    final String description = getDescription(operationInfo,
            o -> "Invokes the operation " + getOperationName(bindingOperationInfo));
    final QName name = bindingOperationInfo.getName();

    final ConnectorAction.Builder builder = new ConnectorAction.Builder()
            .name(name.getLocalPart())
            .description(description)
            .id(getActionId(connectorId, name.getLocalPart(), idMap))
            .descriptor(new ConnectorDescriptor.Builder()
                .connectorId(connectorId)
                .putConfiguredProperty(DEFAULT_OPERATION_NAME_PROPERTY, name.getLocalPart())
                .putConfiguredProperty(DEFAULT_OPERATION_NAMESPACE_PROPERTY, name.getNamespaceURI())
                .putConfiguredProperty(DATA_FORMAT_PROPERTY, PAYLOAD_FORMAT)
                .inputDataShape(getDataShape(bindingOperationInfo.getInput()))
                .outputDataShape(getDataShape(bindingOperationInfo.getOutput()))
                // TODO handle SOAP faults
                .build())
            .pattern(Action.Pattern.To);
    return builder.build();
}
 
Example 2
Source File: URIDomainExpression.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public boolean appliesTo(BindingOperationInfo boi) {
    if (boi == null) {
        return false;
    }
    if ((boi.getBinding() != null) && (boi.getBinding().getName() != null)
        && wsdl11XPointer.matchesBinding(
                    boi.getBinding().getName().getNamespaceURI(),
                    boi.getBinding().getName().getLocalPart())) {
        return true;
    }
    if ((boi.getName() != null) && (boi.getBinding() != null) && (boi.getBinding().getName() != null)
        && wsdl11XPointer.matchesBindingOperation(
                    boi.getBinding().getName().getNamespaceURI(),
                    boi.getBinding().getName().getLocalPart(),
                    boi.getName().getLocalPart())) {
        return true;
    }
    return (boi.getOperationInfo() != null) && (boi.getOperationInfo().getInterface() != null)
        && (boi.getOperationInfo().getInterface().getName() != null) && (boi.getOperationInfo().getName() != null)
        && wsdl11XPointer.matchesPortTypeOperation(
                    boi.getOperationInfo().getInterface().getName().getNamespaceURI(),
                    boi.getOperationInfo().getInterface().getName().getLocalPart(),
                    boi.getOperationInfo().getName().getLocalPart());
}
 
Example 3
Source File: SoapClient.java    From jea with Apache License 2.0 5 votes vote down vote up
private QName getQName(Endpoint endpoint, String methodName){
       BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding();
       QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), methodName);
       
       if (bindingInfo.getOperation(opName) == null) {
           for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) {
               if (methodName.equals(operationInfo.getName().getLocalPart())) {
                   opName = operationInfo.getName();
                   break;
               }
           }
       }
       return opName;
}
 
Example 4
Source File: XMLFormatValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean findXMLFormatRootNode(Iterator<XMLBindingMessageFormat> it,
                                      BindingOperationInfo bo,
                                      String errorPath) {
    while (it != null && it.hasNext()) {
        XMLBindingMessageFormat xmlFormat = it.next();
        if (xmlFormat.getRootNode() == null) {
            QName rootNodeName = bo.getName();
            addErrorMessage(errorPath
                            + ": empty value of rootNode attribute, the value should be "
                            + rootNodeName);
            return false;
        }
    }
    return true;
}
 
Example 5
Source File: SoapBindingFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void addMessageFromBinding(ExtensibilityElement ext, BindingOperationInfo bop,
                                     boolean isInput) {
    SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);

    ServiceInfo serviceInfo = bop.getBinding().getService();

    if (header != null && header.getMessage() == null) {
        throw new RuntimeException("Problem with WSDL: soap:header element"
            + " for operation " + bop.getName() + " under binding " + bop.getBinding().getName()
            + " does not contain a valid message attribute.");
    }

    if (header != null && serviceInfo.getMessage(header.getMessage()) == null) {
        Definition def = (Definition)serviceInfo.getProperty(WSDLServiceBuilder.WSDL_DEFINITION);
        SchemaCollection schemas = serviceInfo.getXmlSchemaCollection();

        if (def != null && schemas != null) {
            QName qn = header.getMessage();

            javax.wsdl.Message msg = findMessage(qn, def);
            if (msg != null) {
                addOutOfBandParts(bop, msg, schemas, isInput, header.getPart());
                serviceInfo.refresh();
            } else {
                throw new RuntimeException("Problem with WSDL: soap:header element"
                    + " for operation " + bop.getName()
                    + " is referring to an undefined wsdl:message element: " + qn);
            }
        }
    }
}
 
Example 6
Source File: CorbaStreamInInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void handleRequest(Message msg) {
    ORB orb;
    ServiceInfo service;
    CorbaDestination destination;
    if (msg.getDestination() != null) {
        destination = (CorbaDestination)msg.getDestination();
    } else {
        destination = (CorbaDestination)msg.getExchange().getDestination();
    }
    service = destination.getBindingInfo().getService();

    CorbaMessage message = (CorbaMessage) msg;

    Exchange exchange = message.getExchange();

    CorbaTypeMap typeMap = message.getCorbaTypeMap();

    BindingInfo bInfo = destination.getBindingInfo();
    InterfaceInfo info = bInfo.getInterface();
    String opName = exchange.get(String.class);
    Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
    OperationType opType = null;
    BindingOperationInfo bopInfo = null;
    QName opQName = null;
    while (i.hasNext()) {
        bopInfo = i.next();
        if (bopInfo.getName().getLocalPart().equals(opName)) {
            opType = bopInfo.getExtensor(OperationType.class);
            opQName = bopInfo.getName();
            break;
        }
    }

    if (opType == null) {
        throw new RuntimeException("Couldn't find the binding operation for " + opName);
    }

    orb = exchange.get(ORB.class);

    ServerRequest request = exchange.get(ServerRequest.class);
    NVList list = prepareArguments(message, info, opType,
                                   opQName, typeMap,
                                   destination, service);
    request.arguments(list);
    message.setList(list);

    HandlerIterator paramIterator = new HandlerIterator(message, true);

    CorbaTypeEventProducer eventProducer = null;
    BindingMessageInfo msgInfo = bopInfo.getInput();
    boolean wrap = false;
    if (bopInfo.isUnwrappedCapable()) {
        wrap = true;
    }

    if (wrap) {
        // wrapper element around our args
        QName wrapperElementQName = msgInfo.getMessageInfo().getName();
        eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName,
                                                                  paramIterator,
                                                                  service,
                                                                  orb);
    } else {
        eventProducer = new ParameterEventProducer(paramIterator,
                                                   service,
                                                   orb);
    }
    CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
    message.setContent(XMLStreamReader.class, reader);
}
 
Example 7
Source File: XMLMessageOutInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void handleMessage(Message message) throws Fault {
    BindingOperationInfo boi = message.getExchange().getBindingOperationInfo();
    MessageInfo mi;
    BindingMessageInfo bmi;
    if (isRequestor(message)) {
        mi = boi.getOperationInfo().getInput();
        bmi = boi.getInput();
    } else {
        mi = boi.getOperationInfo().getOutput();
        bmi = boi.getOutput();
    }
    XMLBindingMessageFormat xmf = bmi.getExtensor(XMLBindingMessageFormat.class);
    QName rootInModel = null;
    if (xmf != null) {
        rootInModel = xmf.getRootNode();
    }
    final int mpn = mi.getMessagePartsNumber();
    if (boi.isUnwrapped()
        || mpn == 1) {
        // wrapper out interceptor created the wrapper
        // or if bare-one-param
        new BareOutInterceptor().handleMessage(message);
    } else {
        if (rootInModel == null) {
            rootInModel = boi.getName();
        }
        if (mpn == 0 && !boi.isUnwrapped()) {
            // write empty operation qname
            writeMessage(message, rootInModel, false);
        } else {
            // multi param, bare mode, needs write root node
            writeMessage(message, rootInModel, true);
        }
    }
    // in the end we do flush ;)
    XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
    try {
        writer.flush();
    } catch (XMLStreamException e) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE, e));
    }
}
 
Example 8
Source File: XMLFormatValidator.java    From cxf with Apache License 2.0 4 votes vote down vote up
private boolean checkXMLFormat(BindingInfo binding) {
    Collection<BindingOperationInfo> bos = binding.getOperations();
    boolean result = true;
    boolean needRootNode = false;
    for (BindingOperationInfo bo : bos) {
        OperationInfo op = binding.getInterface().getOperation(bo.getName());
        needRootNode = false;
        final int inputPartsNum = op.getInput().getMessagePartsNumber();
        if (inputPartsNum == 0 || inputPartsNum > 1) {
            needRootNode = true;
        }
        if (needRootNode) {
            String path = "Binding(" + binding.getName().getLocalPart()
                + "):BindingOperation(" + bo.getName() + ")";
            List<XMLBindingMessageFormat> inExtensors =
                bo.getInput().getExtensors(XMLBindingMessageFormat.class);
            Iterator<XMLBindingMessageFormat> itIn = null;
            if (inExtensors != null) {
                itIn = inExtensors.iterator();
            }
            if (!findXMLFormatRootNode(itIn, bo, path + "-input")) {
                return false;
            }
            // Input check correct, continue to check output binding
            if (op.getOutput() != null) {
                needRootNode = false;
                final int outputPartsNum = op.getOutput().getMessagePartsNumber();
                if (outputPartsNum == 0 || outputPartsNum > 1) {
                    needRootNode = true;
                }
                if (needRootNode) {
                    List<XMLBindingMessageFormat> outExtensors =
                        bo.getOutput().getExtensors(XMLBindingMessageFormat.class);
                    Iterator<XMLBindingMessageFormat> itOut = null;
                    if (outExtensors != null) {
                        itOut = outExtensors.iterator();
                    }
                    result = result
                        && findXMLFormatRootNode(itOut, bo, path + "-Output");
                    if (!result) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}