示例#1
0
  @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());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.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);
  }
示例#2
0
  @Test
  public void testGet() {
    // Create the client
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setBus(getStaticBus());
    proxyFac.setAddress("http://localhost:" + PORT + "/jaxws/addmex");
    proxyFac.getFeatures().add(new LoggingFeature());
    MetadataExchange exc = proxyFac.create(MetadataExchange.class);
    Metadata metadata = exc.get2004();
    assertNotNull(metadata);
    assertEquals(2, metadata.getMetadataSection().size());

    assertEquals(
        "http://schemas.xmlsoap.org/wsdl/", metadata.getMetadataSection().get(0).getDialect());
    assertEquals(
        "http://apache.org/cxf/systest/ws/addr_feature/",
        metadata.getMetadataSection().get(0).getIdentifier());
    assertEquals(
        "http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(1).getDialect());

    GetMetadata body = new GetMetadata();
    body.setDialect("http://www.w3.org/2001/XMLSchema");
    metadata = exc.getMetadata(body);
    assertEquals(1, metadata.getMetadataSection().size());
    assertEquals(
        "http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(0).getDialect());
  }