cancel
Showing results for 
Search instead for 
Did you mean: 

Unique Session ID in XSLT

Former Member
0 Kudos

Hello SND-ers,

Iu2019m having a little difficulty figuring out how to obtain the GUID or another unique session ID to place in field u2018SeqNumu2019. This XSLT creates a custom soap envelope around a payload and Iu2019m using this in an operation mapping in PI 7.1. I need to place a unique session ID in that u2018SeqNumu2019 field, but havenu2019t figured out how to do this yet. I didnu2019t know if there was a specific PI namespace that I could reference similar to the date/time example in the code below. Any help or guidance would be very much appreciated. Iu2019ve only included the top portion of the code to be clear in my request.

<xsl:stylesheet version="2.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:wsa="http://www.w3.org/2005/08/addressing"

xmlns:date="http://exslt.org/dates-and-times">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:variable name="Date" select="date:date()"/>

<xsl:variable name="Time" select="date:time()"/>

<!unique id for the session - this can be the existing session id or guid>

<xsl:param name="SeqNum" select=u201D<requestedvalue>u201D/>

I tried finding a reference library of some sort that may contain this information, but so far have been unsuccessful.

Thanks,

Jason

ps - as another side request, is it possible to pull the hostname or MAC address of the server to place that in the XSL as a dynamic value?

Edited by: Jason Ray on Aug 14, 2009 5:53 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

These runtime constants can be accessed using the sample xslt below:

http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm


<?xml version = "1.0" encoding = "utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:param name="MessageId"/>

  <xsl:template match="/">
     <msgguid>
       <xsl:value-of select="$MessageId"/>
     </msgguid>
  </xsl:template>

</xsl:stylesheet>

Regarding getting the MAC, I would create a small java class and call it as a function. Might as well do the same to get the host name. You can try to get it from a system property if you find one which will work. For example:


            <user>
               <xsl:value-of select="system-property('user.name')"/>
            </user>

Thanks,

-Russ

Former Member
0 Kudos

>

> Have you also added the following statements?

>

xmlns:map="java:java.util.Map"
> <xsl:param name="inputparam"/>
> and
> <xsl:variable name="dynamic-conf" select="map:get($inputparam, 'DynamicConfiguration')" />

>

> Regards,

> Prateek

i have not added that code because i do not wish to pull in the payload of the message quite yet. i'm creating a wrapper for it in the XSLT instead. I'm interested in the GUID or the message ID and placing that value in a field in the XSLT. I hope this makes sense. Below at the bottom i've included more of the message to show what i'm trying to do.

>

> These runtime constants can be accessed using the sample xslt below:

> http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm

>


> <?xml version = "1.0" encoding = "utf-8"?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
>   <xsl:param name="MessageId"/>
> 
>   <xsl:template match="/">
>      <msgguid>
>        <xsl:value-of select="$MessageId"/>
>      </msgguid>
>   </xsl:template>
> 
> </xsl:stylesheet>
> 

> Regarding getting the MAC, I would create a small java class and call it as a function. Might as well do the same to get the host name. You can try to get it from a system property if you find one which will work. For example:

>


>             <user>
>                <xsl:value-of select="system-property('user.name')"/>
>             </user>
> 

>

> Thanks,

> -Russ

This is more along the lines of what i'm trying to do. I saw the runtime constants before and i do believe that the MessageId is what i need. The issue is that when i add in the syntax from the example it fails stating that the stylesheet cannot be compiled. Below is the code after I removed the sensitive information and cut a lot of the unnecessary code to simplify:

I feel I need to add a namespace for the MessageId declaration, similar to how Iu2019ve declared the u2018dateu2019 namespace and referenced functions for the date and time. Is this true, or is that not needed?

Iu2019ll also see if I can figure out how to incorporate a small java class for the retrieval of the hostname and MAC. For now Iu2019ll be sending a static value since the required field just wants a unique ID for the source system.

Edited by: Jason Ray on Aug 19, 2009 5:46 PM

Former Member
0 Kudos

Code being used (for some reason i couldn't post this with my previous post...) - pardon the poor indenting


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:date="http://exslt.org/dates-and-times">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:variable name="Date" select="date:date()"/>
  <xsl:variable name="Time" select="date:time()"/>
  <xsl:param name="MessageId"/>
  <xsl:variable name="Version" select="'1.0'"/>
  <xsl:template match="*">
  <soap:Envelope>
    <soap:Header>
      <svrhdr:ServiceHeader xmlns:svrhdr="(location)" schemaLocation="ServiceHeader.xsd">
      <svrhdr:StaticRegion>
        <svrhdr:OriginatingTimeStamp>
          <svrhdr:TimeStamp>
            <svrhdr:Date>
              <xsl:value-of select="$Date"/>
            </svrhdr:Date>
            <svrhdr:Time>
              <xsl:value-of select="$Time"/>
            </svrhdr:Time>
         </svrhdr:TimeStamp>
      </svrhdr:OriginatingTimeStamp>
      <svrhdr:OriginatingSessionGUID>
        <svrhdr:SessionID>
          <svrhdr:SequenceNumber>
            <xsl:value-of select="$MessageId"/>
          </svrhdr:SequenceNumber>
       </svrhdr:SessionID>
    </svrhdr:OriginatingSessionGUID>
    <svrhdr:StaticHeaderVersionNumber>
      <xsl:value-of select="$Version"/>
    </svrhdr:StaticHeaderVersionNumber>
 </svrhdr:StaticRegion>
</svrhdr:ServiceHeader>
</soap:Header>
  <soap:Body>
    <xsl:copy-of select="/*"/>
  </soap:Body>
</soap:Envelope>
</xsl:template>
</xsl:stylesheet>

Edited by: Jason Ray on Aug 19, 2009 5:47 PM

Former Member
0 Kudos

Currently i have implemented the code as in the example regarding the MessageId, but it fails to produce a value. Am i doing anything wrong? Why is there no value associated with 'MessageId'?

Former Member
0 Kudos

duplicate message

Edited by: Jason Ray on Aug 26, 2009 11:34 PM

Former Member
0 Kudos

The MessageId parameter worked. I failed to recognize it as a Runtime constant during testing and did not see a value during my unit testing because...well...it wasn't in Runtime (ie: i only tested the OM and MM in design time).

Thanks - answer solved and appropriate points awarded.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

the best way to do that is

Date+time = DDMMYYYYHHmmss. Write the logic in java function and call that java function in XSLT whereever it is required.

You can find java function code on net easily..

Inder

prateek
Active Contributor
0 Kudos

You may try to access XI Message ID using dynamic configuration.

http://help.sap.com/saphelp_nw04/helpdata/en/43/03fe1bdc7821ade10000000a1553f6/frameset.htm

Regards,

Prateek

Former Member
0 Kudos

>

> You may try to access XI Message ID using dynamic configuration.

> http://help.sap.com/saphelp_nw04/helpdata/en/43/03fe1bdc7821ade10000000a1553f6/frameset.htm

>

> Regards,

> Prateek

Prateek,

Thanks for the link. This is similar to what i would like to do, but i don't want to change the values in the header. Ideally my goal is to pull the GUID value (or any unique ID for the session) and place it in the XSL as a field value. Is there a way to do this using a namespace definition and a function? Similar to the following:

xmlns:key="java:com.sap.aii.mapping.api.DynamicConfigurationKey"

<xsl:variable name="dynamic-key" select="key:create('http://sap.com/xi/XI/System/File', 'Directory')" />

i tried using the above syntax, but was unsuccessful: "could not compile stylesheet". I believe the namespace reference is invalid, but i'm unsure how to resolve this.

Thanks,

J

prateek
Active Contributor
0 Kudos

Have you also added the following statements?

xmlns:map="java:java.util.Map"
<xsl:param name="inputparam"/>
and
<xsl:variable name="dynamic-conf" select="map:get($inputparam, 'DynamicConfiguration')" />

Regards,

Prateek