private static <T> T createClient(
      String port, Class<T> serviceClass, SchemaValidationType type, Feature... features) {
    JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
    clientFactory.setServiceClass(serviceClass);

    clientFactory.setAddress(getAddress(port, serviceClass));

    if (features != null) {
      clientFactory.getFeatures().addAll(Arrays.asList(features));
    }

    @SuppressWarnings("unchecked")
    T newClient = (T) clientFactory.create();

    Client proxy = ClientProxy.getClient(newClient);

    if (type != null) {
      proxy.getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, type);
    }

    HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
    // give me longer debug times
    HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
    clientPolicy.setConnectionTimeout(1000000);
    clientPolicy.setReceiveTimeout(1000000);
    conduit.setClient(clientPolicy);

    return newClient;
  }
示例#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());
  }