BizTalk – Publishing Message Transformation Orchestration as WCF Web Service

The following details the steps required to publish a very simple message transformation orchestration as a WCF web service via BizTalk

 

Part 1 – Project

1

1) Open Visual Studio and create an “Empty BizTalk Server Project”

 

 

2

2) Right click project in Solution Explorer and select “New item…”

 

 

3

3) Add a “Schema” file that will be used to define the request message

 

 

4

4) Define the request message schema. The schema in example has two attributes, “Amount” and “Quantity”. Define namespace.

 

 

5

5) Repeat step 2 and add another “Schema” for the response message. In this example it has one attribute called “Tax”. Define namespace.

 

 

6

6) Repeat step 2 and add a “Map”

 

 

7

7) In map the transformation is defined from a request message to a response message.

 

 

8

8) Values for the first “Mathematical Functoid”

 

 

9

9) Values for the second “Mathematical Functoid”

 

 

10

10) Right-Click map and select “Test Map”

 

 

11

11) CTRL-Click the first test map to see test request map

 

 

 

12

12) CTRL-Click the second test map to see response map with value calculate from test request map

 

 

13

13) Repeat step 2 and add an “Orchestration”

 

 

14

14) Add a “Receive Shape”,  “Transform Shape” and a “Send Shape”. Create a two messages, one for a request schema and another for the response schema.

 

 

15

15) Configure the “Transform Shape” with the map created in step 6.

 

 

16

16) Add port and give it a name.

 

 

17

17) Create a new port type and give it a name. The port must be public and a request-response pattern.

 

 

18

18) Leave at “Specify later”.

 

 

19

19) Configure messages in the “Receive Shape” and “Send Shape” from the messages created in step 14.

 

 

20

 

20) Connect the “Request” and “Response” ports to the “Receive Shape” and the “Send Shape”. Set the orchestration to public.

 

 

21

 

21) Specify the BizTalk application name otherwise it will deploy in default application on BizTalk.

 

 

22

 

22) Add a key to sign assembly. Assembly will be GAC deployed and a key file is required.

 

 

 

23

 

23) Build solution

 

 

24

 

24) Deploy solution

 

 

25

 

25) GAC deploy assembly after each build

 

Part 2 – Publish

p1

 

1) Start the “BizTalk WCF Publishing Wizard”.  In this example the “WCF-WSHttp” transport type is used. Ensure that “Enable on-premise metadata exchange” and “Create BizTalk receive locations in the following application:” has the application published in part 1 selected.

 

 

p2

2) Select “Publish BizTalk orchestrations as WCF service”.

 

 

p3

 

3) On the next page browse to the assembly created in part 1.

 

 

p4

 

4) Ensure ports are shown

 

 

 

p5

 

5) Specify namespace

 

 

p6

 

6) In this example the WCF service will allow anonymous access.

 

 

p7

 

7) If we at this stage browse to web service location we get this error.

 

 

p8

 

8) To resolve error in step 2, change the identity of the application pool used by the web service, to one with appropriate BizTalk rights.

 

 

p9

 

9) If we at this stage browse to web service location we get this error.

 

 

p10

 

10) To resolve error in step 9, configure the orchestration in the published BizTalk application.

 

 

p11

 

11) Start the BizTalk application.

 

 

p12

 

12) After these step, the web service test page should display correctly.

 

Part 3 – Testing

t1

After the orchestration is published, it is available and transformation can be tested

Move Mouse

Moves mouse one pixel every minute to prevent auto locks and screen savers

MoveMouse

Test Passwords Against Active Directory User

Tool to test password against Active Directory user. Multiple passwords can be tested by ; separating them

Usage: CheckCredentials.exe FQDN USERNAME PASSWORD1[;PASSWORD2;PASSWORD3..]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.DirectoryServices.AccountManagement;
using System.Diagnostics;

namespace CheckCredentials
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.GetUpperBound(0) == 2)
            {
                foreach (string password in args[2].Split(';'))
                {
                    using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, args[0]))
                    {

                        // validate the credentials
                        bool isValid = pc.ValidateCredentials(args[1], password);

                        if (isValid)
                        {
                            Console.WriteLine(@"{1}@{0} has password {2}", args[0], args[1], password);
                        }

                    }
                }
            }
            else
            {
                Console.WriteLine("Usage:{0} FQDN USERNAME PASSWORD1[;PASSWORD2;PASSWORD3..]", Process.GetCurrentProcess().ProcessName + ".exe");
            }
        }
    }
}

Attachment(s):

View Shaun Vermaak's profile on LinkedIn

Non-standard success exit codes

Some software distribution tools do not allow custom success exit codes. This means that if a software package returns a non-standard success exit code that the deployment status might return a failure instead of a success.

With this script an installation package’s non-standard success exit codes can be translated to exit code 0 within the software distribution tool.

Example: CScript.exe Setup.vbs /Command:SomeSetup.exe /SuccessCodes:1;2;3
In this example exit code 1,2 and 3 for SomeSetup.exe will be changed to 0

Attachment(s):

Option Explicit

On Error Resume Next

Dim strCommand
Dim strSuccessCodes

strCommand = WScript.Arguments.Named("Command")
strSuccessCodes = WScript.Arguments.Named("SuccessCodes")

If Len(Trim(strCommand)) = 0 Or Len(Trim(strSuccessCodes)) = 0 Then
    WScript.Quit(1)
End If

Dim arrSuccessCodes
Dim intSuccessCode

arrSuccessCodes = Split(strSuccessCodes,";")

Dim objShell
Dim objExec
Dim intReturnCode

Set objShell = CreateObject("WScript.Shell")

Err.Clear
Set objExec = objShell.Exec(strCommand)
If Err.Number <> 0 Then
    WScript.Echo "Problem with command"
    WScript.Quit(1)
End If

Do While objExec.Status = 0
    Call WScript.Sleep(100)
Loop

intReturnCode = objExec.ExitCode

For Each intSuccessCode In arrSuccessCodes
    If IsNumeric(intSuccessCode) Then
        If intReturnCode = CInt(intSuccessCode) Then
            WScript.Echo "Success"
            intReturnCode = 0
            Exit For
        End If
    End If
Next

Set objExec = Nothing
Set objShell = Nothing

Call WScript.Quit(intReturnCode)

CreateFileWithCode

This utility can be used to recreate any file at runtime.

It works by reading the input file with binaryreader and creates a function that can be called to recreate the input file.

Usage: CreateFileWithCode INPUTFILE > OUTPUTFILE

Attachment(s):

Private Sub CreateFile()
    Try
        Dim objBinaryWriter As System.IO.BinaryWriter
        
        objBinaryWriter = New System.IO.BinaryWriter(System.IO.File.Open("CreateFileWithCode.exe", System.IO.FileMode.Create))
        
        Dim intValue As Int32
        Dim arrValues() As Int32 = { _
        9460301, _
        3, _
        4, _
        65535, _
        184, _
        0, _
        64, _
        0, _
        0, _
        0, _
        0, _
        0, _
        0, _
        0, _
        0, _
        128, _
        247078670, _
        -855002112, _
        1275181089, _
        ...

        ...
        0 _
        }
        For Each intValue In arrValues
            objBinaryWriter.Write(intValue)
        Next
    Catch ex As Exception
        
    End Try
End Sub

Command Prompt with Random Color on Startup

Add REG_SZ to HKLM\SOFTWARE\Microsoft\Command Processor with name AutoRun and value of RndColor.bat

Create file RndColor.bat in %WINDIR%\System32

@Echo Off
Echo Loading...

SET rnd=%random%

IF %rnd% LSS 4681 GOTO 1
IF %rnd% LSS 9362 GOTO 2
IF %rnd% LSS 14043 GOTO 3
IF %rnd% LSS 18724 GOTO 4
IF %rnd% LSS 23405 GOTO 5
IF %rnd% LSS 28086 GOTO 6
IF %rnd% LSS 32767 GOTO 7

Goto END

:1
Color 1F
Goto END

:2
Color 20
Goto END

:3
Color 30
Goto END

:4
Color 4E
Goto END

:5
Color 5F
Goto END

:6
Color 80
Goto END

:7
Color 4F
Goto END

:END
CLS

ShowReplParser

This app will parse the output of “RepAdmin.exe /ShowRepl *” and display a unique list of all the servers with errors

  1. First create OUT.TXT with the following command:
  2. RepAdmin.exe /ShowRepl * > OUT.TXT
  3. Then run the following to get all errors from OUT.TXT
  4. ShowReplParser.exe OUT.TXT

Attachment(s):