SI_Examples

Sterling Integrator examples like bpml, user exits, java code, extended rules codes, XSLT or any other type of code used in SI.
Mirjana's picture

HTTPS configuration and process between SI and MS IIS

I will go through settings we have to done at SI (HTTP client) and IIS (HTTP server) sides, in order to obtain HTTPS connection with server and client authentication included
 
IIS Manager:
 
 
URL that will be used in our process is:
 
https://PUTEST/mirjanaTest/test.html

 
Server Authentication
 
  • Apply Server Certificate in IIS server (for server authentication)
 
Right click on Default Web Site >> Properties >> Directory Security >> Server Certificate … add a certificate you wish.
 
  • Public key of the server certificate must be gotten from a partner and added as CA certificate in SI
 
Dashboard >> Trading Partners >>Digital Certificates >> CA >> New Certificate …  
 
Certificate checked in to the system is:
 
 
This certificate must be added to HTTP Client Begin Session Service as CACertificateID
 
 
Client Authentication
 
 
  • Certificate on SI:
 
We have to have a certificate (private – public) in the client side and its public key in the server side. After getting certificate, created by any wizard like self-signed or gotten by CA, we have to deploy it in SI system.
 
Dashboard >> Trading Partners >>Digital Certificates >> System >> Check-in
 
 
 
This certificate must be added to HTTP Client Begin Session Service as SystemCertificateId
 
 
  • Turn on client authentication on IIS side:
 
Right click on the application name that you will access to (e.g. mirjanaTest in our example) >> Properties >> Directory Security >> Secure communications >> Edit … >> Require secure channel (SSL) >> Require client certificates
 
 
  • Managinging trusted root certificates for a local computer
 
To include a root certificate in the server side, for client authentication, go to Microsoft Management Console, MMC (write mmc in Run or command prompt).
 
 
File menu >> Add/Remove Snap-in >> Add >> Certificates >> Computer account >> Local computer and open Certificates for the Local Computer
 
 
 
 
 
Go to Trusted Root Certification Authorities >> Certificates (right click) >> All Tasks >> Import … and import a new certificate (e.g. ABC)
 
 
 
BPML, server and client authentication included:
 
<process name="default">
 <sequence name="Sequence Start">
    <operation name="HTTP Client Begin Session Service">
      <participant name="HTTPClientBeginSession"/>
      <output message="HTTPClientBeginSessionServiceTypeInputMessage">
        <assign to="." from="*"></assign>
        <assign to="RemoteHost">putest</assign>
        <assign to="SystemCertificateId">MIRJANA:node1:12e4c62e17e:70732</assign>
       <assign to="HTTPClientAdapter">HTTPClientAdapter</assign>
        <assign to="CACertificateId">MIRJANA:node1:12e37c1aba0:172438</assign>
        <assign to="SSL">Must</assign>
        <assign to="RemotePort">443</assign>
        <assign to="CipherStrength">all</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <operation name="HTTP Client GET Service">
      <participant name="HTTPClientGet"/>
      <output message="HTTPClientGetServiceTypeInputMessage">
        <assign to="." from="*"></assign>
        <assign to="SessionToken" from="SessionToken/text()"></assign>
        <assign to="URI">/mirjanaTest/test.html</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <operation name="HTTP Client End Session Service">
      <participant name="HTTPClientEndSession"/>
      <output message="HTTPClientEndSessionServiceTypeInputMessage">
        <assign to="." from="*"></assign>
        <assign to="SessionToken" from="SessionToken/text()"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
 </sequence>
</process>
 
 

 

Mirjana's picture

Xpath - Check filename attribute after FSA multiple collect

Request:
 
Write the rule that will check if the filename has an extension .inv or .sls, and depending on that will be extracted in a separate folders.
 
The Process Data:
 
<ProcessData>
         <BPID>5060827</BPID>
         <currentTimeMillis>1288382751118</currentTimeMillis>
         <time>20101029160511851</time>
         <loop_counter>1</loop_counter>
         <X12_ArchiveDirectory>/app/archive/</X12_ArchiveDirectory>
         <FSA_Document1 SCIObjectID="serverName:38a97b0b:12bf942739e:1144" filename="ConcatSLS2.sls"/>
         <FSA_Document2 SCIObjectID="" filename="ConcatINV2.inv"/>
         <FSA_DocumentCount>2</FSA_DocumentCount>
         <Prev_NotSuccess_Adv_Status/>
         <INVOKE_ID_LIST>5060828</INVOKE_ID_LIST>
</ProcessData>
 
 
The wrong XPath used in the rule is:
contains(string('FSA_Document',//loop_counter/text(),' ',SCIObjectID/text()), string('.sls')
 
… and it does not work!!!
 
To check if the filename attribute in FSA_Document[n] element contains ‘inv’ or ‘sls’, XPath should be like this:
 
contains(//*[name()=concat('FSA_Document',//loop_counter/text())]/@filename,'.sls')
 
That would be interpreted as:
 
… check if the attribute ’filename’ (@filename)
… inside of the element which name is FSA_Document[n] (composed dynamically by concat function)
… contains ‘.sls’ string
 
Result will be boolean, true or false, and depending on that FSA extraction folder can be set .
 
Mirjana's picture

FTP Quote Service - check return code from server

Request:
 
We use BP as FTP client. FTP server sends back return code that is interpreted as error at the SI side, but in fact it should be success.
 
If we want the return code to be interpreted as success, there is a way to use FTP QUOTE service. FTP QUOTE can run any FTP raw command and service will always finish with success and return code that is send back to a BP will be written to the Process Data.
  • FTP QUOTE command (from the documentation): This service never produces a fault, because the service does not know what constitutes a valid response from the quoted command.
 After that we can make a choice, check the return code and finally decide if it was success or error. 
 

FTP Raw commands:

ABOR
abort a file transfer
CWD
change working directory
DELE
delete a remote file
LIST
list remote files
MDTM
return the modification time of a file
MKD
make a remote directory
NLST
name list of remote directory
PASS
send password
PASV
enter passive mode
PORT
open a data
PWD
print working directory
QUIT
terminate the connection
RETR
retrieve a remote file
RMD
remove a remote directory
RNFR
rename from
RNTO
rename to
SITE
site-specific commands
SIZE
return the size of a file
STOR
store a file on the remote host
TYPE
set transfer type
USER
send username

 
Business process:
 
This process is written for CD command (raw command for CD is CWD). This process communicate to a custom FTP server, the return code that was sent back for Change Directory command was interpreted as error in SI. So we used FTP Client QUOTE Service and cheked a return code. If it was 200 or 250, both were treated as success, but for any other process failed.
Rule used for checking is:
 
number(ServerResponse/Code/text()) = 200
or
number(ServerResponse/Code/text()) = 250
 
 
BPML Code:
 
<process name="default">
 
 <rule name="CWDfailed">
    <condition>number(ServerResponse/Code/text()) = 200
or
number(ServerResponse/Code/text()) = 250</condition>
 </rule>

 
 <sequence name="START1">
    <operation name="File System Adapter">
      <participant name="FS_WriteEDI"/>
      <output message="FileSystemInputMessage">
        <assign to="Action">FS_COLLECT</assign>
        <assign to="collectionFolder">/home/si/mirjana/test</assign>
        <assign to="deleteAfterCollect">false</assign>
        <assign to="filter">PLIVA_inputData.txt</assign>
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <operation name="XML Encoder">
      <participant name="XMLEncoder"/>
      <output message="XMLEncoderTypeInputMessage">
        <assign to="map_name">PLIVA_XMLObject</assign>
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <operation name="FTP Client Begin Session Service">
      <participant name="FTPClientBeginSession"/>
      <output message="FTPClientBeginSessionServiceTypeInputMessage">
        <assign to="FTPClientAdapter">FTPClientAdapter</assign>
        <assign to="RemoteHost">192.168.101.128</assign>
        <assign to="RemotePasswd">HPdds10</assign>
        <assign to="RemotePort">21</assign>
        <assign to="RemoteUserId">si</assign>
        <assign to="UsingRevealedPasswd">true</assign>
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <operation name="FTP Client QUOTE Service">
      <participant name="FTPClientQuote"/>
      <output message="FTPClientQuoteServiceTypeInputMessage">
        <assign to="SessionToken" from="//SessionToken/text()"></assign>
        <assign to="QuoteCommand">CWD mirjana</assign>
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <choice name="Choice Start">
      <select>
        <case ref="CWDfailed" negative="true" activity="START2"/>
      </select>
 
      <sequence name="START2">
        <operation name="Business Process Exception">
          <participant name="BPExceptionService"/>
          <output message="BPExceptionServiceTypeInputMessage">
            <assign to="exceptionCode">550</assign>
            <assign to="statusReport">CWD command unsuccessful</assign>
            <assign to="." from="*"></assign>
          </output>
          <input message="inmsg">
            <assign to="." from="*"></assign>
          </input>
        </operation>
 
      </sequence>
    </choice>
 
    <operation name="FTP Client LIST Service">
      <participant name="FTPClientList"/>
      <output message="FTPClientListServiceTypeInputMessage">
        <assign to="SessionToken" from="//SessionToken/text()"></assign>
        <assign to="." from="*"></assign>
      </output>
     <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <operation name="FTP Client End Session Service">
      <participant name="FTPClientEndSession"/>
      <output message="FTPClientEndSessionServiceTypeInputMessage">
        <assign to="SessionToken" from="//SessionToken/text()"></assign>
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <onFault code="550">
      <sequence name="Sequence Start">
        <assign name="Assign" to="error">550 CWD failed</assign>
      </sequence>
    </onFault>
 </sequence>
</process>
 
 
Mirjana's picture

Extended rule - get a system date in a map

System date, comparison of dates and adding dates to a field value of datetime type

// this extended rule explains how to take system date, compare it with date field from input data and also add some days to the field value  
object sysDate;
object sysDateFormat;
string[8] sysDateString;
datetime sysDate2;

sysDate = new("java.util.Date");
sysDateFormat = new("java.text.SimpleDateFormat","yyyyMMdd");
sysDateString = sysDateFormat.format(sysDate);

sysDate2 = date("%y%y%m%d",sysDateString);
if (#field_date < sysDate2) then
begin
   messagebox("date older than system date",0);
   #field_date = sysDate2 << days(7); 
end
   else
begin
   messagebox("date newer than system date",0);
end

Mirjana's picture

Sending an email after EDI Inbound processing

Request:
 
Send an email after EDI Inbound processing. Translated document must be sent as an attachment, and mail body should contain some static text/message or text dynamicaly created from envelopes included in that current processing (information can be gotten from the Process Data).
 
This piece of code, for sending an email, can be added in any process. In the case of EDI we will add specific data into body of mail, such as Sender ID, Receiver ID and Control Number.
 
Code can be added in the end of the business process (EDIInboundFileSystemExtraction) defined in UNH/UNT (EDIFACT) or ST/SE inbound envelope (X12):
 
 
 
EDIInboundFileSystemExtraction system process is used for this example and modified with services added for mail sending. Services are added in the very end of the BP.
This is just for test purposes.
 
Note: it is NOT recommended to make changes in system processes. It is better to use a custom process that will be run after deenveloping and translation. With patch installation, the system processes are overriden by new ones. 
Even if you make modifications on system processes, take it into consideration after upgrade, and move your custom versions of system processes back. Also, if any change is done by developers that come by a new patch, you will not get it, after you import your custom versions of system process.
 
Services for preparing and sending mail:
 
 
Assign element: used to move result of translation, that is normally under Primary Document, into a document with a different name. It is done because Mail Mime Service can take all the documents, with names different than PrimaryDocument, into attachment, and Primary Document is taken for a body of the mail.
 
<assign name="Assign" to="PrimaryDocument_forAttachment" from="PrimaryDocument/@SCIObjectID"></assign>
 
XSLT service: used to create an email body message with info from the Process Data. Result of XSLT Service will be in the Primary Document.
 
Mail Mime Service: create a MIME message, with attachment(s), body, including sender, receipient and other details in the mail based on settings of the service.
In Mail Mime Service, if we have parametermail-mime-use-doc-area set to true, then all the documents with names different than 'PrimaryDocument' will be attached to the mail. If there are more than one non-Primary Document, I do not know the way to select only some of the documents for attachments, the only solution is to make Release of the documents we do not want to be attached prior to creating MIME message.
 
SMTP Send Adapter: send an email. If it is preceeded by Mail Mime Service, like in this example, b2b-raw-message must be set to true, as SMTP Send Adapter get full MIME message. Also xport-smtp-mailhost and xport-smtp-mailport must be set.
 
BPML code:
 
Here is an example of bpml code and process for sending an email with attachment, for previously explained request.
Note: This is not a well formed XML/bpml as that is only a part of the full business process.
 
...
<assign name="Assign" to="PrimaryDocument_forAttachment" from="PrimaryDocument/@SCIObjectID"></assign>
 
    <operation name="XSLT Service">
      <participant name="XSLTService"/>
      <output message="XSLTServiceTypeInputMessage">
        <assign to="." from="*"></assign>
        <assign to="xslt_name">TEST_EDI_report</assign>
        <assign to="xml_input_from">ProcData</assign>
        <assign to="input_pd_xpath">/</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <operation name="Mail Mime Service">
      <participant name="MailMimeService"/>
      <output message="MailMimeServiceInputMessage">
       <assign to="." from="*"></assign>
        <assign to="mail-mime-subject">EDI inbound - report</assign>
        <assign to="mail-mime-sender">admin@localhost</assign>
        <assign to="mail-mime-operation">build</assign>
        <assign to="mail-mime-use-doc-area">true</assign>
        <assign to="mail-mime-recipient">admin@localhost</assign>
        <assign to="mail-mime-body">true</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 
    <operation name="SMTP Send Adapter">
      <participant name="SMTP_SEND_ADAPTER"/>
      <output message="SMTP_SEND_ADAPTERInputMessage">
        <assign to="." from="*"></assign>
        <assign to="xport-smtp-mailhost">192.168.101.136</assign>
        <assign to="b2b-raw-message">true</assign>
        <assign to="xport-smtp-mailport">25</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
...
 
Process Data:
 
Here is the Process Data after deenveloping and translation in EDI Inbound process has been done:
 
<?xml version="1.0" encoding="UTF-8"?>
<ProcessData>
         <PrimaryDocument SCIObjectID="mirjana:node1:12dd166c5f9:341799"/>
         <EnvelopeName>myUNH</EnvelopeName>
         <SegmentTerminator>39</SegmentTerminator>
         <elementForCC/>
         <InterchangeEnvelopeID>madrugada:699a1547:10a2a738628:-507e</InterchangeEnvelopeID>
         <TagSeparator>43</TagSeparator>
         <orderID>3830035970002-00000178</orderID>
         <MessageType>ORDERS</MessageType>
         <ComplianceCheckMapName>IE_EDIorders2inhouse</ComplianceCheckMapName>
         <InterchangeEnvelopeName>myUNB</InterchangeEnvelopeName>
         <ElementSeparator>43</ElementSeparator>
         <InterchangeRecipientID>3838551999996</InterchangeRecipientID>
         <ReleaseCharacter>63</ReleaseCharacter>
         <InterchangeTestIndicator>1</InterchangeTestIndicator>
         <EnvelopeID>madrugada:699a1547:10a3ae7370d:-72f6</EnvelopeID>
         <InterchangeControlNumber>100135</InterchangeControlNumber>
         <MessageReferenceNumber>5</MessageReferenceNumber>
         <InterchangeSenderID>3830035970002</InterchangeSenderID>
         <BAD_WFD_NAME>IE_nonCompliant_error_BP</BAD_WFD_NAME>
         <SubElementSeparator>58</SubElementSeparator>
</ProcessData>
 
OrderID, MessageType, InterchangeRecipientID, InterchangeControlNumber and InterchangeSenderID will be taken for creating mail body by using XSLT.
 
XSLT Service – for mail body:
 
This XSLT will create an email body message
 
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:output method="html" encoding="iso-8859-2" indent="yes"/>
         <xsl:template match="/">
                   <html>
                            <body>
                                      <b>EDI Report</b>
                                      <br/>
                                      <br/>
                                      <table>
                                               <tr>
                                                        <td>Order Id</td>
                                                        <td>
                                                                  <xsl:value-of select="//orderID/text()"/>
                                                        </td>
                                               </tr>
                                               <tr>
                                                        <td>Message Type</td>
                                                        <td>
                                                                 <xsl:value-of select="//MessageType/text()"/>
                                                        </td>
                                               </tr>
                                               <tr>
                                                        <td>InterchangeControlNumber</td>
                                                        <td>
                                                                  <xsl:value-of select="//InterchangeControlNumber/text()"/>
                                                        </td>
                                               </tr>
                                               <tr>
                                                        <td>InterchangeSenderID</td>
                                                        <td>
                                                                  <xsl:value-of select="//InterchangeSenderID/text()"/>
                                                        </td>
                                               </tr>
                                               <tr>
                                                        <td>InterchangeRecipientID</td>
                                                        <td>
                                                                  <xsl:value-of select="//InterchangeRecipientID/text()"/>
                                                        </td>
                                               </tr>
                                     </table>
                            </body>
                   </html>
         </xsl:template>
</xsl:stylesheet>
 
Mail gotten from the process:
 
 
You can find deenveloped and translated file in the attachment and result of XSLT translation in the body.
 
Change the attachment name:
 
Attachment has the default name given by EDI services, if you want to change it, you should set another name for the document that will be used for attachment. That can be done by Get Document Info Service, as the first step, so before assigning the PrimaryDocument into PrimaryDocument_forAttachment in the assign element.
 
 
 
Get Document Info service configuration:
 
<operation name="Get Document Information Service">
         <participant name="GetDocumentInfoService"/>
         <output message="GetDocumentInfoServiceTypeInputMessage">
                   <assign to="." from="*"/>
                   <assign to="BodyName">newAttachmentName</assign>
                   <assign to="updateMetaDataOnly">true</assign>
         </output>
         <input message="inmsg">
                   <assign to="." from="*"/>
         </input>
</operation>
 

Mail after setting a new Body Name for the document that will be attached to the mail:

Syndicate content