当前位置: 首页>>代码示例>>Java>>正文


Java WebClient.create方法代码示例

本文整理汇总了Java中org.apache.cxf.jaxrs.client.WebClient.create方法的典型用法代码示例。如果您正苦于以下问题:Java WebClient.create方法的具体用法?Java WebClient.create怎么用?Java WebClient.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cxf.jaxrs.client.WebClient的用法示例。


在下文中一共展示了WebClient.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAccessToken

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
private ClientAccessToken getAccessToken() {
    JwsHeaders headers = new JwsHeaders(JoseType.JWT, SignatureAlgorithm.RS256);
    JwtClaims claims = new JwtClaims();
    claims.setIssuer(config.getServiceAccountClientId());
    claims.setAudience("https://accounts.google.com/o/oauth2/token");
    claims.setSubject(config.getServiceAccountSubject());

    long issuedAt = OAuthUtils.getIssuedAt();
    long tokenTimeout = config.getServiceAccountTokenLifetime();
    claims.setIssuedAt(issuedAt);
    claims.setExpiryTime(issuedAt + tokenTimeout);
    claims.setProperty("scope", "https://www.googleapis.com/auth/admin.directory.group.readonly https://www.googleapis.com/auth/admin.directory.user");

    JwtToken token = new JwtToken(headers, claims);
    JwsJwtCompactProducer p = new JwsJwtCompactProducer(token);
    String base64UrlAssertion = p.signWith(privateKey);

    JwtBearerGrant grant = new JwtBearerGrant(base64UrlAssertion);

    WebClient accessTokenService = WebClient.create("https://accounts.google.com/o/oauth2/token",
            Arrays.asList(new OAuthJSONProvider(), new AccessTokenGrantWriter()));

    accessTokenService.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_JSON);

    return accessTokenService.post(grant, ClientAccessToken.class);
}
 
开发者ID:hlavki,项目名称:g-suite-identity-sync,代码行数:27,代码来源:GSuiteDirectoryServiceImpl.java

示例2: getScribeCommandObjectByIndustry

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public final ScribeCommandObject getScribeCommandObjectByIndustry(final String industry) throws Exception {

    /* Create a web client */
    final WebClient client = WebClient.create(cadURL);

    /* Create account object */
    ScribeCommandObject accounts = null;
    try {
      /* Call Scribe */
      accounts = client.path(objectUrl).query("Industry", industry).get(ScribeCommandObject.class);
    } catch (final Exception e) {
      if (e instanceof WebApplicationException) {
        final WebApplicationException webApplicationException = (WebApplicationException) e;
        if (webApplicationException.getResponse().getStatus() != Status.OK.getStatusCode()) {
          return null;
        }
      }
    }
    return accounts;
  }
 
开发者ID:inbravo,项目名称:scribe,代码行数:21,代码来源:ScribeClientMgmt.java

示例3: waitForWADL

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
private static boolean waitForWADL() {
    WebClient client = WebClient.create(WADL_ADDRESS);
    // wait for 20 secs or so
    for (int i = 0; i < 20; i++) {
        try {
            Thread.currentThread().sleep(100);
            Response response = client.get();
            if (response.getStatus() == 200) {
                return true;
            }
        } catch (Exception e) {
            return false;
        }
    }
    // no WADL is available yet - throw an exception or give tests a chance to run anyway
    log.error("Service offline");

    return false;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:TestService.java

示例4: testHomeJSON

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void testHomeJSON() {
    if (!waitForWADL()) {
        return;
    }

    WebClient client = WebClient.create(ENDPOINT_ADDRESS);

    client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
    client.type("application/json");
    client.accept("application/json");

    client.path("home");

    String response = readReource("json/response-home.json");

    String webRespose = client.get(String.class);
    assertEquals(response, webRespose);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:TestService.java

示例5: testPdpJSON

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void testPdpJSON() {
    if (!waitForWADL()) {
        return;
    }

    WebClient client = WebClient.create(ENDPOINT_ADDRESS);

    client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
    client.type("application/json");
    client.accept("application/json");

    client.path("pdp");

    String request = readReource("json/request-pdp-1.json");
    String response = readReource("json/response-pdp-1.json");

    String webRespose = client.post(request, String.class);
    assertEquals(response, webRespose);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:TestService.java

示例6: testGetDecisionByAttributesJSON

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
public void testGetDecisionByAttributesJSON() {
    if (!waitForWADL()) {
        return;
    }

    WebClient client = WebClient.create(ENDPOINT_ADDRESS);

    client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
    client.type("application/json");
    client.accept("application/xml");

    client.path("by-attrib");

    String request = readReource("json/request-by-attrib-1.json");
    String response = readReource("json/response-by-attrib-1.xml");

    String webRespose = client.post(request, String.class);

    assertEquals(response, webRespose);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:TestService.java

示例7: getScribeCommandObjectForTenant

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public final ScribeCommandObject getScribeCommandObjectForTenant(final String tenant) throws Exception {

    /* Create a web client */
    final WebClient client = WebClient.create(cadURL);

    /* Create account object */
    ScribeCommandObject accounts = null;
    try {
      /* Call Scribe */
      accounts = client.path(objectUrl).query("tenant", tenant).get(ScribeCommandObject.class);
    } catch (final Exception e) {
      if (e instanceof WebApplicationException) {
        final WebApplicationException webApplicationException = (WebApplicationException) e;
        if (webApplicationException.getResponse().getStatus() != Status.OK.getStatusCode()) {
          return null;
        }
      }
    }
    return accounts;
  }
 
开发者ID:inbravo,项目名称:scribe,代码行数:21,代码来源:ScribeClientMgmt.java

示例8: createTrustedWebClient

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public static WebClient createTrustedWebClient( String url, Object provider )
{
    WebClient client = WebClient.create( url, Arrays.asList( provider ) );

    HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit();

    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout( defaultConnectionTimeout );
    httpClientPolicy.setReceiveTimeout( defaultReceiveTimeout );
    httpClientPolicy.setMaxRetransmits( defaultMaxRetransmits );


    httpConduit.setClient( httpClientPolicy );

    SSLManager sslManager = new SSLManager( null, null, null, null );

    TLSClientParameters tlsClientParameters = new TLSClientParameters();
    tlsClientParameters.setDisableCNCheck( true );
    tlsClientParameters.setTrustManagers( sslManager.getClientFullTrustManagers() );
    httpConduit.setTlsClientParameters( tlsClientParameters );

    return client;
}
 
开发者ID:subutai-io,项目名称:base,代码行数:24,代码来源:RestUtil.java

示例9: getEndpoints

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Test
@RunAsClient
public void getEndpoints() throws Exception {

    final WebClient webClient = WebClient.create(this.url.toURI());
    webClient.accept(MediaType.APPLICATION_JSON);

    final String reset = webClient.path("/service/endpoints/").get(String.class);
    Assert.assertNotNull("Failed to reset", reset);

    final Endpoints eps = webClient.path("conference")
            .get(Endpoints.class);

    Assert.assertNotNull("Failed to get Endpoints", eps);
    Assert.assertFalse("Endpoints is empty", eps.getEndpoints().isEmpty());
}
 
开发者ID:eclipse,项目名称:microprofile-conference,代码行数:17,代码来源:EndpointServiceTest.java

示例10: getScribeCommandObjectByCRMObjectField

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public final ScribeCommandObject getScribeCommandObjectByCRMObjectField(final String fieldName, final String fieldValue) throws Exception {

    /* Create a web client */
    final WebClient client = WebClient.create(cadURL);

    /* Create account object */
    ScribeCommandObject accounts = null;
    try {
      /* Call Scribe */
      accounts = client.path(objectUrl).query(fieldName, fieldValue).get(ScribeCommandObject.class);
    } catch (final Exception e) {
      if (e instanceof WebApplicationException) {
        final WebApplicationException webApplicationException = (WebApplicationException) e;
        System.err.println(webApplicationException.getResponse().getStatus());
        if (webApplicationException.getResponse().getStatus() != Status.OK.getStatusCode()) {
          return null;
        }
      }
    }
    return accounts;
  }
 
开发者ID:inbravo,项目名称:scribe,代码行数:22,代码来源:ScribeClientMgmt.java

示例11: MatterMostBotClient

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public MatterMostBotClient(final String host, final String personalToken, final Optional<WsSocketListener> listener)
{
	final WebClient client = WebClient.create("http://" + host + apiV4);
	final String bearer = "Bearer " + personalToken;
	client.header("Authorization", bearer);
	_client = client;
	_asyncClient = new WebSocketClient("ws://" + host + apiV4 + "/websocket", bearer, listener);
}
 
开发者ID:Cloud-Temple,项目名称:Mattermost-client,代码行数:9,代码来源:MatterMostBotClient.java

示例12: AuthenticationClient

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public AuthenticationClient (String apiUrl, String username, String password) {
    this.apiUrl = apiUrl;
    this.username = username;        
    this.password = password;
    
    webClient = WebClient.create(apiUrl, Collections.singletonList(new JacksonJaxbJsonProvider ()));
    webClient.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON);
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:9,代码来源:AuthenticationClient.java

示例13: ApiClient

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public ApiClient (AuthenticationClient authClient) {
	this.authClient = authClient;
	
       webClient = WebClient.create(authClient.getApiUrl(), Collections.singletonList(new JacksonJaxbJsonProvider ()));
       webClient.header("Authorization", "Bearer " + authClient.getAuthenticationContext().getAuthToken());
       webClient.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON);
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:8,代码来源:ApiClient.java

示例14: createWebClient

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
/**
 * Creates a JAXRS web client for the given JAXRS client
 */
protected <T> T createWebClient(Class<T> clientType) {
    List<Object> providers = WebClients.createProviders();
    String queryString = "?secret=" + secret + "&secretNamespace=" + secretNamespace + "&kubeUserName=" + kubeUserName;
    String commandsAddress = URLUtils.pathJoin(this.address, "/api/forge" + queryString);
    WebClient webClient = WebClient.create(commandsAddress, providers);
    disableSslChecks(webClient);
    HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout(connectionTimeoutMillis);
    httpClientPolicy.setReceiveTimeout(connectionTimeoutMillis);
    conduit.setClient(httpClientPolicy);

    return JAXRSClientFactory.fromClient(webClient, clientType);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:18,代码来源:ForgeClient.java

示例15: setUp

import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Before
	public void setUp() throws Exception {

		MockitoAnnotations.initMocks( this );
		/*
		userService = Mockito.mock( UserService.class );
		userRestRS = Mockito.spy( new UserRestImpl() );
		ReflectionTestUtils.setField( userRestRS, "userService", userService );
		*/

		final List<Object> providers = new ArrayList<Object>();
		JacksonJaxbJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider();
		providers.add( jacksonJsonProvider );

		// custom deserializers for our abstract types ( User and Collection )
		this.objectMapper = jacksonJsonProvider.locateMapper(null, MediaType.APPLICATION_JSON_TYPE);
//		SimpleModule module = new SimpleModule(
//				"Kur8orApiDeserializer",
//				new Version(1, 0, 0, null, "", "")
//		);
//		module.addDeserializer( com.projectx.sdk.user.User.class, userAbstractDeserializer );
//		module.addDeserializer( Collection.class, collectionAbstractDeserializer );
//
//		objectMapper.registerModule( module );

		webClient = WebClient.create( "http://localhost:8080/api", providers );
		WebClient.getConfig( webClient ).getRequestContext().put( LocalConduit.DIRECT_DISPATCH, Boolean.TRUE );
		webClient.accept( "application/json" );

	}
 
开发者ID:amoldavsky,项目名称:restful-api-cxf-spring-java,代码行数:31,代码来源:UserRestTest.java


注:本文中的org.apache.cxf.jaxrs.client.WebClient.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。