Search in sources :

Example 1 with WSDLManagerImpl

use of org.apache.cxf.wsdl11.WSDLManagerImpl in project cxf by apache.

the class AbstractAegisTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUpBus();
    SoapBindingFactory bindingFactory = new SoapBindingFactory();
    bindingFactory.setBus(bus);
    bus.getExtension(BindingFactoryManager.class).registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    SoapTransportFactory soapDF = new SoapTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
    dfm.registerDestinationFactory(SoapBindingConstants.SOAP11_BINDING_ID, soapDF);
    dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", soapDF);
    localTransport = new LocalTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
    dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", localTransport);
    dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", localTransport);
    ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
    extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
    extension.registerConduitInitiator(SoapBindingConstants.SOAP11_BINDING_ID, localTransport);
    bus.setExtension(new WSDLManagerImpl(), WSDLManager.class);
    // WoodstoxValidationImpl wstxVal = new WoodstoxValidationImpl();
    addNamespace("wsdl", WSDLConstants.NS_WSDL11);
    addNamespace("wsdlsoap", WSDLConstants.NS_SOAP11);
    addNamespace("xsd", WSDLConstants.NS_SCHEMA_XSD);
}
Also used : SoapBindingFactory(org.apache.cxf.binding.soap.SoapBindingFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) LocalTransportFactory(org.apache.cxf.transport.local.LocalTransportFactory) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) SoapTransportFactory(org.apache.cxf.binding.soap.SoapTransportFactory) Before(org.junit.Before)

Example 2 with WSDLManagerImpl

use of org.apache.cxf.wsdl11.WSDLManagerImpl in project cxf by apache.

the class Wsdl11AttachmentPolicyProviderTest method oneTimeSetUp.

@BeforeClass
public static void oneTimeSetUp() throws Exception {
    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    WSDLManager manager = new WSDLManagerImpl();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(dfm).anyTimes();
    EasyMock.expect(dfm.getDestinationFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    BindingFactoryManager bfm = control.createMock(BindingFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm).anyTimes();
    EasyMock.expect(bfm.getBindingFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    control.replay();
    int n = 19;
    services = new ServiceInfo[n];
    endpoints = new EndpointInfo[n];
    for (int i = 0; i < n; i++) {
        String resourceName = "/attachment/wsdl11/test" + i + ".wsdl";
        URL url = Wsdl11AttachmentPolicyProviderTest.class.getResource(resourceName);
        try {
            services[i] = builder.buildServices(manager.getDefinition(url.toString())).get(0);
        } catch (WSDLException ex) {
            ex.printStackTrace();
            fail("Failed to build service from resource " + resourceName);
        }
        assertNotNull(services[i]);
        endpoints[i] = services[i].getEndpoints().iterator().next();
        assertNotNull(endpoints[i]);
    }
    control.verify();
}
Also used : IMocksControl(org.easymock.IMocksControl) Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) WSDLException(javax.wsdl.WSDLException) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) WSDLManager(org.apache.cxf.wsdl.WSDLManager) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 3 with WSDLManagerImpl

use of org.apache.cxf.wsdl11.WSDLManagerImpl in project cxf by apache.

the class OASISCatalogTest method testClientWithoutCatalog.

@Test
public void testClientWithoutCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);
    // set Catalog on the Bus
    Bus bus = BusFactory.getDefaultBus();
    OASISCatalogManager catalog = new OASISCatalogManager();
    bus.setExtension(catalog, OASISCatalogManager.class);
    // prevent cache from papering over the lack of a schema.
    WSDLManagerImpl mgr = (WSDLManagerImpl) bus.getExtension(WSDLManager.class);
    mgr.setDisableSchemaCache(true);
    try {
        SOAPService service = new SOAPService(wsdl, serviceName);
        service.getPort(portName, Greeter.class);
        fail("Test did not fail as expected");
    } catch (WebServiceException e) {
    // ignore
    }
    // update catalog dynamically now
    Enumeration<URL> jaxwscatalog = getClass().getClassLoader().getResources("META-INF/jax-ws-catalog.xml");
    assertNotNull(jaxwscatalog);
    while (jaxwscatalog.hasMoreElements()) {
        URL url = jaxwscatalog.nextElement();
        catalog.loadCatalog(url);
    }
    SOAPService service = new SOAPService(wsdl, serviceName);
    Greeter greeter = service.getPort(portName, Greeter.class);
    assertNotNull(greeter);
    bus.shutdown(true);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Bus(org.apache.cxf.Bus) WebServiceException(javax.xml.ws.WebServiceException) Greeter(org.apache.hello_world.Greeter) OASISCatalogManager(org.apache.cxf.catalog.OASISCatalogManager) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) WSDLManager(org.apache.cxf.wsdl.WSDLManager) URL(java.net.URL) Test(org.junit.Test)

Example 4 with WSDLManagerImpl

use of org.apache.cxf.wsdl11.WSDLManagerImpl in project cxf by apache.

the class ServerImpl method registerCallback.

public String registerCallback(NestedCallback callbackObject) {
    try {
        W3CEndpointReference w3cEpr = callbackObject.getCallback();
        EndpointReferenceType callback = ProviderImpl.convertToInternal(w3cEpr);
        WSDLManager manager = new WSDLManagerImpl();
        QName interfaceName = EndpointReferenceUtils.getInterfaceName(callback, bus);
        String wsdlLocation = EndpointReferenceUtils.getWSDLLocation(callback);
        QName serviceName = EndpointReferenceUtils.getServiceName(callback, bus);
        String address = EndpointReferenceUtils.getAddress(callback);
        String portString = EndpointReferenceUtils.getPortName(callback);
        QName portName = new QName(serviceName.getNamespaceURI(), portString);
        StringBuilder seiName = new StringBuilder();
        seiName.append(JAXBUtils.namespaceURIToPackage(interfaceName.getNamespaceURI()));
        seiName.append(".");
        seiName.append(JAXBUtils.nameToIdentifier(interfaceName.getLocalPart(), JAXBUtils.IdentifierType.INTERFACE));
        Class<?> sei = null;
        try {
            sei = Class.forName(seiName.toString(), true, manager.getClass().getClassLoader());
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        URL wsdlURL = new URL(wsdlLocation);
        Service service = Service.create(wsdlURL, serviceName);
        CallbackPortType port = (CallbackPortType) service.getPort(portName, sei);
        ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
        port.serverSayHi("Sean");
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
    return "registerCallback called";
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) QName(javax.xml.namespace.QName) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) Service(javax.xml.ws.Service) URL(java.net.URL) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) CallbackPortType(org.apache.nested_callback.CallbackPortType) WSDLManager(org.apache.cxf.wsdl.WSDLManager)

Example 5 with WSDLManagerImpl

use of org.apache.cxf.wsdl11.WSDLManagerImpl in project cxf by apache.

the class TestBase method common.

protected void common(String wsdl, QName portName, Class<?>... jaxbClasses) throws Exception {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    WSDLManagerImpl manager = new WSDLManagerImpl();
    XMLWSDLExtensionLoader.registerExtensors(manager);
    EasyMock.expect(bus.getExtension(WSDLManager.class)).andStubReturn(manager);
    BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    assertNotNull(bus.getExtension(WSDLManager.class));
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass().getResource(wsdl).toString(), new QName(portName.getNamespaceURI(), "XMLService"));
    org.apache.cxf.service.Service service = factory.create();
    EndpointInfo epi = service.getEndpointInfo(portName);
    serviceInfo = epi.getService();
    assertNotNull(epi);
    Binding xmlBinding = new XMLBindingFactory().createBinding(epi.getBinding());
    control.reset();
    JAXBDataBinding db = new JAXBDataBinding();
    db.initialize(service);
    db.setContext(JAXBContext.newInstance(jaxbClasses));
    service.setDataBinding(db);
    Endpoint endpoint = control.createMock(EndpointImpl.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andStubReturn(epi);
    EasyMock.expect(endpoint.getBinding()).andStubReturn(xmlBinding);
    EasyMock.expect(endpoint.getService()).andStubReturn(service);
    EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
    control.replay();
    xmlMessage.getExchange().put(Endpoint.class, endpoint);
    xmlMessage.getExchange().put(org.apache.cxf.service.Service.class, service);
}
Also used : Binding(org.apache.cxf.binding.Binding) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) Bus(org.apache.cxf.Bus) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) QName(javax.xml.namespace.QName) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) WSDLManager(org.apache.cxf.wsdl.WSDLManager) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) XMLBindingFactory(org.apache.cxf.binding.xml.XMLBindingFactory)

Aggregations

WSDLManagerImpl (org.apache.cxf.wsdl11.WSDLManagerImpl)6 WSDLManager (org.apache.cxf.wsdl.WSDLManager)5 URL (java.net.URL)3 QName (javax.xml.namespace.QName)3 Bus (org.apache.cxf.Bus)3 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)3 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)3 Service (javax.xml.ws.Service)2 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)2 WSDLException (javax.wsdl.WSDLException)1 WebServiceException (javax.xml.ws.WebServiceException)1 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)1 CallbackPortType (org.apache.callback.CallbackPortType)1 Binding (org.apache.cxf.binding.Binding)1 SoapBindingFactory (org.apache.cxf.binding.soap.SoapBindingFactory)1 SoapTransportFactory (org.apache.cxf.binding.soap.SoapTransportFactory)1 XMLBindingFactory (org.apache.cxf.binding.xml.XMLBindingFactory)1 OASISCatalogManager (org.apache.cxf.catalog.OASISCatalogManager)1 Endpoint (org.apache.cxf.endpoint.Endpoint)1 JAXBDataBinding (org.apache.cxf.jaxb.JAXBDataBinding)1