SXI Forum

A place to collect usefull tips, tricks and implementation strategies.

You are not logged in.

#51 HOWTOS » Integrate XLayer with Slack » 04-01-2019 10:46:37

SeanR
Replies: 0

Modern tools claim to be able to integrate with many different technologies and SXI is no different.  You may see claims that certain tools can integrate into Slack and we can do the same thing, without any code changes simply in configuration.

To perform this integration the client will need to create a new Incoming Webhook Slack API App (See the section under Send Messages) in their Slack domain.  The administrator of the slack account will be able to do this.  They will need to provide you with the webhook URL.  Lets use one I created for the SXI Slack domain. 

https://hooks.slack.com/services/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

When you send a message to this webhook your message will appear in the #clientnotifications channel.

Simply setup XLayer to use a RESTConnector to send the message to Slack.

The connector config could look as simple as follows:

<Connector id="SlackConnector" type="RESTWebService">
      <Connection xsi:type="sxi:RESTWebService">
        <sxi:URL>https://hooks.slack.com/services/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</sxi:URL>
        <sxi:DataTypeToSend>JSON</sxi:DataTypeToSend>
        <sxi:RetryDelay>60</sxi:RetryDelay>
      </Connection>
      <sxi:ReturnCodes>
        <sxi:Success>
          <sxi:Code>Success Code</sxi:Code>
        </sxi:Success>
        <sxi:RecoverableError>
          <sxi:Code>Recoverable Error</sxi:Code>
        </sxi:RecoverableError>
      </sxi:ReturnCodes>
    </Connector>

and the DataDefinition as follows:

<sxi:DataDefinition name="SendSlackMessage">
      <sxi:Fields>
        <sxi:Field name="dummy">
          <sxi:Rules>
            <sxi:Default>Testing from inside XLayer</sxi:Default>
          </sxi:Rules>
          <sxi:OutputField>text</sxi:OutputField>
        </sxi:Field>
      </sxi:Fields>
    </sxi:DataDefinition>

As you can see NO stylesheet is needed, however you do need to have an output field of text.  Youcan obviously read the message from an inputfield but inm this example I have chosen to simply send a default message.

This results in "Testing from inside XLayer" appearing in the #clientnotifications channel.

Hope this helps.

#52 Re: Case Exchange » Converting a Date Time stamp » 28-12-2018 08:24:36

Hi Steph,

This is untested however it should work.  I got the date format rules for SimpleDateFormat from here.  Specifically look at "Pattern Syntax" and "Pattern Examples" on that page.

    <sxi:DataDefinition name="ConvertDate">
      <sxi:Fields>
        <sxi:Field name="InDate">
          <sxi:Rules>
            <sxi:DateConverter InputDateFormat="dd MMMM yyyy h:mm a" OutputDateFormat="yyyy/MM/DD HH:MM:ss"/>
          </sxi:Rules>
          <sxi:OutputField>OutDate</sxi:OutputField>
        </sxi:Field>
      </sxi:Fields>
    </sxi:DataDefinition>

Not sure how you are going to get the seconds as they are not provided in the input example you gave.

Ciao
Sean

#53 HOWTOS » Elastic Stack » 12-12-2018 07:57:12

SeanR
Replies: 5

Below is a basic installation plan for Elastic Stack.  Elastic stack is made up of many components however this outlines the 3 main ones.

Basic configuration files can be found in the SXI Github Repository

Installation Steps:
  1. To install some of these products as a Windows Service you will need the NSSM util which can be downloaded here

    • As a SXI standard we normally extract this util to X:\SXI\Utilities

  2. Download the relevant Elastic Stack products from here

  3. Extract each of the zip files into their own directory under the X:/SXI/Dashboard directory. 

    • X: is the drive you wish to run Elastic Stack from, Dashboard is a SXI standard location for the Elastic Installation.

    • There must be NO spaced in the path name to the elastic stack directories.

  4. To install “elasticsearch” as a windows service perform the following tasks:

    1. Ensure that a System Variable called JAVA_HOME it pointing a jre directory that was installed previously

    2. Run the following command “elasticsearch-service.bat install” from within the X:\SXI\Dashboard\elasticsearch\bin directory

Elastic Search

To test is ElasticSearch was installed correctly start the service and browse to http://127.0.0.1:9200/ you should eventually be greeted with a json object which includes the following: 

"tagline" : "You Know, for Search"
Logstash

Logstash needs a config file to tell it what logs to collect from where.  These are normally kept in the config directory.  Please see Using Logstash for more information.

To install “logstash” as a windows service perform the following tasks:

  1. Create the following dir x:\SXI\Dashboard\sincedb

  2. Ensure you have created a config file as described in this post.

  3. In X:\SXI\Dashboard\logstash\bin run the following command: “X:\SXI\Utilities\nssm.exe install logstash”

  4. In the dialog box that pops up set Path: to X:\SXI\Dashboard\logstash\bin\logstash.bat

  5. Startup directory is automatically populated with X:\SXI\Dashboard\logstash\bin

  6. Set the Arguments to -f X:\SXI\Dashboard\logstash\config\name_of_the_config_you_created.json
            It may be better to use the -b X:\SXI\Dashboard\configs - this way we can keep all the logstash configs in one place and they will all be loaded

  7. Set the Service name = Logstash 6.x where x = latest version available

  8. Under the Details tab set Description: = Logstash 6.x Windows Service - https://elastic.co

Kibana

To install “kibana” as a windows service perform the following tasks:

  1. In X:\SXI\Dashboard\kibana\bin run the following command: “X:\SXI\Utilities\nssm.exe install kibana”

  2. In the dialog box that pops up set Path: to X:\SXI\Dashboard\kibana\bin\kibana.bat

  3. Startup directory is automatically populated with X:\SXI\Dashboard\kibana\bin

  4. Set the Service name = Kibana 6.x where x = latest version available

  5. Under the Details tab set Description: = Kibana 6.x Windows Service - https://elastic.co

To test if Kibana was setup correctly start the service and browse to http://127.0.0.1:5601/ and you will eventually see the Kibana Icon.

#54 SXI Web Services » Install and Configure the new SXI Webservices » 28-11-2018 20:04:31

SeanR
Replies: 0

With v2.3 of the SXI Web services you get some additional functionality.  SXIWebservices are distributed as a war file which can be downloaded from the SXI web server.

Below are some of the new features:

  1. Each web service has the ability of writing their transaction to a database

  2. The tables will be created should they not exist

  3. SXIWebServices makes use of Tomcat connection pooling

  4. Any database that is supported by Tomcat can be used for SXIWebServices

  5. SXI Rest Importer and SXI SOAP Importer can also now be called synchronously

Some of the notable changes:

  1. The config names have been changed to remove the word Async (e.g REST Importer used to be called SXIRESTAsyncImporter.properties however it is now called SXIRESTImporter.properties

  2. The REST importer and the SOAP importer each have their own log for both the Async and Sync endpoints - this can be changed if need be.

  3. A common return object returned by all SXIWebServices

  4. Several bug fixes and code cleanups

Asynchronous Operation

When a calling system calls the asynchronous endpoints the web services will immediately respond with a Transaction Response.  This response will include the results of SAVING that transaction ONLY.  The transaction IDs that are returned are only the unique internal integration reference numbers that have been generated for each transaction and are not an indication of a full / complete transaction.  Asynchronous operations are typically called when integrating with systems like Service Desks.

Synchronous Operation

A synchronous operation relies on writing to a database.  The session will keep checking for a response that will be found in the "tranResult" field of specific transaction record that was inserted earlier.  The session will wait for the number of seconds found in the DBSyncTimeout configuration properties. 

  • If a response is found before the time out has expired the data inside the "tranResult" field is sent back to the calling system, as well as a SUCCESS transaction status.

  • If the Timeout value expires before the tranResult is found a FAILED status is returned to the calling system.

Installation:

Prerequisites:

  1. Java               - v1.8_192 or above

  2. Tomcat           - v9.0.13 or above

  3. MS SQLExpress - v2017 or above installed on your local server

Basic Steps
  1. Download the SXIWebServices-2.3.war file from the SXI FTP server

  2. Rename SXIWebServices-2.3.war to SXIWebServices.war

  3. Place the war file in the tomcat/webapps directory. Tomcat will extract it for you.

  4. Configure the relevant properties files

  5. Each SXIWebService endpoint has 3 potential outputs:

    1. XML file on the file system

    2. Database

    3. Elastic Search (Big Data - typically for reporting)

  6. Configure the endpoints (discussed below)

  7. Ensure the configuration that you are pointing to exists and can be accessed.

  8. Restart Tomcat to activate the new configuration.

Configuration
  1. Configure transactions to be written to an XML File:
    To configure the SXIWebService endpoint to create an XML file on the file system, edit the .properties file corresponding to the endpoint you wish to use.  These property files can be found in [tomcat_dir]/webapps/SXIWebServices/WEB-INF/classes directory.

    1. This functionality can be turned on by changing the CreateXML property from No to Yes.

    2. By default the Windows version of the XMLOutputPath is active.  Typically this is configured to point to the XPress XmlIn1, XmlIn2 or typically XmlOut directory.  If SXIWebServices is installed on a *nix machine then simply comment out the Windows XMLOutputPath property and un-comment the *Nix version and point the XMLOutputPath to the directory you wish to have the transaction files written into.

    3. Set the XMLEncoding to either ISO-8859-1 / UTF-8.  This determines what characterset is allowed to be placed into the XML output file.

    4. DefaultDestination must contain the IP address or hostname of the server where XPressStation is listening for transactions to be processed.  This can be left to 127.0.0.1 if you have configured XMLOutputPath to XmlOut - For more details about using the XLayer Transport Module XPress please speak to your SXI representative.

    NOTE: You MUST have write  permissions to access the directory configured in XMLOutputPath and the machine must have enough disk space to write those files.

    If you have enabled Creating XML files your config should include a section that look as follows:

    #==============================================================================#
    #Do you want the trigger to be created as an XML file: Yes/No
    CreateXML=Yes
    # Windows paths must use forward slashes.
    XMLOutputPath = C:/SXI/XPress/XmlOut
    #Unix
    #XMLOutputPath = /opt/SXI/docstore/process
    #This can be used to change the XML declaration (ISO-8859-1 / UTF-8)
    XMLEncoding=ISO-8859-1
    DefaultDestination = 127.0.0.1
  2. Configure transactions to be written to a Database:
    There are 2 parts to this configuration:

    • The properties file - Note: not all the properties are needed any longer as we have moved to connection pooling and the redundant properties will be removed in due course.

    • The Context.xml file used to configure Tomcat's Connection Pooling.

    To turn on the functionality of writing the transactions to a database you need to change the CreateDBRecord property from No to Yes.

    1. The Properties File:

      1. This functionality can be turned on by changing the CreateDBRecord property from No to YesThis will always be here

      2. DBType refers to the type of database you are going to write the transactions into.  In THIS example we will write transactions to a MSSQLExpress server that has been installed locally. 

        • Note: you will need to download the jtds-1.3.1.jar file and copy it to the [tomcat_dir]/lib directory.  This jar file can be downloaded from the SXI FTP Server.

        • If you are wanting to write to a different database you will need to download the database driver jar file that is needed to communicate with that specific database type and copy it into the [tomcat_dir]/lib directory.  There will also be further configuration to change in the Context.xml part.

      3. The DBServer property refers to the IP address or hostname of the server where the database is installed.

      4. The DBPort property refers to the port the database is listening on. 

        • Note: SQLExpress will NOT work unless you ensure that TCP is enabled and that the firewall is not blocking traffic on port 1433. 

      5. DBUser is a user that has suitable permissions to create a table and insert records into the DBName in the DBTriggerTable 

      6. DBPass is the password in clear text for the DBUser.

      7. DBName is the name of the database where the Web Service Transactions will be written to.

        • NOTE: This database MUST already exist before you can connect with the SXIWebServices.

      8. DBTriggerTable this is the name of the table where the transactions will actually be written to.  Note:  This table will be created if it does not already exist.

      9. DBSyncTimeout is a value in seconds indicating how long the Synchronous endpoints will wait for a response before returning to the calling system.  Please see more about the Synchronous operation lower down in this document.

      If you have enabled writing transactions to a database your config should include a section that look as follows:

      #==============================================================================#
      #Do you want the trigger to be inserted into a Database Table: Yes/No
      CreateDBRecord=Yes
      DBType=MSSQL
      DBServer=127.0.0.1
      DBPort=1433
      DBUser=sa
      DBPass=qwerty
      DBName=SXI_WS_Transactions
      DBTriggerTable=SXIWSTriggers
      DBSyncTimeout=15
    2. The context.xml File:
      The content.xml file can be found in the [tomcat_dir]/webapps/SXIWebServices/META-INF directory.
      Do NOT change the configuration option name="jdbc/sxiwsDB". It will break the connection pooling.  This will be address by configuration in a later version.
      You will not need to change everything in the Context.xml file and most of the fields are best left unchanged.  However the following will have to be changed:

      1. username is a user that has suitable permissions to create a table and insert records into the url database

      2. password is the password in clear text for the DBUser.

      3. url must include the SQL server (IP or name):port/<dbname>.

        • Note: there is no need to change the jdbc:jtds:sqlserver:// part of this url when we are using MSSQLExpress

        • If you are wanting to write to a different database you will need to download the database driver jar file that is needed to communicate with that specific database type you are wanting to write to and then copy it into the [tomcat_dir]/lib directory.  You will also need to change the driverClassName, typeand url (jdbc:jtds:sqlserver) lines in the Context.xml file.

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE xml>
      <Context path="/SXIWebServices">
        <Resource 
      	auth="Container" 
      	driverClassName="net.sourceforge.jtds.jdbc.Driver" 
      	maxActive="1000" 
      	maxIdle="30" 
      	maxWait="10000" 
      	name="jdbc/sxiwsDB" 
      	password="qwerty" 
      	removeAbandoned="true" 
      	removeAbandonedTimeout="30" 
      	type="javax.sql.DataSource" 
      	url="jdbc:jtds:sqlserver://localhost:1433/SXI_WS_Transactions" 
      	username="sa" 
      	validationQuery="select 1"/>
      </Context>
  3. Configure transactions to be written to Elastic Search:
    This can be turned on by changing the CreateXDataRecord from No to Yes.

    You will also need to configure the IP address and port of the Elastic Search index server.

    If you have enabled writing XData records to be processed your config should include a section that look as follows:

    #==============================================================================#
    #Do you want the trigger to be inserted into the X-Data Index: Yes/No
    CreateXDataRecord=Yes
    XDataIndexServer=127.0.0.1
    XDataIndexPort=9200

#55 Re: HOWTOS » Security: Generate and implement a Self Signed Certificate » 22-11-2018 08:38:47

Generate and implement a Self Signed Certificate for SSL Web Services connections, I use KeyTool IUI - standalone

https://code.google.com/p/keytool-iui/

#56 Re: HOWTOS » Getting Fiddler to capture SoapUI packets » 22-11-2018 08:35:06

You can get Fiddler to capture packets from X-ServiceBroker as well.

In SXI/X-ServiceBroker/bin you will find a file X-ServiceBroker.vmoptions

add the following lines to the bottom of the file

-DproxySet=true
-Dhttp.proxyHost=127.0.0.1
-Dhttp.proxyPort=8888

save it and restart X-ServiceBroker.

#57 Re: HOWTOS » Getting Fiddler to capture SoapUI packets » 22-11-2018 08:34:42

You can configure Oxygen to do the same by setting up a proxy in the same way.

Go to:
Options -> Preferences -> HTTP(S)/(S)FTP/Proxy Configuration

under Web Proxy (HTTP/HTTPS)
Address = 127.0.0.1
Port    = 8888

This will allow you to capture Oxygen packets in Fiddler.

#58 Re: HOWTOS » Removing "Funny" Characters from XML » 22-11-2018 08:32:48

Here is my style sheet to translate the En Dash “–” to Dash (Minus Sign) “-”

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:strip-space elements="*"/>

    <xsl:output method="xml" encoding="utf-8" indent="yes"/>

    <xsl:template match="text()">
        <xsl:value-of select='translate(., "&#8211;", "&#045;")'/>
    </xsl:template>

    <xsl:template match="*">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

#59 Re: HOWTOS » DOS command to delete files of a certain age » 22-11-2018 08:29:32

The "DEL" command can delete "Read Only" files by adding a /F switch.  This eliminates the need to use the "ATTRIB" command and saves considerable amount of time.

Unfortunately the "DEL" command sometimes result in a question where it asks "if ok to delete on global wildcard" this causes the automatic delete process to fail.  This can be overcome by using the /Q (Quiet) switch.

I use the below config in X-Scheduler to execute the "Auto" delete of files older than a certain number of days.

 <Schedule name="ClearOldFiles">
  <AT>30 00 * * *</AT> 
  <Action>
     <Path>E:\Program Files\Southern X Integrators\X-Scheduler\CMD Files</Path> 
     <Command>ClearOldFiles.cmd</Command> 
     <Arguments>10</Arguments> 
   </Action>
  </Schedule>

The "ClearOldFiles.cmd" is copied below and the way I've set it up is to delete all Success Store files older than 10 days and all Error Store files older than 21 days (11 days more than Success or the 10 day argument)

@Echo Off

SET Days=%1

IF "%Days%"=="" goto NoDays
SET Errors=11
SET /A ErrorDays=%Days%+%Errors%
echo Days = %Days%
echo ErrorDays = %ErrorDays%

@Rem Save curent Folder
Pushd .

@Rem Change to SuccessStore folder
cd /d E:\Program Files\Southern X Integrators\X-ServiceBroker\SuccessStore

@Echo Deleting files older than %Days% days in all subfolders of SuccessStore ...

forfiles /s /m *.* /D -%Days% /C "cmd /c DEL /F /Q @path"

@Rem Change to FileSigregErrorStore folder
cd /d E:\Program Files\Southern X Integrators\X-ServiceBroker\FileSigregErrorStore

@Echo Deleting files older than %ErrorDays% days in all subfolders of FileSigregErrorStore ...

forfiles /s /m *.* /D -%ErrorDays% /C "cmd /c DEL /F /Q @path"

@Rem Restore original folder
Popd

Pause
goto END

:NoDays

@Echo *****************************************************
@Echo *****************************************************
@Echo ***                                               ***
@Echo *** Please provide number of days as a parameter. ***
@Echo ***                                               ***
@Echo *****************************************************
@Echo *****************************************************

Pause
Echo Exit 1

:END
Echo Exit 0

#60 Re: HOWTOS » DOS command to delete files of a certain age » 22-11-2018 08:28:19

This should be used with discretion as it could take a very long time to execute depending on the amount of files to be deleted.

This can be done using the Windows Command "ForFiles" from the command line or a batch file.  Stephanus brought this to my attention and on further research, I found this Microsoft link with more detail on the command.

Below is the batch file that he sent to me modified to delete files older than 30 days from the whole SuccessStore and subfolders.

The "ATTRIB" command removes the readonly attribute from all the files and a "/s" parameter will apply both the "ATTRIB" & "FORFILES" command to all matching files in the current directory and all of its subdirectories.  Using this parameter, you could remove the "\NEW_INCIDENT" from the example below and that would then apply to all SuccessStore files irrespective of "Action" performed.

This batch file could be executed by X-Scheduler.

@echo off
SET Days=30

@echo Clears all Read-only file attribute...
@ Change to SuccessStore folder
cd /d E:\Program Files\Southern X Integrators\X-ServiceBroker\SuccessStore
@ Remove ReadOnly attribute to enable delete
ATTRIB -R /S *.*
@echo Deleting files older than %Days% days in all subdirectories ...
forfiles /p "E:\Program Files\Southern X Integrators\X-ServiceBroker\SuccessStore" /s /m *.* /D -

30 /C "cmd /c del @path"
exit 0

#61 Re: HOWTOS » Configuring the Excel connector to collect data » 22-11-2018 08:26:37

  1. I'm not entirely sure why the file name is not specified as one would do an XML file when using the XML connector. How you would read a file where the name of that file is contained in a field in memory is a mystery to me. ANY HELP ON THIS?

  2. LookupValue and LookupField can be blank, (or N/a in the case of LookupField) and the Source is the name of of the Excel Worksheet, as an Excel file can contain multiple worksheets.

  3. You can specify the column as the input field ( <sxi:Field name="A"> for column A) that will cause the collect to iterate through every single row of the spreadsheet, and collect values for column A on every row.

Or, you can specify the column and the row as input field ( <sxi:Field name="A1"> for column A row 1) that will cause the collect to only collect the data in that 1 cell?

#62 Re: HOWTOS » A DOS Script for Setting Service Startup » 22-11-2018 08:23:46

Or a slight variation where A service that must be manually started.

REM
REM A trivial script to set ALL the XLayer services startup “manual”

sc config X-Asset Client start=demand
sc config X-EventCollector start=demand
sc config X-FileTX start=demand
sc config X-HBChecker start=demand
sc config X-Notify start=demand
sc config X-Scheduler start=demand
sc config X-ServiceBroker start=demand
sc config XPressDispatch start=demand
sc config XPressStation start=demand
pause

#63 Re: HOWTOS » EXCEL Field names » 22-11-2018 08:20:45

Depending on how many columns you have on the excel file the below will be an example of the 1st field.

<sxi:Fields>
	<sxi:Field name="A">
	<sxi:OutputField>Fred</sxi:OutputField>
</sxi:Field>

Question is, how do you do you use conditions on the collect for each row because it seems like the condition you set on the collect is based on the 1st row collected and the rest of the rows are ignored?

Thank you

#64 Re: HOWTOS » Extracting information from Elements returned by a Web Service Call » 22-11-2018 08:16:33

The XML here is returned as a response to a Web Service call.

So the issue here is not an incorrect Xpath but rather the fact that you are trying to address an element which has not been loaded into memory.

To call a Web Service with X-ServiceBroker a "Create" mapping is used, as one needs to send information to the Web Service. This create is usually done with the aid of a stylesheet to construct the correct payload needed by the Web Service being consumed. The response returned by the Web Service is not automatically loaded into memory as it would have been had a Collect mapping being run.

Because of this, IMMEDIATELY following the Create mapping used to call the Web Service, one needs to call a Data Definition to extract the information elements from the response, this is typically done with a MemoryDataManipultion mapping. In the said DataDefinition the element can successfully be addressed with an XPath statement.

#65 Re: HOWTOS » Data Base Connection properties » 22-11-2018 08:14:35

These properties are used when trying to connect to a MSSQL database server that uses Windows Authentication.

Example of a config without properties:

<Connector id="MSSQL" type="DB">
	<Connection xsi:type="sxi:MSSQL">
		<sxi:Server>127.0.0.1</sxi:Server>
		<sxi:User>sxi</sxi:User>
		<sxi:Password>sxi</sxi:Password>
		<sxi:RetryDelay>30</sxi:RetryDelay>
		<sxi:DBName>XLayer</sxi:DBName>
		<sxi:Port>1433</sxi:Port>
	</Connection>
	<sxi:ReturnCodes>
		<sxi:Success></sxi:Success>
		<sxi:RecoverableError>
			<sxi:Code>I/OsError.*</sxi:Code>
			<sxi:Code>.+Read timed out.+</sxi:Code>
			<sxi:Code>Invalid state.+</sxi:Code>
			<sxi:Code>.+Invalid state.+</sxi:Code>
			<sxi:Code>.+Error.+</sxi:Code>
			<sxi:Code>.+SHUTDOWN is in progress.+</sxi:Code>
			<sxi:Code>SHUTDOWN is in progress.+</sxi:Code>
		</sxi:RecoverableError>
	</sxi:ReturnCodes>
</Connector>

Example of a config with properties included:

<Connector id="MSSQL" type="DB">
	<Connection xsi:type="sxi:MSSQL">
		<sxi:Server>127.0.0.1</sxi:Server>
		<sxi:User>sxi</sxi:User>
		<sxi:Password>sxi</sxi:Password>
		<sxi:RetryDelay>30</sxi:RetryDelay>
		<sxi:DBName>XLayer</sxi:DBName>
		
		<!-- ============= PROPERTIES ============= -->
	    <sxi:Properties>
			<sxi:Property name="instance" value="XLayer" />
			<sxi:Property name="domain" value="domain name"/>
			<sxi:Property name="useNTLMv2" value="true"/>
		</sxi:Properties>
		<!-- ============= PROPERTIES ============= -->
		
		<sxi:Port>1433</sxi:Port>
	</Connection>
	<sxi:ReturnCodes>
		<sxi:Success></sxi:Success>
		<sxi:RecoverableError>
			<sxi:Code>I/OsError.*</sxi:Code>
			<sxi:Code>.+Read timed out.+</sxi:Code>
			<sxi:Code>Invalid state.+</sxi:Code>
			<sxi:Code>.+Invalid state.+</sxi:Code>
			<sxi:Code>.+Error.+</sxi:Code>
			<sxi:Code>.+SHUTDOWN is in progress.+</sxi:Code>
			<sxi:Code>SHUTDOWN is in progress.+</sxi:Code>
		</sxi:RecoverableError>
	</sxi:ReturnCodes>
</Connector>

#66 Re: HOWTOS » Security: Tomcat Certificates » 22-11-2018 08:09:55

There is a simpler way to import a certificate for XLayer

Copy the certificate.pfx file to C:\Program Files\SXI\X-ServiceBroker\resource

Inside the C:\Program Files\SXI\jre\bin directory run the following

keytool.exe -importkeystore -srckeystore ..\..\X-ServiceBroker\resource\certificate.pfx -srcstoretype pkcs12 -destkeystore ..\..\X-ServiceBroker\resource\sxi.jks -deststoretype JKS

Next you will be asked for a Destination password: This is the password for SXI.JKS

Then you will be asked for a Source keystore password:  This is the password given to you by the person supplying the certificate

Enter and you should see the following
Import command completed:  1 entries successfully imported, 0 entries failed or cancelled

#67 Re: HOWTOS » Security: Tomcat Certificates » 22-11-2018 08:08:57

X-EventCollector

X-EventCollector uses the cacerts keystore found in the C:\Program Files\SXI\jre\lib\security directory.

to update the cacerts keystore using a .pfx file.

  1. extract the public key certificate from the .pfx file, using a tool called OpenSSL

  2. From a cmd prompt, run the following command (from the openssl install directory)

      
    openssl pkcs12 -in certname.pfx -nokeys -out cert.pem
  3. Import the public key into the cacerts file
       

    1. Copy cacerts from C:\Program Files\SXI\jre\lib\security directory to C:\Program Files\SXI\jre\bin
         

    2. Paste cert.pem into C:\Program Files\SXI\jre\bin
         

    3. Using cmd, run the following commands (from the SXI\jre\bin derectory)
         

      	keytool -import -alias root -keystore cacerts -trustcacerts -file cert.pem
      	keytool -import -alias inter -keystore cacerts -trustcacerts -file cert.pem
      	keytool -import -alias private -keystore cacerts -trustcacerts -file cert.pem
      	

          (password for cacerts is "changeit")
         

  4. Move cacerts file back to  C:\Program Files\SXI\jre\lib\security directory

  5. Restart X-EventCollector

#68 Re: HOWTOS » Security: Tomcat Certificates » 22-11-2018 07:53:22

Please view the following short video to see step by step how to extract a cert from a url using chrome.

How to extract a certificate from a URL using Chrome

#69 Re: HOWTOS » Rules: Strip html tags from a given value » 22-11-2018 07:49:18

The stripHTML rule has been added to the XLayer Rules library and should be used to strip HTML markup from data.

#70 Re: HOWTOS » Rules: Strip html tags from a given value » 22-11-2018 07:48:51

It is possible that the <(.|n)*?> regex could cause stackoverflow errors where the system runs out of memory.

It is recommended that this <.*?> regex rather be used .

An SXI request has been logged to have a stripHTML rule developed.

#71 HOWTOS » Subtracting Dates » 22-11-2018 07:44:50

SeanR
Replies: 3

Date Subtraction

<sxi:DataDefinition name="CalculateTotalTimeOnsite">
  <sxi:Fields>
	<!-- Convert the Date to Epoch -->
	<sxi:Field name="ActualWorkStartDate">
	  <sxi:Rules>
		<sxi:DateToEpoch InputDateFormat="yyyy-MM-dd HH:mm"/>
	  </sxi:Rules>
	  <sxi:OutputField>EpochActualWorkStartDate</sxi:OutputField>
	</sxi:Field>
	<!-- Convert the Date to Epoch -->
	<sxi:Field name="FinalDateTime">
	  <sxi:Rules>
		<sxi:DateToEpoch InputDateFormat="yyyy-MM-dd HH:mm"/>
	  </sxi:Rules>
	  <sxi:OutputField>EpochFinalDateTime</sxi:OutputField>
	</sxi:Field>
	<!-- Subtract the Epoch Final Date From Epoch Start Date to get the difference in seconds -->
	<sxi:Field name="EpochFinalDateTime">
	  <sxi:Rules>
		<sxi:Calculate>
		  <sxi:Expression operator="-">
			<sxi:Operand inputField="yes">EpochActualWorkStartDate</sxi:Operand>
		  </sxi:Expression>
		</sxi:Calculate>
	  </sxi:Rules>
	  <sxi:OutputField>EpochTotalTime</sxi:OutputField>
	</sxi:Field>
	<!-- Convert the seconds difference to minutes -->
	<sxi:Field name="EpochTotalTime">
	  <sxi:Rules>
		<sxi:Calculate>
		  <sxi:Expression operator="/">
			<sxi:Operand>60</sxi:Operand>
		  </sxi:Expression>
		</sxi:Calculate>
	  </sxi:Rules>
	  <sxi:OutputField>TimeOnsite</sxi:OutputField>
	</sxi:Field>
  </sxi:Fields>
</sxi:DataDefinition>

Credit goes to Lauren.

#72 HOWTOS » Setup Tomcat to listen on port HTTPS (443) » 22-11-2018 07:42:45

SeanR
Replies: 0

You will need to edit the conf/server.xml file in the tomcat directory.

Look for the section as seen below:

<!--<Connector port="8443" 
protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" /> -->

Uncomment that section (or copy it) and change the port to the port you wish Tomcat to listen for https traffic on.  Normally this is 443

You will need to apply a keystore.  In the following example the jks file is found in the conf directory and is called sxi_cert.jks.  The password is "password"

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" 
keystoreFile="conf/sxi_cert.jks" keystorePass="password" />

Restart Tomcat and you should be able to connect to your server using https://servername/

#73 HOWTOS » How to collect an Attribute from an XML (esp. Web Service Response) » 22-11-2018 07:40:54

SeanR
Replies: 0

OK ... so there is no simple way to do this currently.

I had to get the "status" attribute from the following xml:

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
    <ns2:processTransactionResponse xmlns:ns2="http://soap.sxi.co.za/">
      <SXIReturn status="FAILED">
        <message>Failed to create XML file.</message>
        <transID>1513606805687</transID>
      </SXIReturn>
    </ns2:processTransactionResponse>
  </S:Body>
</S:Envelope></code></pre>

however when I used the following XPath:

//*[local-name()='SXIReturn']/@status

only the word status was returned .. however it worked in Oxygen (although it did return the full attribute >status="FAILED"<

The only way I have found so far to fetch an attribute is to address it via a stylesheet using an ApplyStyleSheetToMemoryContents mapping in XLayer using a simple stylesheet that looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
    <xsl:variable name="status" select="//*[local-name()='SXIReturn'][last()]/@status"/>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates />
        </xsl:copy>
        <xsl:if test="@status">
           <xsl:apply-templates select="@status" />
       </xsl:if>
    </xsl:template>    
    <xsl:template match="@status">
        <SXIReturnStatus><xsl:value-of select="$status" /></SXIReturnStatus>
    </xsl:template>    
</xsl:stylesheet></code></pre>

This copies all the xml but ALSO create a new xml element called "SXIReturnStatus" and adds the value of the status attribute to it.

This way I can run a "MemoryDataManipulation" mapping to see if the status was SUCCESS or FAILURE using a condition as follows:

<MemoryDataManipulation dataDefinition="GetSOAPStatus">
     <Conditions>
         <Condition>
             <When field="//*[local-name()='MySoapStatus']" operator="Matches" value="FAILED">
                 <LogComment Comment="==== FAILED FAILED FAILED ====="/>
             </When>
         </Condition>
     </Conditions>
 </MemoryDataManipulation>
 

#74 HOWTOS » XLayer Condition Operators » 22-11-2018 07:37:53

SeanR
Replies: 0

XLayer allows the user to configure different procedures based on various conditions during the integration process. This is done by conditionally executing alternate mappings within the Action Node.

Often it appears if the conditional statements are not working properly - here is why:

When using either the MATCHES or DOESNOTMATCH operator the value attribute is a Regular Expression so one needs to be mindful that any REGEX metacharacters must be escaped for the operation to work as intended
   
Following on from the MATCHES or DOESNOTMATCH discussion above one needs to be careful when setting the value attribute in the condition to extract its contents from another field in memory using the ~#~ notation for example ~#~MyField~#~. This field may contain a REGEX metacharacters in which the case the operation would not behave as intended. To get around this issue you would need to apply the MD5Hash rule to both fields that are used as the operands in the condition

The eq, lt, gt and ne operations ONLY work on NUMBERS

#75 HOWTOS » Using Logstash » 22-11-2018 07:34:00

SeanR
Replies: 0

Logstash is used to write data into the Elastic Data Base from where it can be displayed using Kibana.

When configuring Logstash one needs to be mindful of the following:

The logstash log should only be run in TRACE when debugging new configuration. (Set the Logstash logging level in the logstash.yml file (..\Elk\logstash\config). Logging level property is "log.level: trace")

Ensure filters intended for a certain input type are not inadvertently run for different input type. This is done by defining a type in the input and using an "IF" with this type before applying the filter for example
       In the Input specify "type => "xpress""
       In the Filter specify "if [type] == "xpress"{.....}"

We should not write records that we will not be reporting on into Elastic. (During performance testing we noted when non significant records were being dumped into Elastic the performance was noticeably slower)

A set of Config files have been provided for SXI. (See the shared SXI_Logstash_Config folder on Google drive). All of these config files need to be placed into a folder pointed to by the -f switch. Logstash will read in all the .conf files. (It makes no difference to logstash if the config comes from one file or multiple files. Each file is really simple so this should reduce mistakes / frustration)

To configure new stuff we simply provide a extra file containing the appropriate input and a filter with match lines for any event you want to put into elastic. It might be prudent to have different files for XLayer and Docstore logs as these are produced with logback and are slightly different ie the times have milliseconds so transaction start and finish lapses will make sense.

When adding new config files you do not need to concern yourself with dropping unmatched events or adding things like the record_timestamp this is all done for you by the filter_XLayerCommon.conf config. We can add any other generic stuff to this when required. The only thing you need to ensure is that the "type" in the input matches the "if" in the filter. See XServiceBroker.conf.  This ensures that the filter is only run on the appropriate input. If this is omitted this filter will be run with all the inputs, and if the filter has numerous match lines this could be significant. You then simply add as many match lines as required.

I have also included a stdout output (currently commented) which is useful when adding additional matches to your config. It will display exactly what will go into elastic, but obviously you will need to run logstash from a command shell to see this.

Logstash can be run as a Daemon on nix platforms and a service on Windows platforms. To run from the command shell typically during development exercises run logstash.bat. Don't forget the -f switch to point to where you have saved the config files. (To get logstash to read from the beginning of a log file you need to delete the sincedb file. These have been configured to save in .../sxi/elk/sincedb/...)

Board footer

Powered by FluxBB