Search in sources :

Example 51 with Definition

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

the class WSDLGetUtils method updateWSDLKeyDefinition.

/**
 * Create a wsdl Definition object from the endpoint information and register
 * it in the local data structure for future reference.
 *
 * @param bus CXF's hub for access to internal constructs
 * @param mp  a map of known wsdl Definition objects
 * @param message
 * @param smp a map of known xsd SchemaReference objects
 * @param base the request URL
 * @param endpointInfo information for a web service 'port' inside of a service
 * @throws WSDLException
 */
protected void updateWSDLKeyDefinition(Bus bus, Map<String, Definition> mp, Message message, Map<String, SchemaReference> smp, String base, EndpointInfo endpointInfo) throws WSDLException {
    if (!mp.containsKey("")) {
        ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, endpointInfo.getService());
        builder.setUseSchemaImports(MessageUtils.getContextualBoolean(message, WSDL_CREATE_IMPORTS, false));
        // base file name is ignored if createSchemaImports == false!
        builder.setBaseFileName(endpointInfo.getService().getName().getLocalPart());
        Definition def = builder.build(new HashMap<String, SchemaInfo>());
        mp.put("", def);
        updateDefinition(bus, def, mp, smp, base, "", "");
    }
}
Also used : Definition(javax.wsdl.Definition) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Example 52 with Definition

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

the class PolicyAnnotationTest method testAnnotationImplNoInterface.

@org.junit.Test
public void testAnnotationImplNoInterface() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestImplNoInterface());
    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='#TestImplNoInterfaceServiceSoapBindingBindingPolicy']", 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 53 with Definition

use of javax.wsdl.Definition 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);
    Definition def = wsdlReader.readWSDL(wsdlUrl);
    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 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) 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) Before(org.junit.Before)

Example 54 with Definition

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

the class SoapBindingFactoryTest method testFactory.

@Test
public void testFactory() throws Exception {
    Definition d = createDefinition("/wsdl_soap/hello_world.wsdl");
    Bus bus = getMockBus();
    BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP11, bus);
    bus.getExtension(BindingFactoryManager.class);
    expectLastCall().andReturn(bfm).anyTimes();
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    ServiceInfo serviceInfo = builder.buildServices(d, new QName("http://apache.org/hello_world_soap_http", "SOAPService")).get(0);
    BindingInfo bi = serviceInfo.getBindings().iterator().next();
    assertTrue(bi instanceof SoapBindingInfo);
    SoapBindingInfo sbi = (SoapBindingInfo) bi;
    assertEquals("document", sbi.getStyle());
    assertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI()));
    assertTrue(sbi.getSoapVersion() instanceof Soap11);
    BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap_http", "sayHi"));
    SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
    assertNotNull(sboi);
    assertEquals("document", sboi.getStyle());
    assertEquals("", sboi.getAction());
    BindingMessageInfo input = boi.getInput();
    SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
    assertEquals("literal", bodyInfo.getUse());
    List<MessagePartInfo> parts = bodyInfo.getParts();
    assertNotNull(parts);
    assertEquals(1, parts.size());
}
Also used : Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapBodyInfo(org.apache.cxf.binding.soap.model.SoapBodyInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) Test(org.junit.Test)

Example 55 with Definition

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

the class CodeFirstWSDLTest method testDocumentationOnImpl.

@Test
public void testDocumentationOnImpl() throws Exception {
    // CXF-3092
    EndpointImpl ep = (EndpointImpl) Endpoint.publish("local://foo", new CXF3092Impl());
    ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, ep.getService().getServiceInfos().get(0));
    Definition def = wsdlBuilder.build();
    Document d = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter().getDocument(def);
    // org.apache.cxf.helpers.XMLUtils.printDOM(d);
    assertXPathEquals("//wsdl:definitions/wsdl:documentation", "My top level documentation", d.getDocumentElement());
    assertXPathEquals("//wsdl:definitions/wsdl:service/wsdl:documentation", "My Service documentation", d.getDocumentElement());
    assertXPathEquals("//wsdl:definitions/wsdl:binding/wsdl:documentation", "My binding doc", d.getDocumentElement());
    JaxwsServiceBuilder builder = new JaxwsServiceBuilder();
    builder.setServiceClass(CXF3092Impl.class);
    ServiceInfo serviceInfo = builder.createService();
    wsdlBuilder = new ServiceWSDLBuilder(bus, serviceInfo);
    def = wsdlBuilder.build();
    d = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter().getDocument(def);
    // org.apache.cxf.helpers.XMLUtils.printDOM(d);
    assertXPathEquals("//wsdl:definitions/wsdl:documentation", "My top level documentation", d.getDocumentElement());
    assertXPathEquals("//wsdl:definitions/wsdl:service/wsdl:documentation", "My Service documentation", d.getDocumentElement());
    assertXPathEquals("//wsdl:definitions/wsdl:binding/wsdl:documentation", "My binding doc", d.getDocumentElement());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Definition(javax.wsdl.Definition) WSDLManager(org.apache.cxf.wsdl.WSDLManager) Document(org.w3c.dom.Document) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder) Test(org.junit.Test)

Aggregations

Definition (javax.wsdl.Definition)226 Test (org.junit.Test)113 QName (javax.xml.namespace.QName)61 File (java.io.File)52 Document (org.w3c.dom.Document)44 Element (org.w3c.dom.Element)40 HashMap (java.util.HashMap)36 WSDLReader (javax.wsdl.xml.WSDLReader)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)31 JBossWSTest (org.jboss.wsf.test.JBossWSTest)31 Service (javax.wsdl.Service)24 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)23 URL (java.net.URL)21 ArrayList (java.util.ArrayList)21 Port (javax.wsdl.Port)21 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)21 Bus (org.apache.cxf.Bus)20 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)20 WSDLManager (org.apache.cxf.wsdl.WSDLManager)20 IOException (java.io.IOException)18