org.apache.cxf.interceptor.LoggingOutInterceptor Java Examples

The following examples show how to use org.apache.cxf.interceptor.LoggingOutInterceptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoapClient.java    From document-management-software with GNU Lesser General Public License v3.0 7 votes vote down vote up
/**
 * Standard service initialization. Concrete implementations can change the
 * client initialization logic
 */
@SuppressWarnings("unchecked")
protected void initClient(Class<T> serviceClass, int gzipThreshold, boolean log) {
	// Needed to get rig of CXF exception
	// "Cannot create a secure XMLInputFactory"
	System.setProperty("org.apache.cxf.stax.allowInsecureParser", "true");

	JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
	if (log) {
		factory.getInInterceptors().add(new LoggingInInterceptor());
		factory.getOutInterceptors().add(new LoggingOutInterceptor());
	}

	if (gzipThreshold >= 0) {
		factory.getInInterceptors().add(new GZIPInInterceptor());
		factory.getOutInterceptors().add(new GZIPOutInterceptor(gzipThreshold));
	}

	factory.setServiceClass(serviceClass);
	factory.setAddress(endpoint);
	client = (T) factory.create();
}
 
Example #2
Source File: WebServiceInjectionTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #3
Source File: WebServiceInjectionTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
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()));
}
 
Example #4
Source File: JaxRsClientStarter.java    From paymentgateway with GNU General Public License v3.0 6 votes vote down vote up
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;
	}
	
}
 
Example #5
Source File: LoggingFeature.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public void doInitializeProvider(InterceptorProvider provider, Bus bus) {
    if (limit == DEFAULT_LIMIT && inLocation == null
            && outLocation == null && !prettyLogging) {
        provider.getInInterceptors().add(IN);
        provider.getInFaultInterceptors().add(IN);
        provider.getOutInterceptors().add(OUT);
        provider.getOutFaultInterceptors().add(OUT);
    } else {
        LoggingInInterceptor in = new LoggingInInterceptor(limit);
        in.setOutputLocation(inLocation);
        in.setPrettyLogging(prettyLogging);
        in.setShowBinaryContent(showBinary);
        LoggingOutInterceptor out = new LoggingOutInterceptor(limit);
        out.setOutputLocation(outLocation);
        out.setPrettyLogging(prettyLogging);
        out.setShowBinaryContent(showBinary);

        provider.getInInterceptors().add(in);
        provider.getInFaultInterceptors().add(in);
        provider.getOutInterceptors().add(out);
        provider.getOutFaultInterceptors().add(out);
    }
}
 
Example #6
Source File: JaxRsClientStarter.java    From paymentgateway with GNU General Public License v3.0 6 votes vote down vote up
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;
	}
	
}
 
Example #7
Source File: JaxRsClientStarter.java    From paymentgateway with GNU General Public License v3.0 6 votes vote down vote up
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;
	}
	
}
 
Example #8
Source File: JaxRsClientStarter.java    From paymentgateway with GNU General Public License v3.0 6 votes vote down vote up
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;
	}
	
}
 
Example #9
Source File: JaxRsClientStarter.java    From paymentgateway with GNU General Public License v3.0 6 votes vote down vote up
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;
	}
	
}
 
Example #10
Source File: SOAPServiceTest.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
    * 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);
       }
}
 
Example #11
Source File: WssAuthTest.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #12
Source File: RestTest.java    From incubator-batchee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
@OverProtocol("Servlet 2.5") // to use a custom web.xml
public static Archive<?> war() {
    return ShrinkWrap.create(WebArchive.class, "batchee-gui.war")
        // GUI
        .addPackages(true, JBatchResourceImpl.class.getPackage())
        .addPackages(true, JBatchResource.class.getPackage())
        .addAsWebInfResource(new StringAsset(
            Descriptors.create(WebAppDescriptor.class)
                .metadataComplete(false)
                .createServlet()
                .servletName("CXF")
                .servletClass("org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet")
                .createInitParam()
                .paramName("jaxrs.serviceClasses")
                .paramValue(JBatchResourceImpl.class.getName())
                .up()
                .createInitParam()
                .paramName("jaxrs.providers")
                .paramValue(JohnzonBatcheeProvider.class.getName() + "," + JBatchExceptionMapper.class.getName())
                .up()
                .createInitParam()
                .paramName("jaxrs.outInterceptors")
                .paramValue(LoggingOutInterceptor.class.getName())
                .up()
                .up()
                .createServletMapping()
                .servletName("CXF")
                .urlPattern("/api/*")
                .up()
                .exportAsString()
        ), "web.xml")
        // test data to create some job things to do this test
        .addPackage(CreateSomeJobs.class.getPackage())
        .addAsWebInfResource("META-INF/batch-jobs/init.xml", "classes/META-INF/batch-jobs/init.xml");
}
 
Example #13
Source File: QueryInitServlet.java    From fosstrak-epcis with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.apache.cxf.transport.servlet.CXFNonSpringServlet#loadBus(javax.servlet.ServletConfig)
 */
public void loadBus(ServletConfig servletConfig) throws ServletException {
    super.loadBus(servletConfig);
    BusFactory.setDefaultBus(getBus());
    if (LOG.isDebugEnabled()) {
        getBus().getInInterceptors().add(new LoggingInInterceptor());
        getBus().getOutInterceptors().add(new LoggingOutInterceptor());
        getBus().getOutFaultInterceptors().add(new LoggingOutInterceptor());
        getBus().getInFaultInterceptors().add(new LoggingInInterceptor());
    }
    EPCISServicePortType service = setupQueryOperationsModule(servletConfig);

    LOG.debug("Publishing query operations module service at /query");
    Endpoint.publish("/query", service);
}
 
Example #14
Source File: LeaveWebServiceBusinessTest.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 不需要总经理审批
 * @throws ParseException
 */
@Test
public void testFalse() throws ParseException {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.setServiceClass(LeaveWebService.class);
    factory.setAddress(LeaveWebserviceUtil.WEBSERVICE_URL);
    LeaveWebService leaveWebService = (LeaveWebService) factory.create();
    boolean audit = leaveWebService.generalManagerAudit("2013-01-01 09:00", "2013-01-04 17:30");
    assertFalse(audit);
}
 
Example #15
Source File: InvokeCounter.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.setServiceClass(Counter.class);
    factory.setAddress("http://localhost:12345/counter");
    Counter counter = (Counter) factory.create();
    counter.inc();
    counter.inc();
    counter.inc();
    counter.inc();
    counter.inc();

    System.out.println(counter.getCount());
}
 
Example #16
Source File: WebServiceTaskTest.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
	super.initializeProcessEngine();

	counter = new CounterImpl();
	JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
	svrFactory.setServiceClass(Counter.class);
	svrFactory.setAddress("http://localhost:12345/counter");
	svrFactory.setServiceBean(counter);
	svrFactory.getInInterceptors().add(new LoggingInInterceptor());
	svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
	server = svrFactory.create();
	server.start();
}
 
Example #17
Source File: WebServiceTaskTest.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 独立启动WebService服务
 */
public static void main(String[] args) {
	Counter counter = new CounterImpl();
	JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
	svrFactory.setServiceClass(Counter.class);
	svrFactory.setAddress("http://localhost:12345/counter");
	svrFactory.setServiceBean(counter);
	svrFactory.getInInterceptors().add(new LoggingInInterceptor());
	svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
	Server server = svrFactory.create();
	server.start();
}
 
Example #18
Source File: TrustedIdpFacebookProtocolHandler.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private ClientAccessToken getAccessTokenUsingCode(String tokenEndpoint, String code, String clientId,
                                                  String clientSecret, String redirectURI) {
    // Here we need to get the AccessToken using the authorization code
    List<Object> providers = new ArrayList<>();
    providers.add(new OAuthJSONProvider());

    WebClient client =
        WebClient.create(tokenEndpoint, providers, "cxf-tls.xml");

    ClientConfiguration config = WebClient.getConfig(client);

    if (LOG.isDebugEnabled()) {
        config.getOutInterceptors().add(new LoggingOutInterceptor());
        config.getInInterceptors().add(new LoggingInInterceptor());
    }

    client.type("application/x-www-form-urlencoded");
    client.accept("application/json");

    Form form = new Form();
    form.param("grant_type", "authorization_code");
    form.param("code", code);
    form.param("client_id", clientId);
    form.param("redirect_uri", redirectURI);
    form.param("client_secret", clientSecret);
    Response response = client.post(form);

    return response.readEntity(ClientAccessToken.class);
}
 
Example #19
Source File: TrustedIdpFacebookProtocolHandler.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private String getSubjectName(String apiEndpoint, String accessToken, TrustedIdp trustedIdp) {
    WebClient client = WebClient.create(apiEndpoint,
                              Collections.singletonList(new JsonMapObjectProvider()),
                              "cxf-tls.xml");
    client.path("/me");
    ClientConfiguration config = WebClient.getConfig(client);

    if (LOG.isDebugEnabled()) {
        config.getOutInterceptors().add(new LoggingOutInterceptor());
        config.getInInterceptors().add(new LoggingInInterceptor());
    }

    client.accept("application/json");
    client.query("access_token", accessToken);

    String subjectName = getProperty(trustedIdp, SUBJECT_CLAIM);
    if (subjectName == null || subjectName.isEmpty()) {
        subjectName = "email";
    }
    client.query("fields", subjectName);
    JsonMapObject mapObject = client.get(JsonMapObject.class);

    String parsedSubjectName = (String)mapObject.getProperty(subjectName);
    if (subjectName.contains("email")) {
        parsedSubjectName = parsedSubjectName.replace("\\u0040", "@");
    }
    return parsedSubjectName;
}
 
Example #20
Source File: WebServiceInjectionTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void testPort(final Client client) {
    assertNotNull(client);
    assertEquals(2, client.getOutInterceptors().size());
    assertEquals(1, client.getInInterceptors().size());
    final Iterator<Interceptor<? extends Message>> iterator = client.getOutInterceptors().iterator();
    assertTrue(LoggingOutInterceptor.class.isInstance(iterator.next()));
    final Interceptor<? extends Message> wss4jout = iterator.next();
    assertTrue(WSS4JOutInterceptor.class.isInstance(wss4jout));
    assertEquals("d", WSS4JOutInterceptor.class.cast(wss4jout).getProperties().get("c"));
    final Interceptor<? extends Message> wss4jin = client.getInInterceptors().iterator().next();
    assertTrue(WSS4JInInterceptor.class.isInstance(wss4jin));
    assertEquals("b", WSS4JInInterceptor.class.cast(wss4jin).getProperties().get("a"));
}
 
Example #21
Source File: MockWebServiceExtension.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
private static MockWebServiceContext create() {
    WebServiceMock webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress(WEBSERVICE_MOCK_ADDRESS);
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    Server server = svrFactory.create();
    return new MockWebServiceContext(webServiceMock, server);
}
 
Example #22
Source File: WebServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
    super.initializeProcessEngine();

    webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress("http://localhost:63081/webservicemock");
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    server = svrFactory.create();
    server.start();
}
 
Example #23
Source File: AbstractWebServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
	super.initializeProcessEngine();

   webServiceMock = new WebServiceMockImpl();
	JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
	svrFactory.setServiceClass(WebServiceMock.class);
   svrFactory.setAddress("http://localhost:63081/webservicemock");
   svrFactory.setServiceBean(webServiceMock);
	svrFactory.getInInterceptors().add(new LoggingInInterceptor());
	svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
	server = svrFactory.create();
	server.start();
}
 
Example #24
Source File: AbstractWebServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
    super.initializeProcessEngine();

    webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress(WEBSERVICE_MOCK_ADDRESS);
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    server = svrFactory.create();
    server.start();
}
 
Example #25
Source File: AbstractWebServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
	super.initializeProcessEngine();

       webServiceMock = new WebServiceMockImpl();
	JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
	svrFactory.setServiceClass(WebServiceMock.class);
       svrFactory.setAddress("http://localhost:63081/webservicemock");
       svrFactory.setServiceBean(webServiceMock);
	svrFactory.getInInterceptors().add(new LoggingInInterceptor());
	svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
	server = svrFactory.create();
	server.start();
}
 
Example #26
Source File: HelloWorldImplTest.java    From cxf-jaxws with MIT License 5 votes vote down vote up
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();
}
 
Example #27
Source File: OnvifDevice.java    From onvif with Apache License 2.0 5 votes vote down vote up
public JaxWsProxyFactoryBean getServiceProxy(BindingProvider servicePort, String serviceAddr) {

    JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    proxyFactory.getHandlers();

    if (serviceAddr != null) proxyFactory.setAddress(serviceAddr);
    proxyFactory.setServiceClass(servicePort.getClass());

    SoapBindingConfiguration config = new SoapBindingConfiguration();

    config.setVersion(Soap12.getInstance());
    proxyFactory.setBindingConfig(config);
    Client deviceClient = ClientProxy.getClient(servicePort);

    if (verbose) {
      // these logging interceptors are depreciated, but should be fine for debugging/development
      // use.
      proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor());
      proxyFactory.getInInterceptors().add(new LoggingInInterceptor());
    }

    HTTPConduit http = (HTTPConduit) deviceClient.getConduit();
    if (securityHandler != null) proxyFactory.getHandlers().add(securityHandler);
    HTTPClientPolicy httpClientPolicy = http.getClient();
    httpClientPolicy.setConnectionTimeout(36000);
    httpClientPolicy.setReceiveTimeout(32000);
    httpClientPolicy.setAllowChunking(false);

    return proxyFactory;
  }
 
Example #28
Source File: AbstractWebServiceTaskTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
    super.initializeProcessEngine();

    webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress("http://localhost:63081/webservicemock");
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    server = svrFactory.create();
    server.start();
}
 
Example #29
Source File: AbstractWebServiceTaskTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
    super.initializeProcessEngine();

    webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress("http://localhost:63081/webservicemock");
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    server = svrFactory.create();
    server.start();
}
 
Example #30
Source File: Application.java    From spring-cxf with Apache License 2.0 5 votes vote down vote up
@Bean
// <jaxws:endpoint id="helloWorld" implementor="demo.spring.service.HelloWorldImpl" address="/HelloWorld"/>
public EndpointImpl helloService() {
    Bus bus = (Bus) applicationContext.getBean(Bus.DEFAULT_BUS_ID);
    Object implementor = new HelloWorldImpl();
    EndpointImpl endpoint = new EndpointImpl(bus, implementor);
    endpoint.publish("/hello");
    endpoint.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
    endpoint.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
    return endpoint;
}