org.apache.cxf.wsdl.WSDLManager Java Examples

The following examples show how to use org.apache.cxf.wsdl.WSDLManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLManagerImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testBuildSimpleWSDL() throws Exception {
    String qname = "http://apache.org/hello_world_soap_http";
    String wsdlUrl = getClass().getResource("hello_world.wsdl").toString();

    WSDLManager 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);
}
 
Example #2
Source File: ReflectionServiceFactorBeanTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmptyWsdlAndNoServiceClass() throws Exception {
    final String dummyWsdl = "target/dummy.wsdl";
    ReflectionServiceFactoryBean bean = new ReflectionServiceFactoryBean();
    Bus bus = control.createMock(Bus.class);

    WSDLManager wsdlmanager = control.createMock(WSDLManager.class);
    EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(wsdlmanager);
    EasyMock.expect(wsdlmanager.getDefinition(dummyWsdl))
        .andThrow(new WSDLException("PARSER_ERROR", "Problem parsing '" + dummyWsdl + "'."));
    EasyMock.expect(bus.getExtension(FactoryBeanListenerManager.class)).andReturn(null);

    control.replay();

    bean.setWsdlURL(dummyWsdl);
    bean.setServiceName(new QName("http://cxf.apache.org/hello_world_soap_http", "GreeterService"));
    bean.setBus(bus);

    try {
        bean.create();
        fail("no valid wsdl nor service class specified");
    } catch (ServiceConstructionException e) {
        // ignore
    }
}
 
Example #3
Source File: WSDLToProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void parseWSDL(String wsdlUrl) {
    try {
        Bus bus = BusFactory.getThreadDefaultBus();
        WSDLManager mgr = bus.getExtension(WSDLManager.class);
        wsdlDefinition = mgr.getDefinition(wsdlUrl);
        WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
        builder.buildMockServices(wsdlDefinition);
        schemas = mgr.getSchemasForDefinition(wsdlDefinition);

        //remove this as we're going to be modifying it
        mgr.removeDefinition(wsdlDefinition);

    } catch (WSDLException we) {
        org.apache.cxf.common.i18n.Message msg =
                new org.apache.cxf.common.i18n.Message(
                "FAIL_TO_CREATE_WSDL_DEFINITION", LOG);
        throw new ToolException(msg, we);
    }
}
 
Example #4
Source File: WSDLGenerationTester.java    From cxf with Apache License 2.0 6 votes vote down vote up
public File writeDefinition(File targetDir, File defnFile) throws Exception {
    WSDLManager wm = BusFactory.getThreadDefaultBus().getExtension(WSDLManager.class);
    File bkFile = new File(targetDir, "bk_" + defnFile.getName());
    FileWriter writer = new FileWriter(bkFile);
    WSDLFactory factory
        = WSDLFactory.newInstance("org.apache.cxf.tools.corba.utils.TestWSDLCorbaFactoryImpl");
    WSDLReader reader = factory.newWSDLReader();
    reader.setFeature("javax.wsdl.importDocuments", false);
    reader.setExtensionRegistry(wm.getExtensionRegistry());
    final String url = defnFile.toString();
    CatalogWSDLLocator locator = new CatalogWSDLLocator(url, (Bus)null);

    Definition wsdlDefn = reader.readWSDL(locator);

    WSDLWriter wsdlWriter = factory.newWSDLWriter();
    wsdlWriter.writeWSDL(wsdlDefn, writer);
    writer.close();
    writer = null;
    reader = null;
    return bkFile;
}
 
Example #5
Source File: SoapTransportFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void createSoapExtensors(Bus bus, EndpointInfo ei, SoapBindingInfo bi, boolean isSoap12) {
    try {

        String address = ei.getAddress();
        if (address == null) {
            address = "http://localhost:9090";
        }

        ExtensionRegistry registry = bus.getExtension(WSDLManager.class).getExtensionRegistry();
        SoapAddress soapAddress = SOAPBindingUtil.createSoapAddress(registry, isSoap12);
        soapAddress.setLocationURI(address);

        ei.addExtensor(soapAddress);

    } catch (WSDLException e) {
        e.printStackTrace();
    }
}
 
Example #6
Source File: AbstractWSDLToProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void parseWSDL(String wsdlURL) throws ToolException {
    Bus bus = env.get(Bus.class);
    if (bus == null) {
        bus = BusFactory.getThreadDefaultBus();
        env.put(Bus.class, bus);
    }
    WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(bus);
    wsdlDefinition = builder.build(wsdlURL);
    if (env.fullValidateWSDL()) {
        validate(wsdlDefinition, env, bus);
    }
    WSDLManager mgr = bus.getExtension(WSDLManager.class);
    mgr.removeDefinition(wsdlDefinition);

    wsdlFactory = mgr.getWSDLFactory();
    extReg = mgr.getExtensionRegistry();
    wsdlPlugins = builder.getWSDLPlugins();
}
 
Example #7
Source File: WSDLServiceBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void getSchemas(Definition def, ServiceInfo serviceInfo) {
    ServiceSchemaInfo serviceSchemaInfo = null;
    WSDLManager wsdlManager = bus.getExtension(WSDLManager.class);
    if (wsdlManager != null) {
        serviceSchemaInfo = wsdlManager.getSchemasForDefinition(def);
    }

    if (serviceSchemaInfo == null) {
        SchemaUtil schemaUtil = new SchemaUtil(bus, this.schemaList);
        schemaUtil.getSchemas(def, serviceInfo);
        serviceSchemaInfo = new ServiceSchemaInfo();
        serviceSchemaInfo.setSchemaElementList(this.schemaList);
        serviceSchemaInfo.setSchemaCollection(serviceInfo.getXmlSchemaCollection());
        serviceSchemaInfo.setSchemaInfoList(serviceInfo.getSchemas());
        if (wsdlManager != null) {
            wsdlManager.putSchemasForDefinition(def, serviceSchemaInfo);
        }
    } else {
        serviceInfo.setServiceSchemaInfo(serviceSchemaInfo);
        schemaList.putAll(serviceSchemaInfo.getSchemaElementList());
    }
}
 
Example #8
Source File: TestBase.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void common(String wsdl, QName portName, Class<?>... jaxbClasses) throws Exception {
    Bus bus = BusFactory.getDefaultBus();

    WSDLManagerImpl manager = new WSDLManagerImpl();
    XMLWSDLExtensionLoader.registerExtensors(manager);

    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);
    assertNotNull(epi);
    serviceInfo = epi.getService();

    JAXBDataBinding db = new JAXBDataBinding();
    db.initialize(service);
    db.setContext(JAXBContext.newInstance(jaxbClasses));
    service.setDataBinding(db);

    Endpoint endpoint = new EndpointImpl(bus, service, epi);

    xmlMessage.getExchange().put(Endpoint.class, endpoint);
    xmlMessage.getExchange().put(org.apache.cxf.service.Service.class, service);
}
 
Example #9
Source File: Wsdl11AttachmentPolicyProviderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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();

}
 
Example #10
Source File: SoapApiModelParser.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private static WSDLReader getWsdlReader() throws BusException {
    WSDLManager wsdlManager = new WSDLManagerImpl();
    // this is similar to what WSDLManager does,
    // but we need to read and store WSDL specification, so we create the reader ourselves
    final WSDLFactory wsdlFactory = wsdlManager.getWSDLFactory();
    final WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    wsdlReader.setFeature("javax.wsdl.importDocuments", true);
    wsdlReader.setExtensionRegistry(wsdlManager.getExtensionRegistry());
    return wsdlReader;
}
 
Example #11
Source File: AddressingWSDLExtensionLoader.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void createExtensor(WSDLManager manager,
                            Class<?> parentType,
                            Class<?> elementType) {
    try {
        JAXBExtensionHelper.addExtensions(manager.getExtensionRegistry(),
                                          parentType,
                                          elementType, null,
                                          this.getClass().getClassLoader());
    } catch (JAXBException e) {
        //ignore, won't support XML
    }
}
 
Example #12
Source File: WSDLManagerImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Resource
public final void setBus(Bus b) {
    bus = b;
    if (null != bus) {
        bus.setExtension(this, WSDLManager.class);
        ConfiguredBeanLocator loc = bus.getExtension(ConfiguredBeanLocator.class);
        if (loc != null) {
            loc.getBeansOfType(WSDLExtensionLoader.class);
        }
    }
}
 
Example #13
Source File: WSDLExtensionRegister.java    From cxf with Apache License 2.0 5 votes vote down vote up
void registerCXFExtensors(WSDLManager manager) {
    createExtensor(manager, javax.wsdl.Binding.class,
                         org.apache.cxf.binding.corba.wsdl.BindingType.class);
    createExtensor(manager, javax.wsdl.BindingOperation.class,
                         org.apache.cxf.binding.corba.wsdl.OperationType.class);
    createExtensor(manager, javax.wsdl.Definition.class,
                         org.apache.cxf.binding.corba.wsdl.TypeMappingType.class);
    createExtensor(manager, javax.wsdl.Port.class,
                         org.apache.cxf.binding.corba.wsdl.AddressType.class);
    createExtensor(manager, javax.wsdl.Port.class,
                         org.apache.cxf.binding.corba.wsdl.PolicyType.class);
}
 
Example #14
Source File: WSDLExtensionRegister.java    From cxf with Apache License 2.0 5 votes vote down vote up
void registerYokoCompatibleExtensors(WSDLManager manager) {
    createCompatExtensor(manager, javax.wsdl.Binding.class,
                         org.apache.cxf.binding.corba.wsdl.BindingType.class);
    createCompatExtensor(manager, javax.wsdl.BindingOperation.class,
                         org.apache.cxf.binding.corba.wsdl.OperationType.class);
    createCompatExtensor(manager, javax.wsdl.Definition.class,
                         org.apache.cxf.binding.corba.wsdl.TypeMappingType.class);
    createCompatExtensor(manager, javax.wsdl.Port.class,
                         org.apache.cxf.binding.corba.wsdl.AddressType.class);
    createCompatExtensor(manager, javax.wsdl.Port.class,
                         org.apache.cxf.binding.corba.wsdl.PolicyType.class);
}
 
Example #15
Source File: WSDLExtensionRegister.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void createExtensor(WSDLManager manager,
                            Class<?> parentType,
                            Class<?> elementType) {
    try {
        JAXBExtensionHelper.addExtensions(manager.getExtensionRegistry(),
                                          parentType,
                                          elementType,
                                          null,
                                          this.getClass().getClassLoader());
    } catch (JAXBException e) {
        //ignore, won't support CORBA
    }

}
 
Example #16
Source File: WSDLExtensionRegister.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void createCompatExtensor(WSDLManager manager,
                                  Class<?> parentType,
                                  Class<?> elementType) {
    try {
        JAXBExtensionHelper.addExtensions(manager.getExtensionRegistry(),
                                          parentType,
                                          elementType,
                                          YOKO_NAMESPACE);
    } catch (JAXBException e) {
        //ignore, just won't support the yoko extensors
    }

}
 
Example #17
Source File: XMLWSDLExtensionLoader.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static void registerExtensors(WSDLManager manager) {
    createExtensor(manager, javax.wsdl.BindingInput.class,
                   org.apache.cxf.bindings.xformat.XMLBindingMessageFormat.class);
    createExtensor(manager, javax.wsdl.BindingOutput.class,
                   org.apache.cxf.bindings.xformat.XMLBindingMessageFormat.class);
    createExtensor(manager, javax.wsdl.Binding.class,
                   org.apache.cxf.bindings.xformat.XMLFormatBinding.class);
}
 
Example #18
Source File: XMLWSDLExtensionLoader.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static void createExtensor(WSDLManager manager,
                            Class<?> parentType,
                            Class<?> elementType) {
    try {
        JAXBExtensionHelper.addExtensions(manager.getExtensionRegistry(),
                                          parentType,
                                          elementType,
                                          null,
                                          XMLWSDLExtensionLoader.class.getClassLoader());
    } catch (JAXBException e) {
        //ignore, won't support XML
    }
}
 
Example #19
Source File: WSDLManagerImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testLocalNamespacedWSDL() throws Exception {
    String wsdlUrl = getClass().getResource("hello_world_local_nsdecl.wsdl").toString();

    WSDLManager builder = new WSDLManagerImpl();
    Definition def = builder.getDefinition(wsdlUrl);
    java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
    builder.getWSDLFactory().newWSDLWriter().writeWSDL(def, bos);
}
 
Example #20
Source File: HTTPWSDLExtensionLoader.java    From cxf with Apache License 2.0 5 votes vote down vote up
public HTTPWSDLExtensionLoader(Bus b) {
    WSDLManager manager = b.getExtension(WSDLManager.class);

    createExtensor(manager, javax.wsdl.Port.class,
                   org.apache.cxf.transports.http.configuration.HTTPClientPolicy.class);
    createExtensor(manager, javax.wsdl.Port.class,
                   org.apache.cxf.transports.http.configuration.HTTPServerPolicy.class);
    createExtensor(manager, javax.wsdl.Port.class,
                   AddressType.class);
}
 
Example #21
Source File: HTTPWSDLExtensionLoader.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void createExtensor(WSDLManager manager,
                            Class<?> parentType,
                            Class<?> elementType) {
    try {
        JAXBExtensionHelper.addExtensions(manager.getExtensionRegistry(),
                                          parentType,
                                          elementType, null,
                                          this.getClass().getClassLoader());
    } catch (JAXBException e) {
        //ignore, won't support XML
    }
}
 
Example #22
Source File: JMSWSDLExtensionLoader.java    From cxf with Apache License 2.0 5 votes vote down vote up
public JMSWSDLExtensionLoader(Bus b) {
    WSDLManager manager = b.getExtension(WSDLManager.class);
    for (Class<?> extensor : EXTENSORS) {
        addExtensions(manager, javax.wsdl.Binding.class, extensor);
        addExtensions(manager, javax.wsdl.Port.class, extensor);
        addExtensions(manager, javax.wsdl.Service.class, extensor);
    }
}
 
Example #23
Source File: JMSWSDLExtensionLoader.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void addExtensions(WSDLManager manager, Class<?> parentType, Class<?> elementType) {
    try {
        JAXBExtensionHelper.addExtensions(manager.getExtensionRegistry(), parentType, elementType, null,
                                          this.getClass().getClassLoader());
    } catch (JAXBException e) {
        // ignore, won't support XML
    }
}
 
Example #24
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Definition newDefinition(final QName name, String targetNamespace) {
    Definition d = bus.getExtension(WSDLManager.class).getWSDLFactory().newDefinition();
    d.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
    d.setQName(name);
    d.setTargetNamespace(targetNamespace);
    addNamespace(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD, d);
    return d;
}
 
Example #25
Source File: WSDLServiceFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
public WSDLServiceFactory(Bus b, String url) {
    setBus(b);
    wsdlUrl = url;
    try {
        // use wsdl manager to parse wsdl or get cached definition
        definition = getBus().getExtension(WSDLManager.class).getDefinition(url);
    } catch (WSDLException ex) {
        throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
    }
}
 
Example #26
Source File: WSDLServiceFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
public WSDLServiceFactory(Bus b, String url, QName sn) {
    setBus(b);
    wsdlUrl = url;
    try {
        // use wsdl manager to parse wsdl or get cached definition
        definition = getBus().getExtension(WSDLManager.class).getDefinition(url);
    } catch (WSDLException ex) {
        throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
    }

    serviceName = sn;
}
 
Example #27
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setupWSDL(String wsdlPath, boolean doXsdImports) throws Exception {
    String wsdlUrl = getClass().getResource(wsdlPath).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);
    destinationFactory = control.createMock(DestinationFactory.class);
    wsdlServiceBuilder = new WSDLServiceBuilder(bus, false);

    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(new WSDLManagerImpl()).anyTimes();

    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
        .andReturn(destinationFactoryManager);

    EasyMock.expect(destinationFactoryManager
                    .getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/"))
        .andReturn(destinationFactory);

    control.replay();

    serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, serviceInfo);
    builder.setUseSchemaImports(doXsdImports);
    builder.setBaseFileName("HelloWorld");
    newDef = builder.build(new HashMap<String, SchemaInfo>());
}
 
Example #28
Source File: EmbeddedJMSBrokerLauncher.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static void updateWsdlExtensors(Bus bus,
                                       String wsdlLocation,
                                       String url,
                                       String encodedUrl) {
    try {
        if (encodedUrl == null) {
            encodedUrl = url;
        }
        if (bus == null) {
            bus = BusFactory.getThreadDefaultBus();
        }
        Definition def = bus.getExtension(WSDLManager.class)
            .getDefinition(wsdlLocation);
        Map<?, ?> map = def.getAllServices();
        for (Object o : map.values()) {
            Service service = (Service)o;
            Map<?, ?> ports = service.getPorts();
            adjustExtensibilityElements(service.getExtensibilityElements(), url, encodedUrl);

            for (Object p : ports.values()) {
                Port port = (Port)p;
                adjustExtensibilityElements(port.getExtensibilityElements(), url, encodedUrl);
                adjustExtensibilityElements(port.getBinding().getExtensibilityElements(), url, encodedUrl);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #29
Source File: SpringBusFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void checkOtherCoreExtensions(Bus bus) throws BusException {
    assertNotNull("No wsdl manager", bus.getExtension(WSDLManager.class));
    assertNotNull("No phase manager", bus.getExtension(PhaseManager.class));
    assertNotNull("No workqueue manager", bus.getExtension(WorkQueueManager.class));
    assertNotNull("No lifecycle manager", bus.getExtension(BusLifeCycleManager.class));
    assertNotNull("No service registry", bus.getExtension(ServerRegistry.class));

}
 
Example #30
Source File: IssueUnitTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@org.junit.Test
public void testRetrieveWSMEX() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = IssueUnitTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    // Get Metadata
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setBindingId(SoapBindingConstants.SOAP11_BINDING_ID);
    proxyFac.setAddress("https://localhost:" + STSPORT + "/SecurityTokenService/Transport/mex");
    MetadataExchange exc = proxyFac.create(MetadataExchange.class);
    Metadata metadata = exc.get2004();

    // Parse response (as per the STSClient)
    Definition definition = null;
    // Parse the MetadataSections into WSDL definition + associated schemas
    for (MetadataSection s : metadata.getMetadataSection()) {
        if ("http://schemas.xmlsoap.org/wsdl/".equals(s.getDialect())) {
            definition =
                bus.getExtension(WSDLManager.class).getDefinition((Element)s.getAny());
        }
    }
    assertNotNull(definition);
}