Search in sources :

Example 41 with Service

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

the class CorbaObjectReferenceHelper method populateEprInfo.

public static void populateEprInfo(EprMetaData info) {
    if (!info.isValid()) {
        return;
    }
    Binding match = info.getBinding();
    Definition wsdlDef = info.getCandidateWsdlDef();
    Collection<Service> services = CastUtils.cast(wsdlDef.getServices().values());
    for (Service serv : services) {
        Collection<Port> ports = CastUtils.cast(serv.getPorts().values());
        for (Port pt : ports) {
            if (pt.getBinding().equals(match)) {
                info.setPortName(pt.getName());
                info.setServiceQName(serv.getQName());
                break;
            }
        }
    }
    if (info.getServiceQName() == null) {
        Iterator<?> importLists = wsdlDef.getImports().values().iterator();
        while (info.getServiceQName() == null && 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.FINE, "following wsdl import " + importDef.getDocumentBaseURI());
                    info.setCandidateWsdlDef(importDef);
                    populateEprInfo(info);
                    if (info.getServiceQName() != null) {
                        break;
                    }
                }
            }
        }
    }
}
Also used : Binding(javax.wsdl.Binding) Import(javax.wsdl.Import) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) List(java.util.List)

Example 42 with Service

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

the class JaxWsServiceConfigurationTest method getMockedServiceModel.

private ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    Definition def = wsdlReader.readWSDL(new CatalogWSDLLocator(wsdlUrl));
    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    Service service = null;
    for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
        Object obj = it.next();
        if (obj instanceof Service) {
            service = (Service) obj;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
    return serviceInfo;
}
Also used : IMocksControl(org.easymock.IMocksControl) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) Definition(javax.wsdl.Definition) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) WebService(javax.jws.WebService) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 43 with Service

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

the class WSDLRefValidator method collectValidationPointsForBindings.

private void collectValidationPointsForBindings() throws Exception {
    Map<QName, XNode> vBindingNodes = new HashMap<>();
    for (Service service : services.values()) {
        vBindingNodes.putAll(getBindings(service));
    }
    for (Map.Entry<QName, XNode> entry : vBindingNodes.entrySet()) {
        QName bName = entry.getKey();
        Binding binding = this.definition.getBinding(bName);
        if (binding == null) {
            LOG.log(Level.SEVERE, bName.toString() + " is not correct, please check that the correct namespace is being used");
            throw new Exception(bName.toString() + " is not correct, please check that the correct namespace is being used");
        }
        XNode vBindingNode = getXNode(binding);
        vBindingNode.setFailurePoint(entry.getValue());
        vNodes.add(vBindingNode);
        if (binding.getPortType() == null) {
            continue;
        }
        portTypeRefNames.add(binding.getPortType().getQName());
        XNode vPortTypeNode = getXNode(binding.getPortType());
        vPortTypeNode.setFailurePoint(vBindingNode);
        vNodes.add(vPortTypeNode);
        Collection<BindingOperation> bops = CastUtils.cast(binding.getBindingOperations());
        for (BindingOperation bop : bops) {
            XNode vOpNode = getOperationXNode(vPortTypeNode, bop.getName());
            XNode vBopNode = getOperationXNode(vBindingNode, bop.getName());
            vOpNode.setFailurePoint(vBopNode);
            vNodes.add(vOpNode);
            if (bop.getBindingInput() != null) {
                String inName = bop.getBindingInput().getName();
                if (!StringUtils.isEmpty(inName)) {
                    XNode vInputNode = getInputXNode(vOpNode, inName);
                    vInputNode.setFailurePoint(getInputXNode(vBopNode, inName));
                    vNodes.add(vInputNode);
                }
            }
            if (bop.getBindingOutput() != null) {
                String outName = bop.getBindingOutput().getName();
                if (!StringUtils.isEmpty(outName)) {
                    XNode vOutputNode = getOutputXNode(vOpNode, outName);
                    vOutputNode.setFailurePoint(getOutputXNode(vBopNode, outName));
                    vNodes.add(vOutputNode);
                }
            }
            for (Iterator<?> iter1 = bop.getBindingFaults().keySet().iterator(); iter1.hasNext(); ) {
                String faultName = (String) iter1.next();
                XNode vFaultNode = getFaultXNode(vOpNode, faultName);
                vFaultNode.setFailurePoint(getFaultXNode(vBopNode, faultName));
                vNodes.add(vFaultNode);
            }
        }
    }
}
Also used : XBinding(org.apache.cxf.tools.validator.internal.model.XBinding) Binding(javax.wsdl.Binding) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) XNode(org.apache.cxf.tools.validator.internal.model.XNode) Service(javax.wsdl.Service) XService(org.apache.cxf.tools.validator.internal.model.XService) URISyntaxException(java.net.URISyntaxException) ToolException(org.apache.cxf.tools.common.ToolException) BindingOperation(javax.wsdl.BindingOperation) Map(java.util.Map) HashMap(java.util.HashMap)

Example 44 with Service

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

the class WSDLToCorbaBindingTypeTest method testSetCorbaAddressFile.

@Test
public void testSetCorbaAddressFile() throws Exception {
    try {
        URI fileName = getClass().getResource("/wsdl/datetime.wsdl").toURI();
        generator.setWsdlFile(new File(fileName).getAbsolutePath());
        generator.addInterfaceName("BasePortType");
        Definition model = generator.generateCORBABinding();
        QName name = new QName("http://schemas.apache.org/idl/datetime.idl", "BaseCORBAService", "tns");
        Service service = model.getService(name);
        Port port = service.getPort("BaseCORBAPort");
        AddressType addressType = (AddressType) port.getExtensibilityElements().get(0);
        String address = addressType.getLocation();
        assertEquals("file:./Base.ref", address);
        URL idl = getClass().getResource("/wsdl/addressfile.txt");
        String filename = new File(idl.toURI()).getAbsolutePath();
        generator.setAddressFile(filename);
        model = generator.generateCORBABinding();
        service = model.getService(name);
        port = service.getPort("BaseCORBAPort");
        addressType = (AddressType) port.getExtensibilityElements().get(0);
        address = addressType.getLocation();
        assertEquals("corbaloc::localhost:60000/hw", address);
    } finally {
        new File("datetime-corba.wsdl").deleteOnExit();
    }
}
Also used : QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) AddressType(org.apache.cxf.binding.corba.wsdl.AddressType) URI(java.net.URI) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 45 with Service

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

the class EmbeddedJMSBrokerLauncher method updateWsdlExtensors.

public static void updateWsdlExtensors(Bus bus, String wsdlLocation, String url, String encodedUrl) {
    try {
        if (encodedUrl == null) {
            encodedUrl = url;
        }
        if (bus == null) {
            bus = BusFactory.getThreadDefaultBus();
        }
        Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlLocation);
        Map<?, ?> map = def.getAllServices();
        for (Object o : map.values()) {
            Service service = (Service) o;
            Map<?, ?> ports = service.getPorts();
            adjustExtensibilityElements(service.getExtensibilityElements(), url, encodedUrl);
            for (Object p : ports.values()) {
                Port port = (Port) p;
                adjustExtensibilityElements(port.getExtensibilityElements(), url, encodedUrl);
                adjustExtensibilityElements(port.getBinding().getExtensibilityElements(), url, encodedUrl);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) WSDLManager(org.apache.cxf.wsdl.WSDLManager) BrokerService(org.apache.activemq.broker.BrokerService) Service(javax.wsdl.Service)

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