Search in sources :

Example 6 with Service

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

the class WSDLToCorbaBindingTypeTest method testSetCorbaAddress.

@Test
public void testSetCorbaAddress() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/datetime.wsdl").toString();
        generator.setWsdlFile(fileName);
        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);
        generator.setAddress("corbaloc::localhost:40000/hw");
        model = generator.generateCORBABinding();
        service = model.getService(name);
        port = service.getPort("BaseCORBAPort");
        addressType = (AddressType) port.getExtensibilityElements().get(0);
        address = addressType.getLocation();
        assertEquals("corbaloc::localhost:40000/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) File(java.io.File) Test(org.junit.Test)

Example 7 with Service

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

the class ServiceModelUtilTest method setUp.

@Before
public void setUp() throws Exception {
    String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(wsdlUrl);
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            break;
        }
    }
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
}
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 8 with Service

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

the class ServiceWSDLBuilder method buildService.

protected void buildService(ServiceInfo serviceInfo, Definition definition) {
    Map<QName, MessageInfo> messages = serviceInfo.getMessages();
    for (Map.Entry<QName, MessageInfo> mie : messages.entrySet()) {
        if (!mie.getKey().getNamespaceURI().equals(definition.getTargetNamespace())) {
            continue;
        }
        if (definition.getMessage(mie.getKey()) != null) {
            continue;
        }
        Message message = definition.createMessage();
        addDocumentation(message, mie.getValue().getMessageDocumentation());
        message.setUndefined(false);
        message.setQName(mie.getKey());
        for (MessagePartInfo mpi : mie.getValue().getMessageParts()) {
            Part part = definition.createPart();
            boolean elemental = mpi.isElement();
            // RFSB will turn on isElement bogusly.
            if (elemental && null == serviceInfo.getXmlSchemaCollection().getElementByQName(mpi.getElementQName())) {
                elemental = false;
            }
            if (elemental) {
                part.setElementName(mpi.getElementQName());
            } else {
                part.setTypeName(mpi.getTypeQName());
            }
            part.setName(mpi.getName().getLocalPart());
            message.addPart(part);
        }
        definition.addMessage(message);
    }
    addDocumentation(definition, serviceInfo.getTopLevelDoc());
    Service serv = definition.createService();
    addDocumentation(serv, serviceInfo.getDocumentation());
    serv.setQName(serviceInfo.getName());
    addNamespace(serviceInfo.getName().getNamespaceURI(), definition);
    addExtensibilityElements(definition, serv, getWSDL11Extensors(serviceInfo));
    definition.addService(serv);
    for (EndpointInfo ei : serviceInfo.getEndpoints()) {
        addNamespace(ei.getTransportId(), definition);
        Port port = definition.createPort();
        addDocumentation(port, ei.getDocumentation());
        port.setName(ei.getName().getLocalPart());
        port.setBinding(definition.getBinding(ei.getBinding().getName()));
        addExtensibilityElements(definition, port, getWSDL11Extensors(ei));
        serv.addPort(port);
    }
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) Part(javax.wsdl.Part) Port(javax.wsdl.Port) Service(javax.wsdl.Service) Map(java.util.Map) HashMap(java.util.HashMap) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 9 with Service

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

the class WSDLManagerImplTest method testBuildImportedWSDL.

@Test
public void testBuildImportedWSDL() throws Exception {
    String wsdlUrl = getClass().getResource("hello_world_services.wsdl").toString();
    WSDLManagerImpl builder = new WSDLManagerImpl();
    Definition def = builder.getDefinition(wsdlUrl);
    assertNotNull(def);
    Map<?, ?> services = def.getServices();
    assertNotNull(services);
    assertEquals(1, services.size());
    String serviceQName = "http://apache.org/hello_world/services";
    Service service = (Service) services.get(new QName(serviceQName, "SOAPService"));
    assertNotNull(service);
    Map<?, ?> ports = service.getPorts();
    assertNotNull(ports);
    assertEquals(1, ports.size());
    Port port = service.getPort("SoapPort");
    assertNotNull(port);
    Binding binding = port.getBinding();
    assertNotNull(binding);
    QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding");
    assertEquals(bindingQName, binding.getQName());
    PortType portType = binding.getPortType();
    assertNotNull(portType);
    QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter");
    assertEquals(portTypeQName, portType.getQName());
    Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
    assertNotNull(op1);
    QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest");
    assertEquals(messageQName, op1.getInput().getMessage().getQName());
    Part part = op1.getInput().getMessage().getPart("in");
    assertNotNull(part);
    assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName());
}
Also used : Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) Part(javax.wsdl.Part) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) Operation(javax.wsdl.Operation) PortType(javax.wsdl.PortType) Test(org.junit.Test)

Example 10 with Service

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

the class CorbaObjectReferenceHelper method getEndpointName.

public static String getEndpointName(Binding binding, Definition wsdlDef) {
    LOG.log(Level.FINE, "Getting endpoint name for an object reference");
    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(binding)) {
                return pt.getName();
            }
        }
    }
    return null;
}
Also used : Port(javax.wsdl.Port) 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