SHARE
TWEET

Untitled

a guest Jul 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.bala.custom.wih;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import javax.xml.bind.JAXBException;
  7. import javax.xml.namespace.QName;
  8.  
  9. import org.apache.cxf.endpoint.Client;
  10. import org.apache.cxf.headers.Header;
  11. import org.apache.cxf.jaxb.JAXBDataBinding;
  12. import org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler;
  13. import org.kie.api.runtime.KieSession;
  14. import org.kie.api.runtime.process.WorkItem;
  15.  
  16. /**
  17.  *
  18.  * @author bbalasub
  19.  *
  20.  *
  21.  *         Custom Work Item Handler to set the custom SOAP headers to the
  22.  *         request context
  23.  */
  24. public class CustomWSWIH extends WebServiceWorkItemHandler {
  25.  
  26.     public CustomWSWIH(KieSession ksession, ClassLoader classloader) {
  27.         super(ksession, classloader);
  28.         System.out.println("Invoked the constructor in custome ws wih....");
  29.     }
  30.  
  31.     @Override
  32.     protected Client getWSClient(WorkItem workItem, String interfaceRef) {
  33.         Client client = super.getWSClient(workItem, interfaceRef);
  34.  
  35.         Object headerToken = workItem.getParameter("Header");
  36.         System.out.println("The value passed in for header is " + headerToken);
  37.        
  38.         List<Header> headers = new ArrayList<Header>();
  39.         Header dummyHeader = null;
  40.         try {
  41.             dummyHeader = new Header(new QName("uri:org.apache.cxf", "dummy"), headerToken,
  42.                     new JAXBDataBinding(String.class));
  43.         } catch (JAXBException e) {
  44.             e.printStackTrace();
  45.         }
  46.         headers.add(dummyHeader);
  47.  
  48.         client.getRequestContext().put(Header.HEADER_LIST, headers);
  49.        
  50.         return client;
  51.     }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top