Java Code Examples for javax.wsdl.BindingOperation#getOperation()

The following examples show how to use javax.wsdl.BindingOperation#getOperation() . 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: WSDL11SOAPOperationExtractor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the target namespace given the soap binding operation
 *
 * @param bindingOperation soap operation
 * @return target name space
 */
private String getTargetNamespace(BindingOperation bindingOperation) {

    Operation operation = bindingOperation.getOperation();
    if (operation != null) {
        Input input = operation.getInput();

        if (input != null) {
            Message message = input.getMessage();
            if (message != null) {
                Map partMap = message.getParts();

                for (Object obj : partMap.entrySet()) {
                    Map.Entry entry = (Map.Entry) obj;
                    Part part = (Part) entry.getValue();
                    if (part != null) {
                        if (part.getElementName() != null) {
                            return part.getElementName().getNamespaceURI();
                        }
                    }
                }
            }
        }
    }
    return targetNamespace;
}
 
Example 2
Source File: PublishMetadataRunnable.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private Collection<String> getAllPaths() throws URISyntaxException {
    final Set<String> paths = new HashSet<String>();
    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();
                    addParamsToPath(portType, oper, inMsg, paths, alreadyCreated);
                }

                Output outDef = oper.getOutput();
                if (outDef != null) {
                    Message outMsg = outDef.getMessage();
                    addParamsToPath(portType, oper, outMsg, paths, alreadyCreated);
                }
                for (Fault fault : (Collection<Fault>) oper.getFaults().values()) {
                    Message faultMsg = fault.getMessage();
                    addParamsToPath(portType, oper, faultMsg, paths, alreadyCreated);
                }
            }
        }
    }
    return paths;
}
 
Example 3
Source File: UniqueBodyPartsValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
public boolean isValid() {
    Collection<Binding> bindings = CastUtils.cast(def.getAllBindings().values());
    for (Binding binding : bindings) {
        uniqueBodyPartsMap = new HashMap<>();
        List<BindingOperation> ops = CastUtils.cast(binding.getBindingOperations());
        for (BindingOperation op : ops) {
            Operation operation = op.getOperation();
            if (operation != null && operation.getInput() != null) {
                Message inMessage = operation.getInput().getMessage();
                BindingInput bin = op.getBindingInput();
                Set<String> headers = new HashSet<>();
                if (bin != null) {
                    List<ExtensibilityElement> lst = CastUtils.cast(bin.getExtensibilityElements());
                    for (ExtensibilityElement ext : lst) {
                        if (!(ext instanceof SOAPHeader)) {
                            continue;
                        }
                        SOAPHeader header = (SOAPHeader)ext;
                        if (!header.getMessage().equals(inMessage.getQName())) {
                            continue;
                        }
                        headers.add(header.getPart());
                    }
                }

                //find the headers as they don't contribute to the body

                if (inMessage != null && !isUniqueBodyPart(operation.getName(),
                                                           inMessage,
                                                           headers,
                                                           binding.getQName())) {
                    return false;
                }
            }
        }
    }
    return true;
}
 
Example 4
Source File: LightweightOperationInfoBuilder.java    From tomee with Apache License 2.0 5 votes vote down vote up
public LightweightOperationInfoBuilder(BindingOperation bindingOperation, Method method) throws OpenEJBException {
    if (bindingOperation == null) {
        throw new OpenEJBException("No BindingOperation supplied for method " + method.getName());
    }

    Operation operation = bindingOperation.getOperation();
    this.operationName = operation.getName();
    this.inputMessage = operation.getInput().getMessage();
    this.outputMessage = operation.getOutput() == null ? null : operation.getOutput().getMessage();
    this.method = method;
}
 
Example 5
Source File: ComponentBuilder.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
private static ServiceInfo populateComponent(Service service) {
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setServiceName(service.getQName());
    Collection<Port> ports = service.getPorts().values();
    for (Port port : ports) {
        String soapLocation = null;
        SOAPAddress soapAddress = findExtensibilityElement(port.getExtensibilityElements(), SOAPAddress.class);
        if (null != soapAddress) {
            soapLocation = soapAddress.getLocationURI();
        } else {
            SOAP12Address soap12Address = findExtensibilityElement(port.getExtensibilityElements(), SOAP12Address.class);
            if (null != soap12Address) {
                soapLocation = soap12Address.getLocationURI();
            }
        }
        Binding binding = port.getBinding();
        for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) {
            SOAPOperation soapOperation = findExtensibilityElement(operation.getExtensibilityElements(), SOAPOperation.class);

            if (null != soapOperation && OPERATION_TYPE_RPC.equalsIgnoreCase(soapOperation.getStyle())) {
                // TESB-6151 disable display of unsupported RPC type.
                serviceInfo.setHasRpcOperation(true);
                continue;
            }
            OperationInfo operationInfo = new OperationInfo(operation.getOperation());
            operationInfo.setPortName(port.getName());
            operationInfo.setNamespaceURI(binding.getPortType().getQName().getNamespaceURI());
            if (soapOperation != null) {
                operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
            } else {
                SOAP12Operation soap12Operation = findExtensibilityElement(operation.getExtensibilityElements(),
                        SOAP12Operation.class);
                if (soap12Operation != null) {
                    operationInfo.setSoapActionURI(soap12Operation.getSoapActionURI());
                }
            }

            operationInfo.setTargetURL(soapLocation);
            serviceInfo.addOperation(operationInfo);
        }
    }
    return serviceInfo;
}
 
Example 6
Source File: WSDL11SOAPOperationExtractor.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
/**
 * Gets swagger output parameter model for a given soap operation
 *
 * @param bindingOperation soap operation
 * @return list of swagger models for the parameters
 * @throws APIMgtWSDLException
 */
private List<ModelImpl> getSoapOutputParameterModel(BindingOperation bindingOperation) throws APIMgtWSDLException {
    List<ModelImpl> outputParameterModelList = new ArrayList<>();
    Operation operation = bindingOperation.getOperation();
    if (operation != null) {
        Output output = operation.getOutput();
        if (output != null) {
            Message message = output.getMessage();
            if (message != null) {
                Map map = message.getParts();

                for (Object obj : map.entrySet()) {
                    Map.Entry entry = (Map.Entry) obj;
                    Part part = (Part) entry.getValue();
                    if (part != null) {
                        if (part.getElementName() != null) {
                            outputParameterModelList.add(parameterModelMap.get(part.getElementName()
                                    .getLocalPart()));
                        } else {
                            if (part.getTypeName() != null && parameterModelMap
                                    .containsKey(part.getTypeName().getLocalPart())) {
                                outputParameterModelList
                                        .add(parameterModelMap.get(part.getTypeName().getLocalPart()));
                            } else {
                                ModelImpl model = new ModelImpl();
                                model.setType(ObjectProperty.TYPE);
                                model.setName(message.getQName().getLocalPart());
                                if (getPropertyFromDataType(part.getTypeName().getLocalPart()) instanceof RefProperty) {
                                    RefProperty property = (RefProperty) getPropertyFromDataType(part.getTypeName()
                                            .getLocalPart());
                                    property.set$ref(SOAPToRESTConstants.Swagger.DEFINITIONS_ROOT +
                                            part.getTypeName().getLocalPart());
                                    model.addProperty(part.getName(), property);
                                } else {
                                    model.addProperty(part.getName(),
                                            getPropertyFromDataType(part.getTypeName().getLocalPart()));
                                }
                                parameterModelMap.put(model.getName(), model);
                                outputParameterModelList.add(model);
                            }
                        }
                    }
                }
            }
        }
    }
    return outputParameterModelList;
}
 
Example 7
Source File: HeavyweightOperationInfoBuilder.java    From tomee with Apache License 2.0 4 votes vote down vote up
public HeavyweightOperationInfoBuilder(BindingOperation bindingOperation, ServiceEndpointMethodMapping methodMapping, JavaWsdlMapping mapping, XmlSchemaInfo schemaInfo) throws OpenEJBException {
    Operation operation = bindingOperation.getOperation();
    this.operationName = operation.getName();
    this.operationStyle = JaxRpcOperationInfo.OperationStyle.valueOf(operation.getStyle().toString());
    this.outputMessage = operation.getOutput() == null ? null : operation.getOutput().getMessage();
    this.inputMessage = operation.getInput().getMessage();

    // faults
    for (Object o : operation.getFaults().values()) {
        faults.add((Fault) o);
    }

    this.mapping = mapping;
    this.methodMapping = methodMapping;
    this.schemaInfo = schemaInfo;

    // index types - used to process build exception class constructor args
    for (JavaXmlTypeMapping javaXmlTypeMapping : mapping.getJavaXmlTypeMapping()) {
        String javaClassName = javaXmlTypeMapping.getJavaType();
        if (javaXmlTypeMapping.getAnonymousTypeQname() != null) {
            String anonymousTypeQName = javaXmlTypeMapping.getAnonymousTypeQname();
            anonymousTypes.put(anonymousTypeQName, javaClassName);
        } else if (javaXmlTypeMapping.getRootTypeQname() != null) {
            QName qname = javaXmlTypeMapping.getRootTypeQname();
            publicTypes.put(qname, javaClassName);
        }
    }

    // BindingStyle
    if (methodMapping.getWrappedElement() != null) {
        bindingStyle = BindingStyle.DOCUMENT_LITERAL_WRAPPED;
    } else {
        BindingInput bindingInput = bindingOperation.getBindingInput();

        SOAPOperation soapOperation = JaxRpcServiceInfoBuilder.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
        String styleString = soapOperation.getStyle();
        if (styleString == null) {
            SOAPBinding soapBinding = JaxRpcServiceInfoBuilder.getExtensibilityElement(SOAPBinding.class, bindingInput.getExtensibilityElements());
            styleString = soapBinding.getStyle();
        }

        SOAPBody soapBody = JaxRpcServiceInfoBuilder.getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
        String useString = soapBody.getUse();

        bindingStyle = BindingStyle.getBindingStyle(styleString, useString);
    }
}