Search in sources :

Example 6 with LocalTransportFactory

use of org.apache.cxf.transport.local.LocalTransportFactory in project cxf by apache.

the class PolicyAnnotationTest method testAnnotations.

@org.junit.Test
public void testAnnotations() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestImpl());
    factory.setStart(false);
    List<String> tp = Arrays.asList("http://schemas.xmlsoap.org/soap/http", "http://schemas.xmlsoap.org/wsdl/http/", "http://schemas.xmlsoap.org/wsdl/soap/http", "http://www.w3.org/2003/05/soap/bindings/HTTP/", "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat");
    LocalTransportFactory f = new LocalTransportFactory();
    f.getUriPrefixes().add("http");
    f.setTransportIds(tp);
    Server s = factory.create();
    try {
        ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
        Definition def = builder.build();
        WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
        def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
        Element wsdl = wsdlWriter.getDocument(def).getDocumentElement();
        Map<String, String> ns = new HashMap<>();
        ns.put("wsdl", WSDLConstants.NS_WSDL11);
        ns.put("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
        ns.put("wsp", Constants.URI_POLICY_13_NS);
        XPathUtils xpu = new XPathUtils(ns);
        // org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
        check(xpu, wsdl, "/wsdl:definitions/wsdl:service/wsdl:port", "TestImplPortPortPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/", "TestInterfacePortTypePolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/", "echoIntPortTypeOpPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:input", "echoIntPortTypeOpInputPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:output", "echoIntPortTypeOpOutputPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/", "TestImplServiceSoapBindingBindingPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/", "echoIntBindingOpPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:input", "echoIntBindingOpInputPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:output", "echoIntBindingOpOutputPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:service/", "TestImplServiceServicePolicy");
        assertEquals(1, xpu.getValueList("/wsdl:definitions/wsdl:binding/wsdl:operation/" + "wsp:PolicyReference[@URI='#echoIntBindingOpPolicy']", wsdl).getLength());
        EndpointPolicy policy = bus.getExtension(PolicyEngine.class).getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null, null);
        assertNotNull(policy);
        assertEquals(1, policy.getChosenAlternative().size());
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) HashMap(java.util.HashMap) LocalTransportFactory(org.apache.cxf.transport.local.LocalTransportFactory) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) WSDLWriter(javax.wsdl.xml.WSDLWriter) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder) EndpointPolicy(org.apache.cxf.ws.policy.EndpointPolicy) XPathUtils(org.apache.cxf.helpers.XPathUtils) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 7 with LocalTransportFactory

use of org.apache.cxf.transport.local.LocalTransportFactory in project cxf by apache.

the class PolicyAnnotationTest method testAnnotationImplNoInterfacePolicies.

@org.junit.Test
public void testAnnotationImplNoInterfacePolicies() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestImplWithPoliciesNoInterface());
    factory.setStart(false);
    List<String> tp = Arrays.asList("http://schemas.xmlsoap.org/soap/http", "http://schemas.xmlsoap.org/wsdl/http/", "http://schemas.xmlsoap.org/wsdl/soap/http", "http://www.w3.org/2003/05/soap/bindings/HTTP/", "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat");
    LocalTransportFactory f = new LocalTransportFactory();
    f.getUriPrefixes().add("http");
    f.setTransportIds(tp);
    Server s = factory.create();
    try {
        ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
        Definition def = builder.build();
        WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
        def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
        Element wsdl = wsdlWriter.getDocument(def).getDocumentElement();
        Map<String, String> ns = new HashMap<>();
        ns.put("wsdl", WSDLConstants.NS_WSDL11);
        ns.put("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
        ns.put("wsp", Constants.URI_POLICY_13_NS);
        XPathUtils xpu = new XPathUtils(ns);
        // org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
        assertEquals(1, xpu.getValueList("/wsdl:definitions/wsdl:binding/" + "wsp:PolicyReference[@URI='#TestImplWithPoliciesNoInterfaceServiceSoapBindingBindingPolicy']", wsdl).getLength());
        final EndpointPolicy policy = bus.getExtension(PolicyEngine.class).getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null, null);
        assertNotNull(policy);
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) HashMap(java.util.HashMap) LocalTransportFactory(org.apache.cxf.transport.local.LocalTransportFactory) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) WSDLWriter(javax.wsdl.xml.WSDLWriter) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder) EndpointPolicy(org.apache.cxf.ws.policy.EndpointPolicy) XPathUtils(org.apache.cxf.helpers.XPathUtils) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 8 with LocalTransportFactory

use of org.apache.cxf.transport.local.LocalTransportFactory in project cxf by apache.

the class PolicyAnnotationTest method testAnnotationsInterfaceAsClass.

@org.junit.Test
public void testAnnotationsInterfaceAsClass() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestImpl());
    factory.setServiceClass(TestInterface.class);
    factory.setStart(false);
    List<String> tp = Arrays.asList("http://schemas.xmlsoap.org/soap/http", "http://schemas.xmlsoap.org/wsdl/http/", "http://schemas.xmlsoap.org/wsdl/soap/http", "http://www.w3.org/2003/05/soap/bindings/HTTP/", "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat");
    LocalTransportFactory f = new LocalTransportFactory();
    f.getUriPrefixes().add("http");
    f.setTransportIds(tp);
    Server s = factory.create();
    try {
        ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
        Definition def = builder.build();
        WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
        def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
        Element wsdl = wsdlWriter.getDocument(def).getDocumentElement();
        Map<String, String> ns = new HashMap<>();
        ns.put("wsdl", WSDLConstants.NS_WSDL11);
        ns.put("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
        ns.put("wsp", Constants.URI_POLICY_13_NS);
        XPathUtils xpu = new XPathUtils(ns);
        // org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
        check(xpu, wsdl, "/wsdl:definitions/wsdl:service/wsdl:port", "TestInterfacePortPortPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/", "TestInterfacePortTypePolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/", "echoIntPortTypeOpPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:input", "echoIntPortTypeOpInputPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:output", "echoIntPortTypeOpOutputPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/", "TestInterfaceServiceSoapBindingBindingPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/", "echoIntBindingOpPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:input", "echoIntBindingOpInputPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:output", "echoIntBindingOpOutputPolicy");
        check(xpu, wsdl, "/wsdl:definitions/wsdl:service/", "TestInterfaceServiceServicePolicy");
        assertEquals(1, xpu.getValueList("/wsdl:definitions/wsdl:binding/wsdl:operation/" + "wsp:PolicyReference[@URI='#echoIntBindingOpPolicy']", wsdl).getLength());
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) HashMap(java.util.HashMap) LocalTransportFactory(org.apache.cxf.transport.local.LocalTransportFactory) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) WSDLWriter(javax.wsdl.xml.WSDLWriter) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder) XPathUtils(org.apache.cxf.helpers.XPathUtils) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 9 with LocalTransportFactory

use of org.apache.cxf.transport.local.LocalTransportFactory in project cxf by apache.

the class AbstractSimpleFrontendTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUpBus();
    Bus bus = getBus();
    SoapBindingFactory bindingFactory = new SoapBindingFactory();
    bus.getExtension(BindingFactoryManager.class).registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    SoapTransportFactory soapTF = new SoapTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapTF);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapTF);
    LocalTransportFactory localTransport = new LocalTransportFactory();
    localTransport.getUriPrefixes().add("http");
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
    ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
    extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", soapTF);
}
Also used : Bus(org.apache.cxf.Bus) 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) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) SoapTransportFactory(org.apache.cxf.binding.soap.SoapTransportFactory) Before(org.junit.Before)

Aggregations

LocalTransportFactory (org.apache.cxf.transport.local.LocalTransportFactory)9 Bus (org.apache.cxf.Bus)7 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)5 HashMap (java.util.HashMap)4 Definition (javax.wsdl.Definition)4 WSDLWriter (javax.wsdl.xml.WSDLWriter)4 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)4 SoapBindingFactory (org.apache.cxf.binding.soap.SoapBindingFactory)4 SoapTransportFactory (org.apache.cxf.binding.soap.SoapTransportFactory)4 Server (org.apache.cxf.endpoint.Server)4 XPathUtils (org.apache.cxf.helpers.XPathUtils)4 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)4 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)4 ServiceWSDLBuilder (org.apache.cxf.wsdl11.ServiceWSDLBuilder)4 Before (org.junit.Before)4 Element (org.w3c.dom.Element)4 EndpointPolicy (org.apache.cxf.ws.policy.EndpointPolicy)3 PolicyEngine (org.apache.cxf.ws.policy.PolicyEngine)3 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1