soaplogic.xslt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  5. (C) Copyright IBM Corp. 2005, 2019
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <!-- $Header: //cpscrn/main/templates/cps4/common/logicsheets/soaplogic.xslt#1 $ -->
  13. <!-- $DateTime: 2008/10/22 11:12:04 $ -->
  14. <!-- $Change: 25109 $ -->
  15. <!--
  16. CPS Portal Services
  17. SOAP Logicsheet
  18. -->
  19. <xsl:stylesheet version="1.0"
  20. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  21. xmlns:out="dummy-uri"
  22. xmlns:soap="http://developer.cognos.com/schemas/cps/logic/soap"
  23. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  24. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  25. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  26. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  27. xmlns:cpx="http://developer.cognos.com/schemas/cps/header/service/1/"
  28. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  29. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
  30. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  31. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  32. <!--
  33. soap:request
  34. built-in requests:
  35. @provider = 'cm' | 'cm2' | 'warp' | 'xts' | 'dispatcher' | 'jsm' | 'jobservice' | 'system'
  36. otherwise treated as a SOAP request and you must supply any of:
  37. @target
  38. @soapAction
  39. @outputHeader
  40. @protocolHeader
  41. @option
  42. @mimeType
  43. @faultBlock
  44. @directedRequest
  45. @afinity
  46. note: always returns response envelope
  47. -->
  48. <xsl:template match="soap:request">
  49. <xsl:choose>
  50. <xsl:when test="@provider = 'massembler'">
  51. <xts:transform processor="XSLT" src="/cps4/asm/transforms/asm-rewrite.xslt">
  52. <root>
  53. <xsl:for-each select="xts:param">
  54. <param name="{ @name }">
  55. <xsl:copy-of select="node()"/>
  56. </param>
  57. </xsl:for-each>
  58. <envelope>
  59. <xsl:call-template name="request-content">
  60. <xsl:with-param name="content" select="*[not(self::xts:param)]"/>
  61. </xsl:call-template>
  62. </envelope>
  63. <markup>
  64. <xts:request protocol="SOAP" responseEnvelope="true" target="interface://cps/assembler">
  65. <xsl:copy-of select="@soapAction | @outputHeader"/>
  66. <xsl:call-template name="request-content">
  67. <xsl:with-param name="content" select="*[not(self::xts:param)]"/>
  68. </xsl:call-template>
  69. </xts:request>
  70. </markup>
  71. </root>
  72. </xts:transform>
  73. </xsl:when>
  74. <xsl:otherwise>
  75. <xts:request>
  76. <xsl:choose>
  77. <xsl:when test="@responseEnvelope='false'">
  78. <xsl:attribute name="responseEnvelope">false</xsl:attribute>
  79. </xsl:when>
  80. <xsl:otherwise>
  81. <xsl:attribute name="responseEnvelope">true</xsl:attribute>
  82. </xsl:otherwise>
  83. </xsl:choose>
  84. <!-- select attributes for request -->
  85. <xsl:choose>
  86. <xsl:when test="@provider='cm'">
  87. <xsl:attribute name="protocol">BUS</xsl:attribute>
  88. <xsl:attribute name="href">bus://cm</xsl:attribute>
  89. <xsl:attribute name="soapAction">http://www.ibm.com/xmlns/prod/cognos/contentManagerService/201904/</xsl:attribute>
  90. <xsl:attribute name="outputHeader">true</xsl:attribute>
  91. </xsl:when>
  92. <xsl:when test="@provider='cm2'">
  93. <xsl:attribute name="protocol">CM</xsl:attribute>
  94. <xsl:attribute name="href">cm://cm</xsl:attribute>
  95. <xsl:attribute name="soapAction">http://www.ibm.com/xmlns/prod/cognos/contentManagerService/201904/</xsl:attribute>
  96. <xsl:attribute name="outputHeader">true</xsl:attribute>
  97. </xsl:when>
  98. <xsl:when test="@provider='warp'">
  99. <xsl:attribute name="protocol">BUS</xsl:attribute>
  100. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  101. <xsl:attribute name="soapAction">http://developer.cognos.com/schemas/bibus/2#reportService<xsl:value-of select="@affinity"/></xsl:attribute>
  102. <xsl:attribute name="outputHeader">true</xsl:attribute>
  103. </xsl:when>
  104. <xsl:when test="@provider='xts'">
  105. <xsl:attribute name="protocol">BUS</xsl:attribute>
  106. <xsl:attribute name="href">bus://xts</xsl:attribute>
  107. <xsl:attribute name="soapAction">xts.run</xsl:attribute>
  108. <xsl:attribute name="outputHeader">true</xsl:attribute>
  109. </xsl:when>
  110. <xsl:when test="@provider='dispatcher'">
  111. <xsl:attribute name="protocol">BUS</xsl:attribute>
  112. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  113. <xsl:attribute name="soapAction">http://developer.cognos.com/schemas/bibus/2#dispatcher</xsl:attribute>
  114. <xsl:attribute name="outputHeader">true</xsl:attribute>
  115. </xsl:when>
  116. <xsl:when test="@provider='jsm'">
  117. <xsl:attribute name="protocol">BUS</xsl:attribute>
  118. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  119. <xsl:attribute name="soapAction">http://developer.cognos.com/schemas/bibus/2#scheduler</xsl:attribute>
  120. <xsl:attribute name="outputHeader">true</xsl:attribute>
  121. </xsl:when>
  122. <xsl:when test="@provider='jobService'">
  123. <xsl:attribute name="protocol">BUS</xsl:attribute>
  124. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  125. <xsl:attribute name="soapAction">jobService</xsl:attribute>
  126. <xsl:attribute name="outputHeader">true</xsl:attribute>
  127. </xsl:when>
  128. <xsl:when test="@provider='system'">
  129. <xsl:attribute name="protocol">BUS</xsl:attribute>
  130. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  131. <xsl:attribute name="soapAction">http://developer.cognos.com/schemas/bibus/2#systemService</xsl:attribute>
  132. <xsl:attribute name="outputHeader">true</xsl:attribute>
  133. </xsl:when>
  134. <xsl:when test="@provider='assembler'">
  135. <xsl:attribute name="protocol">ASSEMBLER</xsl:attribute>
  136. <xsl:attribute name="target">unused</xsl:attribute>
  137. </xsl:when>
  138. <xsl:when test="@provider='consumer'">
  139. <xsl:attribute name="protocol">CONSUMER</xsl:attribute>
  140. <xsl:attribute name="target">unused</xsl:attribute>
  141. </xsl:when>
  142. <xsl:when test="@provider='storage'">
  143. <xsl:attribute name="protocol">STORAGE</xsl:attribute>
  144. <xsl:attribute name="target">unused</xsl:attribute>
  145. </xsl:when>
  146. <xsl:otherwise>
  147. <xsl:attribute name="protocol">SOAP</xsl:attribute>
  148. <xsl:copy-of select="@target | @href | @soapAction | @outputHeader"/>
  149. </xsl:otherwise>
  150. </xsl:choose>
  151. <xsl:call-template name="request-content"/>
  152. </xts:request>
  153. </xsl:otherwise>
  154. </xsl:choose>
  155. </xsl:template>
  156. <xsl:template name="request-content">
  157. <xsl:param name="content" select="*"/>
  158. <xsl:copy-of select="@option | @mimeType | @protocolHeader | @faultBlock"/>
  159. <!--
  160. Cookies
  161. the cookies attribute hold an xpath statement of the location of a cookie collection
  162. the cookies collection is an array of elements with name attribute and content
  163. -->
  164. <xsl:if test="@cookies">
  165. <out:variable name="cookies{ generate-id() }" select="{ @cookies }"/>
  166. <out:if test="$cookies{ generate-id() }">
  167. <xts:param name="header">
  168. <out:text>Cookie=</out:text>
  169. <out:for-each select="$cookies{ generate-id() }">
  170. <out:value-of select="@name"/>
  171. <out:text>=</out:text>
  172. <out:value-of select="."/>
  173. <out:if test="position() != last()">
  174. <out:text>; </out:text>
  175. </out:if>
  176. </out:for-each>
  177. </xts:param>
  178. </out:if>
  179. </xsl:if>
  180. <!-- copy any xts:output-param elements -->
  181. <xsl:copy-of select="*[local-name()='output-param']"/>
  182. <!-- envelope -->
  183. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  184. <SOAP-ENV:Header xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  185. <xsl:call-template name="bibus-header"/>
  186. <xsl:call-template name="service-header">
  187. <xsl:with-param name="tracking-headers" select="soap:cpx-tracking"/>
  188. </xsl:call-template>
  189. </SOAP-ENV:Header>
  190. <SOAP-ENV:Body>
  191. <xsl:apply-templates select="$content"/>
  192. </SOAP-ENV:Body>
  193. </SOAP-ENV:Envelope>
  194. </xsl:template>
  195. <xsl:template match="soap:cpx-tracking">
  196. <xsl:choose>
  197. <xsl:when test="parent::soap:request">
  198. </xsl:when>
  199. <xsl:otherwise>
  200. <xsl:copy-of select="."/>
  201. </xsl:otherwise>
  202. </xsl:choose>
  203. </xsl:template>
  204. <xsl:template match="soap:cpx-tracking-param">
  205. <out:variable name="{@name}" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Header/*[local-name()='serviceHeader']/*[local-name()='traceRequest']/*[local-name()='service']/*[local-name()='tracking']/*[local-name()='param' and @name='{@name}']"/>
  206. </xsl:template>
  207. <!--
  208. soap:response
  209. -->
  210. <xsl:template match="soap:response">
  211. <xos:part xmlns:xos="http://developer.cognos.com/schemas/xts/output/">
  212. <xos:entityHeader>
  213. <xos:param name="Content-Type">text/xml; charset=utf-8</xos:param>
  214. </xos:entityHeader>
  215. <xos:entityBody>
  216. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  217. <SOAP-ENV:Header>
  218. <xsl:call-template name="bibus-response"/>
  219. <xsl:call-template name="service-response"/>
  220. </SOAP-ENV:Header>
  221. <SOAP-ENV:Body>
  222. <xsl:apply-templates/>
  223. </SOAP-ENV:Body>
  224. </SOAP-ENV:Envelope>
  225. </xos:entityBody>
  226. </xos:part>
  227. </xsl:template>
  228. <!--
  229. BIBUS Support
  230. -->
  231. <xsl:template name="bibus-header">
  232. <out:variable name="bibus-header" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Header/bus:biBusHeader"/>
  233. <out:variable name="bibus" select="/root/header/bus:biBusHeader[not($bibus-header)] | $bibus-header"/>
  234. <out:if test="$bibus">
  235. <bus:biBusHeader xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="bus:biBusHeader">
  236. <xsl:choose>
  237. <!-- If the attribute directedRequest is present, then it's a xpath to a dispatcher. Make sure we add it's value as a child of trakking. -->
  238. <xsl:when test="@directedRequest != ''">
  239. <bus:tracking xsi:type="bus:tracking">
  240. <out:copy-of select="$bibus/bus:tracking/*[local-name() != 'conversationContext']"/>
  241. <bus:conversationContext xsi:type="bus:conversationContext">
  242. <out:copy-of select="$bibus/bus:tracking/bus:conversationContext/*[local-name() != 'nodeID']"/>
  243. <nodeID xsi:type="xsd:string">
  244. <out:value-of select="{ @directedRequest }"/>
  245. </nodeID>
  246. </bus:conversationContext>
  247. </bus:tracking>
  248. </xsl:when>
  249. <xsl:otherwise>
  250. <out:choose>
  251. <out:when test="/root/env/param[@name = 'm_tracking'] and /root/env/param[@name = 'm_tracking']!='' and '{ @affinity }'='.high'">
  252. <out:value-of select="xtsext:web64decode( xtsext:cafaction( 'sign_unwrap', string( /root/env/param[@name = 'm_tracking'] )), true() )" disable-output-escaping="yes"/>
  253. </out:when>
  254. <out:otherwise>
  255. <out:copy-of select="$bibus/bus:tracking"/>
  256. </out:otherwise>
  257. </out:choose>
  258. </xsl:otherwise>
  259. </xsl:choose>
  260. <!-- set up the rest of the header elements -->
  261. <out:for-each select="$bibus/*">
  262. <out:choose>
  263. <out:when test="local-name()='tracking'"/>
  264. <out:when test="local-name()='setCookieVars'"/>
  265. <out:when test="local-name()='cookieVars'"/>
  266. <out:when test="local-name()='hdrSession'">
  267. <xsl:choose>
  268. <xsl:when test="starts-with(@provider, 'cm')">
  269. <!-- trim the bus header before sending to cm -->
  270. <out:copy>
  271. <out:copy-of select="@*"/>
  272. <bus:formFieldVars xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:formFieldVar[]">
  273. <out:copy-of select="item[starts-with(name, 'CAM')]"/>
  274. </bus:formFieldVars>
  275. <out:copy-of select="*[local-name() != 'formFieldVars']"/>
  276. </out:copy>
  277. </xsl:when>
  278. <xsl:otherwise>
  279. <out:copy>
  280. <out:copy-of select="@*"/>
  281. <out:copy-of select="*"/>
  282. </out:copy>
  283. </xsl:otherwise>
  284. </xsl:choose>
  285. </out:when>
  286. <out:otherwise>
  287. <out:copy>
  288. <out:copy-of select="@*"/>
  289. <!-- copy child elements except the CAMCredentialPath -->
  290. <out:copy-of select="*[local-name() != 'CAMCredentialPath']"/>
  291. </out:copy>
  292. </out:otherwise>
  293. </out:choose>
  294. </out:for-each>
  295. <!-- cookies -->
  296. <xsl:if test="@cookies">
  297. <!--
  298. HACK ALERT:
  299. THIS DISPATCHER DOESN'T CURRENTLY SUPPORT PASSING HTTP COOKIES TO IT'S REQUEST HANDLERS,
  300. FOR SOAP REQUESTS. TO GET IB19 WORKING WE'LL CREATE BUS COOKIE ELEMENTS, IN ADDITION TO
  301. THE USUAL HTTP COOKIES.
  302. -->
  303. <out:if test="$cookies{ generate-id() }">
  304. <bus:hdrSession xsi:type="bus:hdrSession">
  305. <bus:cookieVars xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:cookieVar[]">
  306. <out:for-each select="$cookies{ generate-id() }">
  307. <item>
  308. <name xsi:type="xsd:string">
  309. <out:value-of select="@name"/>
  310. </name>
  311. <value xsi:type="xsd:string">
  312. <out:value-of select="."/>
  313. </value>
  314. </item>
  315. </out:for-each>
  316. </bus:cookieVars>
  317. </bus:hdrSession>
  318. </out:if>
  319. </xsl:if>
  320. </bus:biBusHeader>
  321. </out:if>
  322. </xsl:template>
  323. <xsl:template name="bibus-response">
  324. <out:copy-of select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Header/bus:biBusHeader"/>
  325. </xsl:template>
  326. <!--
  327. Cognos Web Service Headers
  328. -->
  329. <xsl:template name="service-header">
  330. <xsl:param name="tracking-headers"/>
  331. <cpx:serviceHeader>
  332. <cpx:traceRequest>
  333. <cpx:service>
  334. <cpx:operation>
  335. <xsl:value-of select="name(*[1])"/>
  336. </cpx:operation>
  337. <cpx:namespace>
  338. <xsl:value-of select="namespace-uri(*[1])"/>
  339. </cpx:namespace>
  340. <cpx:target>
  341. <out:value-of select="'{@target}'"/>
  342. </cpx:target>
  343. <cpx:tracking>
  344. <xsl:for-each select="$tracking-headers">
  345. <cpx:param name="{@name}">
  346. <out:value-of select="{@select}"/>
  347. </cpx:param>
  348. </xsl:for-each>
  349. <out:copy-of select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Header/cpx:serviceHeader/cpx:traceRequest/cpx:service/cpx:tracking/cpx:param"/>
  350. </cpx:tracking>
  351. <!--
  352. <cpx:timeRequest>
  353. <xts:function name="getTimer"/>
  354. </cpx:timeRequest>
  355. -->
  356. </cpx:service>
  357. </cpx:traceRequest>
  358. </cpx:serviceHeader>
  359. </xsl:template>
  360. <xsl:template name="service-response">
  361. <out:variable name="serviceHeader" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Header/cpx:serviceHeader"/>
  362. <out:if test="$serviceHeader">
  363. <out:variable name="traceRequest" select="$serviceHeader/cpx:traceRequest"/>
  364. <out:variable name="service" select="$traceRequest/cpx:service"/>
  365. <cpx:serviceHeader>
  366. <out:if test="$traceRequest">
  367. <cpx:traceResponse>
  368. <cpx:service>
  369. <out:copy-of select="$service/*"/>
  370. <!--
  371. <out:if test="$service/cpx:timeRequest">
  372. <cpx:timeResponse>
  373. <xts:function name="getTimer"/>
  374. </cpx:timeResponse>
  375. </out:if>
  376. -->
  377. <cpx:traceOutput>
  378. <out:value-of select="/root/debug/traceRequestPath"/>
  379. </cpx:traceOutput>
  380. <xts:queryNode select="//*[local-name() = 'traceResponse']/*"/>
  381. </cpx:service>
  382. </cpx:traceResponse>
  383. </out:if>
  384. </cpx:serviceHeader>
  385. </out:if>
  386. </xsl:template>
  387. <xsl:template match="*|@*|text()|processing-instruction()">
  388. <xsl:copy>
  389. <xsl:apply-templates select="*|@*|text()|processing-instruction()"/>
  390. </xsl:copy>
  391. </xsl:template>
  392. </xsl:stylesheet>