本文整理汇总了Java中org.apache.cxf.interceptor.LoggingOutInterceptor类的典型用法代码示例。如果您正苦于以下问题:Java LoggingOutInterceptor类的具体用法?Java LoggingOutInterceptor怎么用?Java LoggingOutInterceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LoggingOutInterceptor类属于org.apache.cxf.interceptor包,在下文中一共展示了LoggingOutInterceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRoutes
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
@Test
public void testRoutes() throws Exception {
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));
Person client = ss.getSoap();
Client c = ClientProxy.getClient(client);
((BindingProvider)client).getRequestContext()
.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:" + port1 + "/" + getClass().getSimpleName() + "/PersonService");
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
Holder<String> personId = new Holder<String>();
personId.value = "hello";
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
client.getPerson(personId, ssn, name);
assertEquals("Bonjour", name.value);
}
示例2: getServiceProxy
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
public static JaxWsProxyFactoryBean getServiceProxy(BindingProvider servicePort, String serviceAddr) {
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
if(serviceAddr != null)
proxyFactory.setAddress(serviceAddr);
proxyFactory.setServiceClass(servicePort.getClass());
proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor());
SoapBindingConfiguration config = new SoapBindingConfiguration();
config.setVersion(Soap12.getInstance());
proxyFactory.setBindingConfig(config);
Client deviceClient = ClientProxy.getClient(servicePort);
HTTPConduit http = (HTTPConduit) deviceClient.getConduit();
// AuthorizationPolicy authPolicy = new AuthorizationPolicy();
// authPolicy.setUserName(username);
// authPolicy.setPassword(password);
// authPolicy.setAuthorizationType("Basic");
// http.setAuthorization(authPolicy);
HTTPClientPolicy httpClientPolicy = http.getClient();
httpClientPolicy.setConnectionTimeout(36000);
httpClientPolicy.setReceiveTimeout(32000);
httpClientPolicy.setAllowChunking(false);
return proxyFactory;
}
示例3: createCXFClient
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
protected static ReportIncidentEndpoint createCXFClient(String url) {
List<Interceptor<? extends Message>> outInterceptors = new ArrayList<Interceptor<? extends Message>>();
// Define WSS4j properties for flow outgoing
Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put("action", "UsernameToken Timestamp");
outProps.put("passwordType", "PasswordDigest");
outProps.put("user", "charles");
outProps.put("passwordCallbackClass", "org.apache.camel.example.reportincident.UTPasswordCallback");
WSS4JOutInterceptor wss4j = new WSS4JOutInterceptor(outProps);
// Add LoggingOutInterceptor
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
outInterceptors.add(wss4j);
outInterceptors.add(loggingOutInterceptor);
// we use CXF to create a client for us as its easier than JAXWS and works
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setOutInterceptors(outInterceptors);
factory.setServiceClass(ReportIncidentEndpoint.class);
factory.setAddress(url);
return (ReportIncidentEndpoint) factory.create();
}
示例4: testWsdlGeneration
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
/**
* Tests WSDL generation from a URL.
*
* This is similar to another KEW test but it is good to have it as part of the KSB tests. Note that the
* {@link Client} modifies the current thread's class loader.
*
* @throws Exception for any errors connecting to the client
*/
@Test
public void testWsdlGeneration() throws Exception {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(new URI(getWsdlUrl()).toString());
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
Object[] results = client.invoke("echo", "testing");
assertNotNull(results);
assertEquals(1, results.length);
assertEquals("testing", results[0]);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}
示例5: createCXFClient
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
protected static OrderEndpoint createCXFClient(String url, String user, String passwordCallbackClass) {
List<Interceptor<? extends Message>> outInterceptors = new ArrayList();
// Define WSS4j properties for flow outgoing
Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put("action", "UsernameToken Timestamp");
outProps.put("user", user);
outProps.put("passwordCallbackClass", passwordCallbackClass);
WSS4JOutInterceptor wss4j = new WSS4JOutInterceptor(outProps);
// Add LoggingOutInterceptor
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
outInterceptors.add(wss4j);
outInterceptors.add(loggingOutInterceptor);
// we use CXF to create a client for us as its easier than JAXWS and works
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setOutInterceptors(outInterceptors);
factory.setServiceClass(OrderEndpoint.class);
factory.setAddress(url);
return (OrderEndpoint) factory.create();
}
示例6: internalTestInfosetUsingFeatureProperties
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
private void internalTestInfosetUsingFeatureProperties(URL wsdlURL, QName serviceName, QName portQName) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream in = new ByteArrayOutputStream();
PrintWriter pwIn = new PrintWriter(in);
PrintWriter pwOut = new PrintWriter(out);
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
try {
bus.getInInterceptors().add(new LoggingInInterceptor(pwIn));
bus.getOutInterceptors().add(new LoggingOutInterceptor(pwOut));
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
HelloWorld port = (HelloWorld) service.getPort(portQName, HelloWorld.class);
ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
configurer.setConfigProperties(port, "META-INF/jaxws-client-config.xml", "Custom Client Config");
assertEquals("helloworld", port.echo("helloworld"));
assertTrue("request is expected fastinfoset", out.toString().indexOf("application/fastinfoset") > -1);
assertTrue("response is expected fastinfoset", in.toString().indexOf("application/fastinfoset") > -1);
} finally {
bus.shutdown(true);
pwOut.close();
pwIn.close();
}
}
示例7: createClientProxy
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
private static HelloWorldPortType createClientProxy() {
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
// create the loggingInInterceptor and loggingOutInterceptor
LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
loggingInInterceptor.setPrettyLogging(true);
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
loggingOutInterceptor.setPrettyLogging(true);
// add loggingInterceptor to print the received/sent messages
jaxWsProxyFactoryBean.getInInterceptors().add(loggingInInterceptor);
jaxWsProxyFactoryBean.getInFaultInterceptors()
.add(loggingInInterceptor);
jaxWsProxyFactoryBean.getOutInterceptors().add(loggingOutInterceptor);
jaxWsProxyFactoryBean.getOutFaultInterceptors()
.add(loggingOutInterceptor);
jaxWsProxyFactoryBean.setServiceClass(HelloWorldPortType.class);
jaxWsProxyFactoryBean.setAddress(ENDPOINT_ADDRESS);
return (HelloWorldPortType) jaxWsProxyFactoryBean.create();
}
示例8: userServiceEndpoint
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
@Bean(name = "helloEndpoint")
public CxfEndpoint userServiceEndpoint() {
CxfEndpoint cxfEndpoint = new CxfEndpoint();
cxfEndpoint.setAddress("http://localhost:8888/services/hello");
cxfEndpoint.setServiceClass(HelloWorld.class);
LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
loggingInInterceptor.setPrettyLogging(true);
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
loggingOutInterceptor.setPrettyLogging(true);
cxfEndpoint.getOutInterceptors().add(loggingOutInterceptor);
cxfEndpoint.getInInterceptors().add(loggingInInterceptor);
cxfEndpoint.setDataFormat(DataFormat.POJO);
final Map<String, Object> properties = new HashMap<>();
properties.put("schema-validation-enabled", "true");
properties.put("bus.jmx.enabled", "true");
//properties.setProperty("faultStackTraceEnabled", "true");
//properties.setProperty("exceptionMessageCauseEnabled", "true");
//properties.setProperty("schema-validation-enabled", "false");
//properties.put("allowStreaming", true);
cxfEndpoint.configureProperties(properties);
return cxfEndpoint;
}
示例9: start
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
public T start(Class<T> cls, String url, boolean trustAllCerts, String trustStore, String trustStorePassword,
List<?> providers, int connectTimeout, int receiveTimeout) {
try {
T resource = JAXRSClientFactory.create(url, cls, providers);
HTTPConduit conduit = WebClient.getConfig(resource).getHttpConduit();
WebClient.getConfig(resource).getInInterceptors().add(new LoggingInInterceptor());
WebClient.getConfig(resource).getOutInterceptors().add(new LoggingOutInterceptor());
configureHTTPS(resource, conduit, trustAllCerts, trustStore, trustStorePassword);
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(connectTimeout);
httpClientPolicy.setReceiveTimeout(receiveTimeout);
conduit.setClient(httpClientPolicy);
return resource;
} catch (Exception e) {
LOG.error(" rest client '{}': NOT STARTED", url);
return null;
}
}
示例10: createLocalJaxWsService
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
/**
* 构造服务,注意要自己释放
* @param intf
* @param bean
* @return
*/
private Server createLocalJaxWsService(Class<?> intf, Object bean) {
String url = "local://" + intf.getName();
ServiceDefinition ws = getFactory().processServiceDef(new ServiceDefinition(intf.getSimpleName(),intf,bean));
if (ws == null)
return null;
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(new CXFPlusServiceFactoryBean());
sf.setAddress(url);
sf.setServiceBean(ws.getServiceBean());
sf.setServiceClass(ws.getServiceClass());
if (printTrace()){
sf.getInInterceptors().add(new LoggingInInterceptor());
sf.getOutInterceptors().add(new LoggingOutInterceptor());
// sf.getHandlers().add(TraceHandler.getSingleton());
}
Server server = sf.create();
return server;
}
示例11: createLocalService
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
/**
* 构造服务,注意要自己释放
* @param intf
* @param bean
* @return
*/
private Server createLocalService(Class<?> intf, Object bean) {
String url = "local://" + intf.getName();
ServiceDefinition ws = getFactory().processServiceDef(new ServiceDefinition(intf.getSimpleName(), intf, bean));
if (ws == null)
return null;
ServerFactoryBean sf = new ServerFactoryBean(new CXFPlusServiceBean());
sf.setAddress(url);
sf.setServiceBean(ws.getServiceBean());
sf.setServiceClass(ws.getServiceClass());
if (printTrace()){
sf.getInInterceptors().add(new LoggingInInterceptor());
sf.getOutInterceptors().add(new LoggingOutInterceptor());
}
Server server = sf.create();
return server;
}
示例12: rawTest
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的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);
}
示例13: testCallAxis2
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
@Test
@Ignore
public void testCallAxis2(){
//服务位于: http://localhost/axis2-web/services/myService?wsdl
// JaxWsClientFactoryBean clientBean=new JaxWsClientFactoryBean();
// JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
ClientProxyFactoryBean factoryBean=new ClientProxyFactoryBean();
factoryBean.setAddress("http://localhost/axis2-web/services/myService?wsdl");
factoryBean.setServiceClass(MyService.class); //有接口调用
//修复兼容性:
//发现居然提示命名空间不对,原来是CXF认为命名空间用/结尾,多一个斜杠引起问题
factoryBean.setServiceName(new QName("http://sevice.test.axis2","MyService"));
factoryBean.getInInterceptors().add(new LoggingInInterceptor());
factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
MyService service=(MyService)factoryBean.create();
System.out.println(service.getHello("将"));//当前类
String result=service.toBaseString("Hello, jiyi", 100);//父类方法
System.out.println(result);
}
示例14: testPortWithFeature
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
private void testPortWithFeature(final Client client) {
assertNotNull(client);
assertEquals(4, client.getOutInterceptors().size());
assertEquals(3, client.getInInterceptors().size());
final Iterator<Interceptor<? extends Message>> Out = client.getOutInterceptors().iterator();
assertTrue(MAPAggregatorImpl.class.isInstance(Out.next()));
assertTrue(MAPCodec.class.isInstance(Out.next()));
assertTrue(LoggingOutInterceptor.class.isInstance(Out.next()));
final Interceptor<? extends Message> wss4jout = Out.next();
assertTrue(WSS4JOutInterceptor.class.isInstance(wss4jout));
final Iterator<Interceptor<? extends Message>> iteratorIn = client.getInInterceptors().iterator();
assertTrue(MAPAggregatorImpl.class.isInstance(iteratorIn.next()));
assertTrue(MAPCodec.class.isInstance(iteratorIn.next()));
assertTrue(WSS4JInInterceptor.class.isInstance(iteratorIn.next()));
}
示例15: props
import org.apache.cxf.interceptor.LoggingOutInterceptor; //导入依赖的package包/类
@ApplicationConfiguration
public Properties props() {
// return new PropertiesBuilder().p("cxf.jaxws.client.out-interceptors", LoggingOutInterceptor.class.getName()).build();
// return new PropertiesBuilder().p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}MyWebservicePort.out-interceptors", LoggingOutInterceptor.class.getName()).build();
return new PropertiesBuilder()
.p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}MyWebservicePort.in-interceptors", "wss4jin")
.p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}MyWebservicePort.out-interceptors", "loo,wss4jout")
.p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}myWebservice.in-interceptors", "wss4jin")
.p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}myWebservice.out-interceptors", "loo,wss4jout")
.p("loo", "new://Service?class-name=" + LoggingOutInterceptor.class.getName())
.p("wss4jin", "new://Service?class-name=" + WSS4JInInterceptorFactory.class.getName() + "&factory-name=create")
.p("wss4jin.a", "b")
.p("wss4jout", "new://Service?class-name=" + WSS4JOutInterceptor.class.getName() + "&constructor=properties")
.p("wss4jout.properties", "$properties")
.p("properties", "new://Service?class-name=" + MapFactory.class.getName())
.p("properties.c", "d")
.build();
}