BIBusHeaderHelper.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2009, 2010
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. import javax.xml.namespace.QName;
  9. import org.apache.axis.message.SOAPHeaderElement;
  10. import com.cognos.developer.schemas.bibus._3.BiBusHeader;
  11. import com.cognos.developer.schemas.bibus._3.RoutingInfo;
  12. public class BIBusHeaderHelper {
  13. private static final String BIBUS_NS = "http://developer.cognos.com/schemas/bibus/3/";
  14. private static final String BIBUS_HDR = "biBusHeader";
  15. private static final QName BUS_QNAME = new QName(BIBUS_NS, BIBUS_HDR);
  16. // sn_dg_sdk_mng_svc_hdrs_start_2
  17. //Use this method when copying headers, such as for requests to services
  18. public static BiBusHeader getHeaderObject(SOAPHeaderElement SourceHeader, boolean isNewConversation, String RSGroup)
  19. {
  20. if (SourceHeader == null)
  21. return null;
  22. BiBusHeader bibus = null;
  23. try {
  24. bibus = (BiBusHeader)SourceHeader.getValueAsType(BUS_QNAME);
  25. // Note BUS_QNAME expands to:
  26. // new QName("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader")
  27. //If the header will be used for a new conversation, clear
  28. //tracking information, and set routing if supplied (clear if not)
  29. if (isNewConversation){
  30. bibus.setTracking(null);
  31. //If a Routing Server Group is specified, direct requests to it
  32. if (RSGroup.length()>0) {
  33. RoutingInfo routing = new RoutingInfo(RSGroup);
  34. bibus.setRouting(routing);
  35. }
  36. else {
  37. bibus.setRouting(null);
  38. }
  39. }
  40. } catch (Exception e) {
  41. e.printStackTrace();
  42. }
  43. return bibus;
  44. }
  45. // sn_dg_sdk_mng_svc_hdrs_end_2
  46. // use this method when retrieving information from header, but header is not being copied
  47. // for use in service requests
  48. public static BiBusHeader getHeaderObject(SOAPHeaderElement SourceHeader)
  49. {
  50. if (SourceHeader == null)
  51. return null;
  52. BiBusHeader bibus = null;
  53. try {
  54. bibus = (BiBusHeader)SourceHeader.getValueAsType(BUS_QNAME);
  55. } catch (Exception e) {
  56. e.printStackTrace();
  57. }
  58. return bibus;
  59. }
  60. }