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


Java JAXRSClientFactoryBean.setServiceClass方法代码示例

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


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

示例1: rawTest

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
@Test
	@Ignore
	public void rawTest(){
		JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean();
		bean.setAddress("http://localhost:8080/cxf-plus/ws/rest/");
		                 
		bean.setServiceClass(PeopleServiceXml.class);
//		bean.setProvider(new FastJSONProvider(true, false));
		
		bean.getInInterceptors().add(new LoggingInInterceptor());
		bean.getOutInterceptors().add(new LoggingOutInterceptor());
		
		PeopleServiceXml s=(PeopleServiceXml)bean.create();
		List<People> r=s.getAll();
		
		System.out.println("-------------------");
		System.out.println("得到用户"+r.size());
//		int id=s.create(new People("[email protected]","jiyi","lu"));
//		System.out.println(id);
	}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:21,代码来源:ClientTest.java

示例2: build

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
/**
 * This method returns an instance of an implementation the specified {@code clazz} (which should be a REST service
 * interface, e.g. TablemanagementRestService.class). <br/>
 * The caller must take care that no parameter value is equal to {@code NULL}. <br/>
 * The caller will be authenticated using basic authentication with the provided credentials. The method
 * {@code setLocalServerPort} MUST be called in advance.
 *
 * @param <T> The return type.
 * @param clazz This must be an interface type.
 * @param userName The userName for basic authentication.
 * @param tmpPassword The password for basic authentication.
 * @param tmpUrl The URL through which the server is reached.
 * @return A REST proxy of type {@code T}
 */
public <T extends RestService> T build(Class<T> clazz, String userName, String tmpPassword, String tmpUrl) {

  JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean();
  factoryBean.setAddress(tmpUrl);
  factoryBean.setHeaders(new HashMap<String, String>());
  // example for basic auth
  String payload = userName + ":" + tmpPassword;
  String authorizationHeader = "Basic " + Base64Utility.encode(payload.getBytes());
  factoryBean.getHeaders().put("Authorization", Arrays.asList(authorizationHeader));
  factoryBean.setProviders(Arrays.asList(this.jacksonJsonProvider));

  factoryBean.setServiceClass(clazz);
  return factoryBean.create(clazz);
}
 
开发者ID:oasp,项目名称:oasp-tutorial-sources,代码行数:29,代码来源:RestTestClientBuilder.java

示例3: createProxy

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T createProxy(String url, Class<T> clz) {
	JAXRSClientFactoryBean proxyFactoryBean = new JAXRSClientFactoryBean();
	proxyFactoryBean.setAddress(url);
	proxyFactoryBean.setServiceClass(clz);
	proxyFactoryBean.setProvider(new FastJSONProvider(true, false));
	proxyFactoryBean.getInInterceptors().add(new LoggingInInterceptor());
	proxyFactoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
	T client = (T) proxyFactoryBean.create();
	return client;
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:12,代码来源:RsClientFactoryImpl.java

示例4: getBean

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
private static JAXRSClientFactoryBean getBean(String baseAddress, Class<?> cls, String configLocation, Map<String, String> headers) {
    JAXRSClientFactoryBean bean = getBean(baseAddress, configLocation, headers);
    bean.setServiceClass(cls);
    return bean;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:6,代码来源:IdentityManagementEndpointUtil.java


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