Search in sources :

Example 31 with Service

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

the class WSDLManagerImplTest method testBuildSimpleWSDL.

@Test
public void testBuildSimpleWSDL() throws Exception {
    String qname = "http://apache.org/hello_world_soap_http";
    String wsdlUrl = getClass().getResource("hello_world.wsdl").toString();
    WSDLManagerImpl builder = new WSDLManagerImpl();
    Definition def = builder.getDefinition(wsdlUrl);
    assertNotNull(def);
    Map<?, ?> services = def.getServices();
    assertNotNull(services);
    assertEquals(1, services.size());
    Service service = (Service) services.get(new QName(qname, "SOAPService"));
    assertNotNull(service);
    Map<?, ?> ports = service.getPorts();
    assertNotNull(ports);
    assertEquals(1, ports.size());
    Port port = service.getPort("SoapPort");
    assertNotNull(port);
}
Also used : QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) Test(org.junit.Test)

Example 32 with Service

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

the class WSDLServiceBuilderTest method setUpDefinition.

private void setUpDefinition(String wsdl, int serviceSeq) throws Exception {
    URL url = getClass().getResource(wsdl);
    assertNotNull("could not find wsdl " + wsdl, url);
    String wsdlUrl = url.toString();
    LOG.info("the path of wsdl file is " + wsdlUrl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(new CatalogWSDLLocator(wsdlUrl));
    int seq = 0;
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            if (seq == serviceSeq) {
                break;
            }
            seq++;
        }
    }
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) Service(javax.wsdl.Service) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 33 with Service

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

the class TestBase method getMockedServiceModel.

protected ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    Definition def = wsdlReader.readWSDL(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) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 34 with Service

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

the class JAXBDataBindingTest method setUp.

@Before
public void setUp() throws Exception {
    jaxbDataBinding = new JAXBDataBinding();
    String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
    LOG.info("the path of wsdl file is " + wsdlUrl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(wsdlUrl);
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(destinationFactoryManager);
    control.replay();
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            break;
        }
    }
    wsdlServiceBuilder.buildServices(def, service);
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLReader(javax.wsdl.xml.WSDLReader) Before(org.junit.Before)

Example 35 with Service

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

the class WSDLToCorbaBinding method generateCORBAServiceForBinding.

private void generateCORBAServiceForBinding(Definition definition, PortType portType, Binding binding) throws Exception {
    if (extReg == null) {
        extReg = def.getExtensionRegistry();
    }
    String interfaceName = portType.getQName().getLocalPart();
    interfaceName = mangleInterfaceName(interfaceName);
    String serviceName = interfaceName + "CORBAService";
    String portName = interfaceName + "CORBAPort";
    String prefix = definition.getPrefix(definition.getTargetNamespace());
    if (prefix == null) {
        prefix = "";
    }
    String corbaPrefix = definition.getPrefix(CorbaConstants.NU_WSDL_CORBA);
    if (corbaPrefix == null) {
        corbaPrefix = "corba";
        def.addNamespace(corbaPrefix, CorbaConstants.NU_WSDL_CORBA);
    }
    // Build the service and port information and add it to the wsdl
    Service service = def.createService();
    Port servicePort = def.createPort();
    servicePort.setName(portName);
    servicePort.setBinding(binding);
    try {
        AddressType addressType = (AddressType) def.getExtensionRegistry().createExtension(Port.class, CorbaConstants.NE_CORBA_ADDRESS);
        String addr = null;
        if (getAddressFile() != null) {
            BufferedReader bufferedReader = null;
            try {
                File addrFile = new File(getAddressFile());
                FileReader fileReader = new FileReader(addrFile);
                bufferedReader = new BufferedReader(fileReader);
                addr = bufferedReader.readLine();
            } catch (Exception ex) {
                throw new ToolException(ex.getMessage(), ex);
            } finally {
                if (bufferedReader != null) {
                    bufferedReader.close();
                }
            }
        } else {
            addr = getAddress();
        }
        if (addr == null) {
            addr = "file:./" + interfaceName + ".ref";
        }
        addressType.setLocation(addr);
        servicePort.addExtensibilityElement((ExtensibilityElement) addressType);
    } catch (WSDLException ex) {
        throw new Exception("Failed to create CORBA address for service", ex);
    }
    QName serviceQName = new QName(definition.getTargetNamespace(), serviceName, prefix);
    service.setQName(serviceQName);
    service.addPort(servicePort);
    definition.addService(service);
}
Also used : WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) BufferedReader(java.io.BufferedReader) Service(javax.wsdl.Service) FileReader(java.io.FileReader) ToolException(org.apache.cxf.tools.common.ToolException) AddressType(org.apache.cxf.binding.corba.wsdl.AddressType) File(java.io.File) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException)

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