本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}