Search in sources :

Example 51 with Service

use of javax.wsdl.Service in project tesb-studio-se by Talend.

the class WSDLUtils method getServiceOperationParameters.

public static Map<String, String> getServiceOperationParameters(IFile wsdlURI, String operationName, String portTypeName) throws CoreException {
    // NOTE: all below in assuming standalone (no another WSDL's imports) WS-I complaint WSDL !
    Map<String, String> map = new HashMap<String, String>();
    if (null == wsdlURI) {
        // no WSDL provided
        return map;
    }
    Definition wsdl = getDefinition(wsdlURI);
    for (Object serviceObject : wsdl.getServices().values()) {
        Service service = (Service) serviceObject;
        for (Object portObject : service.getPorts().values()) {
            Port port = (Port) portObject;
            try {
                port.getBinding().getPortType().getQName().getLocalPart();
            } catch (NullPointerException npe) {
                throw getCoreException("WSDL is not consistent. Can not find portType operation description for current service.", npe);
            }
            if (portTypeName.equals(port.getBinding().getPortType().getQName().getLocalPart())) {
                final String targetNs = wsdl.getTargetNamespace();
                map.put(SERVICE_NAME, service.getQName().getLocalPart());
                map.put(SERVICE_NS, targetNs);
                map.put(PORT_NAME, port.getName());
                map.put(PORT_NS, targetNs);
                map.put(OPERATION_NAME, operationName);
                map.put(WSDL_LOCATION, wsdlURI.getLocation().toPortableString());
                BindingOperation bindingOperation = port.getBinding().getBindingOperation(operationName, null, null);
                if (null == bindingOperation) {
                    throw getCoreException("Operation '" + operationName + "' not found in binding", null);
                }
                map.put(COMMUNICATION_STYLE, null == bindingOperation.getBindingOutput() && bindingOperation.getBindingFaults().isEmpty() ? ONE_WAY : REQUEST_RESPONSE);
                String faults = null;
                for (Object fault : bindingOperation.getBindingFaults().keySet()) {
                    if (faults == null) {
                        faults = (String) fault;
                    } else {
                        faults += ',' + (String) fault;
                    }
                }
                map.put(FAULTS, faults);
                // map.put(OPERATION_NS, targetNs);
                map.put(ENDPOINT_URI, getPortAddress(port));
                break;
            }
        }
    }
    return map;
}
Also used : BindingOperation(javax.wsdl.BindingOperation) HashMap(java.util.HashMap) ServicePort(org.talend.repository.services.model.services.ServicePort) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 52 with Service

use of javax.wsdl.Service in project tomee by apache.

the class WsDeployer method getLocationFromWsdl.

private String getLocationFromWsdl(final Definition definition, final PortComponent portComponent) {
    if (definition == null) {
        return null;
    }
    try {
        final Service service = definition.getService(portComponent.getWsdlService());
        if (service == null) {
            return null;
        }
        final Port port = service.getPort(portComponent.getWsdlPort().getLocalPart());
        if (port == null) {
            return null;
        }
        for (final Object element : port.getExtensibilityElements()) {
            if (element instanceof SOAPAddress) {
                final SOAPAddress soapAddress = (SOAPAddress) element;
                final URI uri = URLs.uri(soapAddress.getLocationURI());
                return uri.getPath();
            } else if (element instanceof HTTPAddress) {
                final HTTPAddress httpAddress = (HTTPAddress) element;
                final URI uri = URLs.uri(httpAddress.getLocationURI());
                return uri.getPath();
            }
        }
    } catch (final Exception e) {
    // no-op
    }
    return null;
}
Also used : HTTPAddress(javax.wsdl.extensions.http.HTTPAddress) Port(javax.wsdl.Port) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) Service(javax.wsdl.Service) URI(java.net.URI) MalformedURLException(java.net.MalformedURLException) OpenEJBException(org.apache.openejb.OpenEJBException) IOException(java.io.IOException)

Example 53 with Service

use of javax.wsdl.Service in project tomee by apache.

the class WsdlVisitor method walkTree.

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();
    }
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) Binding(javax.wsdl.Binding) Import(javax.wsdl.Import) Message(javax.wsdl.Message) BindingFault(javax.wsdl.BindingFault) Port(javax.wsdl.Port) Service(javax.wsdl.Service) BindingFault(javax.wsdl.BindingFault) Fault(javax.wsdl.Fault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) BindingOperation(javax.wsdl.BindingOperation) BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) Part(javax.wsdl.Part) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) Iterator(java.util.Iterator) Collection(java.util.Collection) List(java.util.List) Map(java.util.Map) PortType(javax.wsdl.PortType)

Aggregations

Service (javax.wsdl.Service)53 Port (javax.wsdl.Port)37 QName (javax.xml.namespace.QName)28 Definition (javax.wsdl.Definition)21 Test (org.junit.Test)16 Binding (javax.wsdl.Binding)12 File (java.io.File)10 HashMap (java.util.HashMap)10 Map (java.util.Map)8 BindingOperation (javax.wsdl.BindingOperation)8 WSDLReader (javax.wsdl.xml.WSDLReader)8 SOAPAddress (javax.wsdl.extensions.soap.SOAPAddress)7 ToolException (org.apache.cxf.tools.common.ToolException)6 List (java.util.List)5 Operation (javax.wsdl.Operation)5 Part (javax.wsdl.Part)5 PortType (javax.wsdl.PortType)5 WSDLFactory (javax.wsdl.factory.WSDLFactory)5 Bus (org.apache.cxf.Bus)5 URI (java.net.URI)4