This element enables users to request messages from a resource and bring them into the workflow processor. The result of a message source is always one or more messages that can be processed by some of the action types.

<MessageSource> Base Attributes

MessageSource general attributes
Attribute Definition

BatchSize

(optional)

The number of messages to pull into the workflow in a single batch.

ConfigurationName

(optional)

The name of the configuration section defined in the XML workflow configuration file. The message source will be passed the configuration XML information when it is executed by the workflow engine.

Configuration files will be loaded from any XML file found in the Workflow Portal's /service/Config/ folder. As such, every config file should have a unique root node (or multiple root-level nodes). For example, the file /service/Config/magentoConfig.xml contains the following content.

To reference this config, set the ConfigurationName to match the root node, in this case ConfigurationName=TestMagento.

<?xml version="1.0" encoding="utf-8" ?>
<TestMagento>
    <SoapUrl>http://www.myonlinestore.com/api/index/</SoapUrl>
    <SoapUser>soapUser</SoapUser>
    <SoapPassword>soapPassword</SoapPassword>
    <StoreId>1</StoreId>
    <WebsiteCode>base</WebsiteCode>
    <IncludeCustomerInfo>false</IncludeCustomerInfo>
    <WebAccount>C20000</WebAccount>
    <DefaultPriceListCode>1</DefaultPriceListCode>
    <DefaultB1TaxCode>EX</DefaultB1TaxCode>
</TestMagento>

CreateMessages

(optional) [true|false]

Specifies whether or not to create messages for this MessageSource. This can be used to disable a MessageSource without deleting it (false). Defaults to true.

DefaultFailFolder

(optional)

Specifies the default folder to use for storing messages that have failed to be processed.

Name

(optional)

The unique name assigned to the branch. This property is not serialized. Used for readability.

SaveFirst

(optional) [true|false]

Default is false. If set to true, this will save the workflow messages to the database before applying actions.

SplitterXPath

(optional)

Contains the node name of the elements we wish to retrieve from the message source. This is an optional parameter that creates multiple messages from the data returned by the message source. Typically, a splitter is used to break a large XML message into smaller transactional elements based on the specified node name. This field name may change in future versions, as it’s not actually an XPath.

SuccessFolder

(optional)

Specifies the workflow folder to use for storing successfully processed messages.

Type

(required)

Specifies the type, which will determine the behavior of the MessageSource.

Supported and planned message source types are described below:

WebMethod

(optional)

Used in message source objects such as Magento Connector or custom objects. Determines which B1WebAPI method to call. (eg: GetPendingOrders).

<MessageSource type=”Message”>

The Message message source type pulls all of the integration messages of a specific kind from the given folder for processing by the actions and branches.

Example

<MessageSource xsi:type="Message" SourceFolder="OUTGOING" ConfigurationName="MyMagento" BatchSize="5" B1ObjectType="oInvoices" DefaultFailFolder="FAILURE" SuccessFolder="SUCCESS"/>

Attributes

"Message" Type Attributes
Attribute Definition

SourceFolder

(Required)

Specifies which workflow folder to use as a filter for retrieving messages.

DefaultFailFolder

(optional)

Define in the Base MessageSource attributes, above.

SuccessFolder

(optional)

Define in the Base MessageSource attributes, above.

B1ObjectType

(optional)

This parameter indicates to only retrieve specific B1 object types from the SourceFolder.

<MessageSource type=”HTTPRequest”>

The http request type executes the specified URL and expects to receive an XML response representing an integration message(s). The results of this could then be processed by a standard action or in some cases a splitter action.

<MessageSource type=”HTTPPost”>

The http post type will “post” to a specific URL. The result of this can be processed by an action via the workflow engine.

FTP Message Sources

FTP message sources establish an FTP connection with the specified host, and download files in the configuration location and file formats.

  • <MessageSource type="FTP"> - specifies that the files to be processed may be of any file format.
  • <MessageSource type="FTPXmlFile"> - specifies that the files to be processed are XML format.
  • <MessageSource type="FTPCSVFile"> - specifies that the files to be processed are CSV format.

Example

<MessageSource type="FTP" host="ftp://myftpserver.com" username="username" password="pass" />

Attributes

FTP
Attribute Definition

AnonymousAuthentication

(optional) [true|false]

If enabled (true) then username and password are ignored. Defaults to false.

FTPServerURI

(Required)

Specifies the FTP ServerURI. May be part of a config file.

InputFolder

(Optional) The source folder for xml input files.

OutputFolder

(Optional) The folder import files are copied to.

Password

Required for authenticated FTP access. Can be omitted for AnonymousAuthentication=true. May be part of a config file.

Specifies the FTP Password.

Port

(optional) May be part of a config file.

Port used to connect to the FTP Host.

UserName

Required for authenticated FTP access. Can be omitted for AnonymousAuthentication=true. May be part of a config file.

Specifies the FTP Username.

SFTP Message Sources

SFTP message sources establish an SFTP connection with the specified host, and download files in the configuration location and file formats.

  • <MessageSource type="SFTPXmlFile"> - specifies that the files to be processed are XML format.
  • <MessageSource type="SFTPCSVFile"> - specifies that the files to be processed are CSV format.

Example

<MessageSource type="SFTPXmlFile" host="ftp://myftpserver.com" username="username" password="pass" />

Attributes

SFTP
Attribute Definition

AnonymousAuthentication

(optional) [true|false]

If enabled (true) then username and password are ignored. Defaults to false.

Host

(Required)

Specifies the FTP Host. May be part of a config file.

InputFolder

(Optional) The source folder for xml input files.

OutputFolder

(Optional) The folder import files are copied to.

Password

Required for authenticated FTP access. Can be omitted for AnonymousAuthentication=true. May be part of a config file.

Specifies the FTP Password.

Port

(optional) May be part of a config file.

Port used to connect to the FTP Host.

UserName

Required for authenticated FTP access. Can be omitted for AnonymousAuthentication=true. May be part of a config file.

Specifies the FTP Username.

Custom Message Sources

The workflow framework supports the ability to write your own custom message source objects to implement logic that is specific to your solution. The magento connector solution has implemented its own message source as shown in the example below.

Example

<MessageSource xsi:type="MagentoPendingOrders" WebMethod="GetPendingOrders" Folder="New" ConfigurationName="TestMagento" SplitterXPath="Order"/>

In this example, The class MagentoPendingOrders simply has to inherit from the MessageSource class in the Workflow framework and implement the following required methods:

  • GetMessages - This is the main processing method that will be executed when the workflow runs. It will be passed a string parameter called workflow batchID that can be used to uniquely identify any transactions taking place as part of this workflow. The workflow engine expects your class to create a WorkFlowReponse object and fill the SourceMessages property with the WorkflowMessage objects that you want to be processed.

  • ValidateMessageSource - This is a validation method that is called before any processing is completed. You can complete any required configuration checks in this section and stop the workflow from processing.

  • DebugMessageSourceTrace - This method will be called when the workflow TRACE=ON is set. Normally you would enter any debug type messages or logging in this method that would be useful for troubleshooting errors in a production environment.

  • ErrorMessageSourceTrace - This method will be called when an exception is encountered during the message source GetMessages execution. You should log the errors or handle the failures in this method.

In order to complete the configuration of your custom message source you will need to populate the CustomWorkFlowClass section of the workflow service B1WorkFlowService.config file. You will also have to make sure your custom dll is in the /bin/ directory of the service. This is an example of how that was done for Magento:

<add key="B1WebAPI.WorkFlow.MagentoConnect.MagentoPendingOrders" value="Magento.WorkFlow.Connector.dll"></add>

Sender Object

This object enables users to send messages to an external resource from the Workflow Processor. The result of a Sender object is always one or more messages that can be sent to any external resource as required. It will support most of the same types as the MessageSource object but it can be used during the workflow like an Action object (see Actions] for more details).

For example:

<Branches>
    <Branch Name="UpdateMagentoStatus">
        <Actions>
            <Action xsi:type="MagentoOrderUpdateSender" configName="TestMagento" WebMethod="" TransformXSLT="Magento_UpdateOrderStatus.xslt"/>
        </Actions>
    </Branch>
</Branches>

Message Source Configuration

Most of the message source objects that will be used with the Workflow Engine for Interconnect will require some configuration information. This information is defined in an external XML file located in the Config folder of the Workflow Service. The file MessageSourceConfig is configured during implementation and loaded by the workflow engine.

Example configuration XML for a Magento Connector

<?xml version="1.0" encoding="utf-8" ?>
<TestMagento>
<SoapUrl>http://www.myonlinestore.com/api/index/</SoapUrl>
    <SoapUser>soapUser</SoapUser>
    <SoapPassword>soapPassword</SoapPassword>
    <StoreId>1</StoreId>
    <WebsiteCode>base</WebsiteCode>
    <IncludeCustomerInfo>false</IncludeCustomerInfo>
    <WebAccount>C20000</WebAccount>
    <DefaultPriceListCode>1</DefaultPriceListCode>
    <DefaultB1TaxCode>EX</DefaultB1TaxCode>
</TestMagento>