terça-feira, 12 de agosto de 2014

webMethods Creating a business process with a task for approval Part 3 Create a database structure to hold the PurchaseOrder

We will want to display the purchase order content to our manager to approve it. There are two ways to do this:

 - You can pass the document in between activities in the BPM flow, but I really don't recommend this approach, it creates a big load on BPM engine and it only supports a small amount of MBs, depending on you're system, you might try to crash the system by generating a 10MB or more PurchaseOrder and try to feed it to activities in the process, normally a PurchaseOrder shouldn't be this big but there are allot of document that include pictures and can get quite big. Bottom line is store you're PurchaseOrder (or whatever input document is there) to a database.

- Second approach is store the document in a database, we are using standard relational database, you could use a non SQL database but this is a PurchaseOrder and probably in real world applications you might want to query it in relation to multiple other tables from other system and relational databases are really much more flexible in terms of queries.

1. We are going for second option the first thing is to generate the relational model, from our document/xml (check the XMLSpy tabular form). We can see that there are two one to many relations from the PurchaseOrder with Items and Address elements. This will have an external key to the PurchaseOrderNumber that will be a primary key in a top relational table PurchaseOrder.


The relational model diagram using MS SQL Server 2008 and SQL Management Studio could be modelled like bellow. Note that an extra field was added to the PurchaseOrder table, Approved, this will be the field to be changed on manager approval, by default this field will be set to No. 


2. To generate this model first create a database in MS SQL, this is just for the demo so we are leaving the default values.


Note on the top comments of each section.



3.  Once the database structure has been created we can now proceed to develop the adapters to insert the PurchaseOrder document in the database once it has been received by the exposed web service and before it is published to the broker.


The folder structure of the package has been changed to receive the adapters, we are using standard wM adapters to insert values in the table, this kind of a trivial process so it is being skipped.

4. Once the adapters have been created generate a service Demo_POApprovalProcess.services.db:createPurchaseOrder that will be responsible for inserting a full PurchaseOrder to the database. Note that the transaction is implicit as the JDBC connector is set LOCAL_TRANSACTION.




5. Change the service Demo_POApprovalProcess.services:publishPurchaseOrder created in Part 1 to include the previous service just before the document is published.


6. Use SOAP UI to call of the WS (as shown in Part 1) and check that the fields are inserted in the database.




Now that there is a database structure to work with we can start using the task engine and the some CAF to display a the data for the manager to approve. 





quarta-feira, 6 de agosto de 2014

webMethods Creating a business process with a task for approval Part 2 Create a Dummy Process to triggered by the PurchaseOrder submission

 On this second part of webMethods BPM/Task Engine tutorial we are going to invoke the previously created web service to start a Process in webMethods with a simple Dummy task this will enable to progressively increment the level of complexity. Note that we are not going to explore BPM governance nor problem resolution this a tutorial for beginners that now they're way on IS but don't have experience on BPM.

1. Start by creating a new Process in Designer. If you don't have the Process view available in the top shortcut tabs hit the left most icon and look for Process Development.



Now you can select that view and on the left pane create a new Process Project by right clicking the Processes folder and clicking the new Process Project. Name you're process whatever you want but in real life it should have a designation related with the business unit the children processes will be related to.


After this the newly created Process Project folder can be used to create our process by second mouse button on it. This is a key component in process development organization, Processes Projects are our packages for Processes. 

The final structure should look something like this.




 2. Create a new process definition. If this is the first time you are creating a Process you might want to change from Business Analyst (blue) perspective to Process Developer (purple) otherwise you won't have access to the Implementation tab in the activities Properties tab.


Using the palette create a Process, I am using a pool with two lanes one will be for system and the second one for the Manager (at this time we are still not creating user tasks but this will be later assigned to a fictitious user). Also drag a start and end activity as well as an abstract class (that we are renaming to dummy at this time we just want to check the process has started and that we can monitor it on MWS).

The screen before is quite explicitly on the process design.

3. Enable the subscription of documents from the broker. To do this go to the Implementation tab and set Receive Protocol  for Subscription(For Broker Documents), this will enable that any document type specified on the Receive Document parameter, whenever is published to the broker, it will immediately  start a new process instance (of course there are filters that can be applied to fields on the received document).



4. Finally we need to build and upload the process, just click the icon on the picture bellow and everything is ok the process will be deployed to IS and also be visible on MWS.


This is how the Build Report should look.


5.Check that the process is upload in MWS and IS.

In the IS the BPM engine will generate a package. With a trigger for the transaction and one for the PurchaseOrder broker subscription. Yeap wM does all this background work to enable the BPM feature wMPRT is one of the packages responsible for this, this is a strong reload candidate whenever there is some anomalous BPM functionality.


On MWS when navigating to Administration > Business Processes the uploaded process should be available here, make sure the Execution is enabled. 


If you are new to BPM I strongly advise to play around and create more complex processes, try to drag a service from the IS and see what happens, add more tasks and check how the IS package was changed.

6. Finally lets test if everything is working correctly. Using the same procedure as explained in part 1 run the SOAP UI (or other interface to call the WS). If things are working correctly you should be able to navigate (in MWS with Administrator account) to Monitoring > Business > Process Instances  and see a BP instance available, you might have to hit search.



If you click detail you should an extensive page that will resume the process execution status.


Well folks that's it for this part.











quinta-feira, 24 de julho de 2014

webMethods Creating a business process with a task for approval Part 1 expose a web service for a Purchase Order

This is a tutorial on how to create a simple process in webMethods BPM editor. The process will be triggered using the IS as the backend which will publish a document with some new purchase order information.

1. Create a new package: Demo_POApprovalProcess




2. Add the following folder structure including the root folder with the name of the package to avoid namespace conflits.


3. Create a PurchaseOrder document under the folder docs. This is done using the microsft sample available at http://msdn.microsoft.com/en-us/library/bb387012.aspx



4. Set the document as publishable and push it to the broker to synch.


5. Create a service definition (under services) to publish the document to the broker. This service has just the PurchaseOrder document as an input and the a result string for sucess/error feedback. The document is the input of the publish wM service.


6. Now that the service is created the only thing missing is generating the WSDL. We will need to create an alias, but first lets generate a keystore and a key for enhanced security (I really don't like when security is set a side even for tutorial purposes).

  • To generate a keystore java provides the keytool available in any jdk and this includes the one wM uses. Just run the following command and it will generate a keystore with one key included.

C:\SoftwareAG\jvm\jvm170_64\bin>keytool -keystore demokeystore -genkey -alias demoks



You will be prompted for organizational details this would be useful to generate a CA for tutorial purpose this info can be inserted randomly. This will generate a keystore on the bin folder with the name demokeystore.

7. Now that the keystore has been generated we can had it to the Integration Server. Navigate to Security > Keystore > Create Keystore Alias. Insert the password chosen that was used to generate the keystore.

8. Generate a Web Service Provider Endpoint. Navigate to Settings > Web Services and create a new server alias for HTTP. In this case it was named wMlocalhost. Use the ip of the machine you have where the IS is running and a valid port. Include the previous created keystore and key in the WS definitions. The other fields can be left with default definitions.


9. The WSDL can now be generated in the Designer. Just choose the previously created End Point alias, the other setting can be left with default values.



 10. We will test the call of the web service using SOAP UI. Create a new project and had the WSDL address to initial WSDL.



11. Test the WS call using the following SOAP message. Use an account with sufficient privileges for the HTTP authentication security. The expected result is displayed bellow.










quarta-feira, 23 de julho de 2014

SFG PGP/GPG File Security Step-By-Step (includes layer creation for SFG)

PGP is a security technology that encrypts the files before being transferred through the web. This provides an extra layer of safety even if the files is captured it will still be unreadable without decryption. The producer partner has a private and public key, the public key is provided to consumer partner that uses it to decipher the files.


1. To use PGP with SFG it requires the deployment of local PGP server solution. The open source solution being used is the GPG4Win available at http://gpg4win.org/download.html


2. Install the file using the executable downloaded previously, make sure that Kleopatra and GpgEX are deployed.

3. To use GPG it will require the creation of an extra layer as it is not supported by SFG natively (the supported native solutions are displayed in yellow). Before deploying the new layer to Sterling let’s make sure everything is working on GPG side, once that is complete we can build a BP to test the GPG functionality within SFG and finally deploy the layer and create a Routing Channel to test its functionality. We will only explore the common GPG signing capabilities (that ensure the file was modified by a user) and encryption (that actually obscures the file content). Further can be achieved like compression or more advanced encryption.

4. To get started with GPG first we need to have a certificate deployed in Kleopatra, for this purpose we will generate a self signed OpenPGP certificate. You can leave Advanced settings with default values (it includes encryption and signing options already). On the last step when prompted for a Passphrase we will be using passphrase this is required for each encryption/decryption and other operations.



5. To test the encryption of a file (which will be associated with a consumer at SFG deploy time) we have created a test folder under the c drive and a simple txt test file. The first objective is to encrypt and sign the document and store in the same folder. We have run the following command:

  • echo passphrase|gpg --armor --recipient TestCertificate --batch --yes --passphrase-fd 0 --encrypt --sign test.txt
  • We test GPG4Win is well installed by just running gpg on the cmd
  • After running the command making a dir over the directory and we can find a test.txt.asc file



Test.txt.asc file content:
-----BEGIN PGP MESSAGE-----
Version: GnuPG v2.0.22 (MingW32)

hQEMAwPWle2/P5FNAQgAlSc4OoGNVm0nf7kjgNIxd4ElDzopIvLxrPuh8jXcJYrM
UpaCa119QA0mWpWZ66qv/NXLdvpzsCSktQCBAOWpD/LyAPQ6Cr9ae+EsxGYETJfQ
vNUoV7vOo591qxbHgQ9wpEnSQx8oeTuEXNBxGeyt4QZcGde+VOwQ/T09ou9TGH6d
Op4fCme1VIN6FuIAaKGd/jNbuT0banxFE0iWau6hoBy5urEQWRVexgcTOVcBl5fq
CWY4y6rTFA10YXQRFWXVXZvYgzGiNZpjkMk0qWUgx9QAzkhbrv9dKtXg3+FEeqac
ytbQaiedc9XPaPC7vMh3mw9OK9YdoEa7MRwndON/qdLAzAERNquESfx55E/sDh4Z
RACB7Wwf5wnmKaDwnehdhBeWJVgixpUsDxL5L29P3vUGA/YR4FmgXhRBnqp5oGuw
mSH2r3rjgzCcSiWifZafV2PjnWHmEOAO0y+CrmwYE7DyMPbefF9QsjZ1DRa+r3zr
azEviGMm9MDumpV0bf9l0k7s8lFfGw6n2sqrQAFetX9reUkE21omM75nfUQchqC4
vllYXjOCE2qEjRC7NTgTty1kpITwqg/h5z9ZKIZL37+hD85FmpGD0lyHCfOV94NF
li7bsWt9myBEyQWlJPzJ1bsARX7t13coLtoTy7Oj8fSvHD35NGqLiFZLnOExByxy
Le5M0Fs/IfvlHLUdjEacoS4ZjEDgUSsisoGqkREqU+wkEEkpHWSJjTrS2zK9R1s5
XjQG8tApEDhPS0hacf2PxVBLgpQKVhgBTbDLgBaa74weZyUaDuDvjmA7Pl7T5kUH
k5TTxHSuTZEGstlPElVzSYHTVXXF801F2KSnU0X/sWVMfimQvHuNmHAPKHrzsA==
=2K2+
-----END PGP MESSAGE-----


6. Having concluded the encryption phase we can now advance to the actual deployment on the integrator. As a first step lets create a Business Process that achieves the same result but replaces the primary document that is inserted as a non-encrypted file into its encrypted version.

  • In order to run the command line as Administrator we need to change the service to be set to run as Administrator instead of system to do so open the IBM Sterling B2B Integrator CmdLine2Adapter at port xxxxx

  • Change the Lon On to Administrator, note that this account must be the same that creates the keys for GPG, and at the same time should have admin permissions.

  • Create a folder under c drive c:\gpg -> this will be the working directory for the gpg scripting
  • Create a GPGEncryptSign.bat (under the folder c:\gpg) with the following content (passphrase is the value of your key passphrase, it should be replaced along with certificate name):

echo passphrase|gpg --armor --output %2 --recipient TestCertificate --batch --yes --passphrase-fd 0 --encrypt --sign %1
  • Finally under Sterling create a BP with the any name (eg: GPG_Test) and with the following definition



  • Note: cmdLine we pass the Input that is the name of PrimaryDocument that CL Adapter temporarily stores in the system, Output will bring the CL stdout to ProcessData; outputName will be the name of the document in the ProcessData same as input but with .gpg extension; finally we replace the PrimaryDocument with the newly generated document.

  • With this we will have a BP to add as a layer on SFG, we receive a non-encrypted file from producer and encrypt it before we continue the routing

  • Next step is to make this BP generic so we can set the .bat file and working directory dynamically at RCT creation time.

7. Before extending the BP we should first create a service that will hold the obscured passwords of the PGP keys.
1.       
8. Use the updated BP that contemplates the newly created obscure service.



  • Also update the .bat file to receive the password dynamically
echo %3|gpg --armor --output %2 --recipient TestCertificate --batch --yes --passphrase-fd 0 --encrypt --sign %1



9. Finally we can start work in the layer API definition. There are 2 fields to be defined:

a. GPG Batch Full Path: The path to the GPG .bat file you should be able to use a different one for each GPG routing channel template

b. GPG Working Directory: The working directory not really that relevant unless the script contains any code to use the dir where it is located, Sterling can use any working dir and repeat it for many scripts.

  • You can set the value to be displayed in the drop down menu by specifying the value DisplayLabel in FgProducerFileLayerType tag. 
  • The layer deployment must be performed with extreme caution any error on the configuration, e.g. a repeated ProducerFileLayerParameterTypeKey will generate an error in the database and the deletion of the residues must be performed manually 
  • You can delete a layer, if deployed successfully by using a command like this (applies for the layers bellow):

terça-feira, 8 de abril de 2014

Sterling B2B Integrator Enveloping an EDI message Part 1 - Creating the UNB envelope

This topic follows the previous entry to DeEnvelope a message. The message to be enveloped will be again a simple CONTRL EDIFACT message for it's simplicity but the principle can be applied to any EDI enveloping. We are going through both the immediate and deferred mode.

Lets start by creating the Outbound envelope UNH at level.


The envelope type for this tutorial will be using EDIFACT standard.


This is an Outbound UNB level.



There is no base Envelope.



It's being named GENERIC_UNB_UNZ_ENVELOPE_OUTBOUND, it's a good practice to name envelopes for type and direction, if it is for particular sender/receiver pair also specify it.



Use correlation overrides so you can set values like sender/receiver at BP level, this way the envelope can be more generic. The only settings we are inserting is Syntax Identifier and version.


Lets use the control number generated in the DeEnvelope tutorial.


There is no limit settings for this envelope but it can be restricted on size or number of UNH messages.


Leaving default delimiters and including the delimiter definition segment UNA, which is place at the top of the EDI message, e.g., UNA:+.? '


No encoding on the scope of tutorial.


For each document enveloped we want a BP to process that file therefore the option Specifying a business process.


The BP will be created on part 3 of tutorial alter this setting once the BP is created.


As stated before we are creating a BP to process the enveloped messages, the other options allow deliver the message directly using SFG with the option of extract to mailbox or put the message to the file system specified directory (The following substitution tokens are supported: %y (2 digit year), %Y (4 digit year), %m (month name), %M (month as a decimal number), %d (day name), %D (day of the month as a decimal number), %H (hour in 24-hour format), %N (minutes), %S (seconds), %P (process ID), %K (document ID))  


Verify and confirm.




Finish the first part of the tutorial next part we are configuring the UNH envelope level.