Java Code Examples for javax.wsdl.Binding#getExtensibilityElements()

The following examples show how to use javax.wsdl.Binding#getExtensibilityElements() . 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
/**
 * Retrieves all the operations defined in the provided Binding.
 *
 * @param binding WSDL binding
 * @return a set of {@link WSDLOperation} defined in the provided Binding
 */
private Set<WSDLSOAPOperation> getSOAPBindingOperations(Binding binding) throws APIMgtWSDLException {
    Set<WSDLSOAPOperation> allBindingOperations = new HashSet<>();
    if (binding.getExtensibilityElements() != null && binding.getExtensibilityElements().size() > 0) {
        List extensibilityElements = binding.getExtensibilityElements();
        for (Object extensibilityElement : extensibilityElements) {
            if (extensibilityElement instanceof SOAPBinding || extensibilityElement instanceof SOAP12Binding) {
                for (Object opObj : binding.getBindingOperations()) {
                    BindingOperation bindingOperation = (BindingOperation) opObj;
                    WSDLSOAPOperation wsdlSoapOperation = getSOAPOperation(bindingOperation);
                    if (wsdlSoapOperation != null) {
                        allBindingOperations.add(wsdlSoapOperation);
                    } else {
                        log.warn("Unable to get soap operation details from binding operation: " + bindingOperation
                                .getName());
                    }
                }
            }
        }
    } else {
        throw new APIMgtWSDLException("Cannot further process to get soap binding operations");
    }
    return allBindingOperations;
}
 
Example 2
Source File: WSDL11SOAPOperationExtractor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Returns if the provided WSDL definition contains SOAP binding operations
 *
 * @return whether the provided WSDL definition contains SOAP binding operations
 */
private boolean hasSoapBindingOperations() {
    if (wsdlDefinition == null) {
        return false;
    }
    for (Object bindingObj : wsdlDefinition.getAllBindings().values()) {
        if (bindingObj instanceof Binding) {
            Binding binding = (Binding) bindingObj;
            for (Object ex : binding.getExtensibilityElements()) {
                if (ex instanceof SOAPBinding) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 3
Source File: WSDL11SOAPOperationExtractor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Returns if the provided WSDL definition contains SOAP 1.2 binding operations
 *
 * @return whether the provided WSDL definition contains SOAP 1.2 binding operations
 */
private boolean hasSoap12BindingOperations() {
    if (wsdlDefinition == null) {
        return false;
    }
    for (Object bindingObj : wsdlDefinition.getAllBindings().values()) {
        if (bindingObj instanceof Binding) {
            Binding binding = (Binding) bindingObj;
            for (Object ex : binding.getExtensibilityElements()) {
                if (ex instanceof SOAP12Binding) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 4
Source File: CorbaObjectReferenceHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static Binding getDefaultBinding(Object obj, Definition wsdlDef) {
    LOG.log(Level.FINEST, "Getting binding for a default object reference");
    Collection<Binding> bindings = CastUtils.cast(wsdlDef.getBindings().values());
    for (Binding b : bindings) {
        List<?> extElements = b.getExtensibilityElements();
        // Get the list of all extensibility elements
        for (Iterator<?> extIter = extElements.iterator(); extIter.hasNext();) {
            java.lang.Object element = extIter.next();

            // Find a binding type so we can check against its repository ID
            if (element instanceof BindingType) {
                BindingType type = (BindingType)element;
                if (obj._is_a(type.getRepositoryID())) {
                    return b;
                }
            }
        }
    }
    return null;
}
 
Example 5
Source File: WSDLServiceUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static BindingFactory getBindingFactory(Binding binding, Bus bus, StringBuilder sb) {
    BindingFactory factory = null;
    for (Object obj : binding.getExtensibilityElements()) {
        if (obj instanceof ExtensibilityElement) {
            ExtensibilityElement ext = (ExtensibilityElement) obj;
            sb.delete(0, sb.length());
            sb.append(ext.getElementType().getNamespaceURI());
            try {
                BindingFactoryManager manager = bus.getExtension(BindingFactoryManager.class);
                if (manager != null) {
                    factory = manager.getBindingFactory(sb.toString());
                }
            } catch (BusException e) {
                // ignore, we'll use a generic BindingInfo
            }

            if (factory != null) {
                break;
            }
        }

    }

    return factory;
}
 
Example 6
Source File: WSDLConverter.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void convertPortType( PortType portType, Binding binding )
	throws IOException {
	String comment = "";
	if( portType.getDocumentationElement() != null ) {
		comment = portType.getDocumentationElement().getNodeValue();
	}

	Style style = Style.DOCUMENT;
	for( ExtensibilityElement element : (List< ExtensibilityElement >) binding.getExtensibilityElements() ) {
		if( element instanceof SOAPBinding ) {
			if( "rpc".equals( ((SOAPBinding) element).getStyle() ) ) {
				style = Style.RPC;
			}
		} else if( element instanceof HTTPBinding ) {
			style = Style.HTTP;
		}
	}
	Interface iface = new Interface( portType.getQName().getLocalPart(), comment );
	List< Operation > operations = portType.getOperations();
	for( Operation operation : operations ) {
		if( operation.getOutput() == null ) {
			iface.addOneWayOperation( convertOperation( operation, style ) );
		} else {
			iface.addRequestResponseOperation( convertOperation( operation, style ) );
		}
	}
	interfaces.put( iface.name(), iface );
}
 
Example 7
Source File: PortTypeVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private BindingType findCorbaBinding(Binding binding) {
    List<?> list = binding.getExtensibilityElements();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i) instanceof BindingType) {
            return (BindingType) list.get(i);
        }
    }
    throw new RuntimeException("[InterfaceVisitor] Couldn't find Corba binding in Binding "
                               + binding.getQName());
}
 
Example 8
Source File: ObjectReferenceVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static QName getBindingQNameByID(Definition wsdlDef, String repositoryID,
                                         WSDLASTVisitor wsdlVisitor) {
    // We need to find the binding which corresponds with the given repository ID.
    // This is specified in the schema definition for a custom endpoint
    // reference type.
    Collection<Binding> bindings = CastUtils.cast(wsdlDef.getBindings().values());
    if (bindings.isEmpty() && !wsdlVisitor.getModuleToNSMapper().isDefaultMapping()) {
        // If we are not using the default mapping, then the binding definitions are not
        // located in the current Definition object, but nistead in the root Definition
        bindings = CastUtils.cast(wsdlVisitor.getDefinition().getBindings().values());
    }

    for (Binding b : bindings) {
        List<?> extElements = b.getExtensibilityElements();
        for (java.lang.Object element : extElements) {
            if (element instanceof BindingType) {
                BindingType bt = (BindingType)element;
                if (bt.getRepositoryID().equals(repositoryID)) {
                    if (wsdlVisitor.getSupportPolymorphicFactories()) {
                        return new QName(b.getQName().getNamespaceURI(),
                                         "InferFromTypeId",
                                         b.getQName().getPrefix());

                    }
                    return b.getQName();
                }
            }
        }
    }

    return null;
}
 
Example 9
Source File: WSDLToIDLAction.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void generateIDL(Definition definition, Binding binding) {
    List<?> ext = binding.getExtensibilityElements();
    if (!(ext.get(0) instanceof BindingType)) {
        // throw an error not a corba binding
        throw new RuntimeException(binding.getQName() + " is not a corba binding, "
                                   + "please pass a corba binding/porttype to use");
    }

    String[] nm = unscopeName(binding.getPortType().getQName().getLocalPart());
    int pos = nm[nm.length - 1].lastIndexOf("Binding");

    if (pos != -1) {
        nm[nm.length - 1] = nm[nm.length - 1].substring(0, pos);
    }

    IdlScopeBase parent = root;

    if (nm.length > 1) {
        for (int i = 0; i < nm.length - 1; ++i) {
            IdlModule mod = IdlModule.create(parent, nm[i]);
            parent.addToScope(mod);
            parent = mod;
        }
    }
    intf = IdlInterface.create(parent, nm[nm.length - 1]);
    parent.holdForScope(intf);
    try {
        getAllIdlTypes();
        collectIdlDefns(binding);
        root.flush();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    parent.promoteHeldToScope();
    root.write(printWriter);
}
 
Example 10
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static boolean isSOAPBinding(Binding binding) {
    for (Object obj : binding.getExtensibilityElements()) {
        if (isSOAPBinding(obj)) {
            return true;
        }
    }
    return false;
}
 
Example 11
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static String getBindingStyle(Binding binding) {
    for (Object obj : binding.getExtensibilityElements()) {
        if (isSOAPBinding(obj)) {
            return getSoapBinding(obj).getStyle();
        }
    }
    return "";
}
 
Example 12
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static boolean isSOAPBinding(Binding binding) {
    for (Object obj : binding.getExtensibilityElements()) {
        if (isSOAPBinding(obj)) {
            return true;
        }
    }
    return false;
}
 
Example 13
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static String getBindingStyle(Binding binding) {
    for (Object obj : binding.getExtensibilityElements()) {
        if (isSOAPBinding(obj)) {
            return getSoapBinding(obj).getStyle();
        }
    }
    return "";
}
 
Example 14
Source File: SoapApiConnectorGenerator.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private Connector createConnector(ConnectorTemplate connectorTemplate, ConnectorSettings connectorSettings,
                                  SoapApiModelInfo modelInfo) {

    final Definition definition = modelInfo.getModel().
            orElseThrow(() -> new IllegalArgumentException("Unable to parse WSDL, or missing SOAP Service and Port in specification"));

    // get service and port
    final Map<String, String> configuredProperties = connectorSettings.getConfiguredProperties();
    final QName serviceName = getService(modelInfo, configuredProperties)
            .orElseThrow(() -> new IllegalArgumentException("Missing property " + SERVICE_NAME_PROPERTY));
    final String portName = getPortName(modelInfo, configuredProperties)
            .orElseThrow(() -> new IllegalArgumentException("Missing property " + PORT_NAME_PROPERTY));

    // get SOAP Version from Service and Port
    final Service service = definition.getService(serviceName);
    final Port port = service.getPort(portName);
    final Binding binding = port.getBinding();
    double soapVersion = 1.1;
    for (Object element : binding.getExtensibilityElements()) {
        if (element instanceof SOAP12Binding) {
            soapVersion = 1.2;
            break;
        }
    }

    // add actions
    try {

        final Connector configuredConnector = configuredConnector(connectorTemplate, connectorSettings);

        final List<ConnectorAction> actions = SoapApiModelParser.parseActions(definition,
                serviceName, new QName(serviceName.getNamespaceURI(), portName),
                configuredConnector.getId().get());
        final ActionsSummary actionsSummary = SoapApiModelParser.parseActionsSummary(definition, serviceName, portName);

        final Connector.Builder builder = new Connector.Builder()
                .createFrom(configuredConnector)
                .putConfiguredProperty(SOAP_VERSION_PROPERTY, String.valueOf(soapVersion))
                .addAllActions(actions)
                .actionsSummary(actionsSummary);

        return builder.build();

    } catch (ParserException e) {
        throw new IllegalArgumentException("Error getting actions from WSDL: " + e.getMessage(), e);
    }
}
 
Example 15
Source File: CorbaObjectReferenceHelper.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static EprMetaData getBindingForTypeId(String repId, Definition wsdlDef) {
    LOG.log(Level.FINE, "RepositoryId " + repId
            + ", wsdl namespace " + wsdlDef.getTargetNamespace());
    EprMetaData ret = new EprMetaData();
    Collection<Binding> bindings = CastUtils.cast(wsdlDef.getBindings().values());
    for (Binding b : bindings) {
        List<?> extElements = b.getExtensibilityElements();

        // Get the list of all extensibility elements
        for (Iterator<?> extIter = extElements.iterator(); extIter.hasNext();) {
            java.lang.Object element = extIter.next();

            // Find a binding type so we can check against its repository ID
            if (element instanceof BindingType) {
                BindingType type = (BindingType)element;
                if (repId.equals(type.getRepositoryID())) {
                    ret.setCandidateWsdlDef(wsdlDef);
                    ret.setBinding(b);
                    return ret;
                }
            }
        }
    }

    if (!ret.isValid()) {
        // recursivly check imports
        Iterator<?> importLists = wsdlDef.getImports().values().iterator();
        while (importLists.hasNext()) {
            List<?> imports = (List<?>) importLists.next();
            for (java.lang.Object imp : imports) {
                if (imp instanceof Import) {
                    Definition importDef = ((Import)imp).getDefinition();
                    LOG.log(Level.INFO, "Following import " + importDef.getDocumentBaseURI());
                    ret = getBindingForTypeId(repId, importDef);
                    if (ret.isValid()) {
                        return ret;
                    }
                }
            }
        }
    }
    return ret;
}