Saturday, June 29, 2013

Visual Studio Unit testing: URI formats are not supported

Last week I tried to execute some Unit Test in a C# Test project on Visual Studio 2010 (in relation to the daily BizTalk development work that I do).  Both options “Run Selection” and “Debug Selection” gave me the following error message "URI formats are not supported".

What was the problem?  I created the solution just in the default directory because I only needed that solution to test some regex output.   Was unaware that I was working on a network share.

How can you solve the problem? 
Normally when you add a new "Test Project" to your solution it adds the following files to a solution items folder. 






Just check the “Enable Deployment” property in the “Local.testsettings” and “TraceAndTestImpact.testsettings” under the deployment category, like the example below.

Problem solved, unit tests running fine!
Author: Sven Van den brande

Saturday, June 22, 2013

Basic scheduling on IBM Datapower

Performing scheduled actions is not the primary architectural purpose of the Datapower SOA Appliances, but sometimes it might come in handy to be able to perform a certain ‘batch’ task on a scheduled timing.

As an example we take the situation at one of our customers, where a Datapower box is used as a proxy to add a security layer to the calls going to an external party.

Part of this security layer is the addition of a secure code, that must be retrieved with a call to a security server. This code stays typically the same for a long time and is the same for all calls going through the proxy.

To avoid making a call to the security server for each call that goes through the proxy, a scheduler was created that picks up the secure code every 60 seconds and stores the code in a global Datapower variable. The normal proxy calls simply use the value of this global variable to get the secure code.

- First thing we need for a scheduler is the action that will be executed. This action is defined in a processing rule with all the necessary processing actions in it.

- The scheduling itself should be done through an xml manager. On the page of your xml manager, go to the tab ‘Scheduled Processing Policy Rule’ and simply add a new rule with your selected processing rule and the interval in seconds.

As you see, it’s a very easy but limited (only fixed seconds intervals) feature on the Datapower appliance. In a few minutes you can create a simple scheduler, which is often just what you need.

When you need a more advanced scheduling process, you should consider using cron on unix or the task scheduler on windows and send a request to the service on Datapower that you want to schedule.

Author: Tim

Wednesday, June 12, 2013

BizTalk Health Email Alerting Part 1: Active Messages

In this multipart serie of blogposts, I will try to give some examples to keep an eye on the monitoring of BizTalk, without having the need to log on to the environment. Emails will be sent to specific users about certain information.

This first part will be about notifying users of existing active messages. These are  messages which are active for a certain duration in the environment, while they should be already processed within this timeframe. Beware, when you have some long running process in your BizTalk environment, these need to be excluded in the WMI call that is being constructed later in this article.

These small scripts consist a little vbscript, using wmi classes and can be hosted in a scheduled task on the BizTalk server(s) for example. I will walk through the vbscript that we set up to perform this task:

First start is defining a number of variables. A timeout of the script itself and some elements that we’ll be using in the script. Some variables are already assigned a value. The “TimeInterval” is the time in minutes that an instance in BizTalk should be active when this informational email is being sent. The email addresses are the ‘To’ and ‘Cc’ addresses to which the emails should be sent.

Option Explicit

Wscript.TimeOut = 30

Dim TimeInterval,strEmailAdresses,strEmailAdressesCC,objWMI,objDatetime,objShell,svcInsts,svcInst,strDescription,strCommand

TimeInterval       = 30
strEmailAdresses   = "BizTalkAdministrators@yourcompany.com"
strEmailAdressesCC = ""


The following step is the initialization of the WMI classes to execute queries on the BizTalk environment. The WMI is initialized with the connectionstring to the BizTalk environment and the full CIM datetime (currect datetime) is calculated. The timeinterval (in this case 30 minutes) is deducted from the current timestamp, to get all instances which are older than 30 minutes.

Set objWMI = GetObject("winmgmts:\root\MicrosoftBizTalkServer")
Set objDatetime = CreateObject("WbemScripting.SWbemDateTime")
Set objShell = CreateObject("WScript.Shell")

objDatetime.SetVarDate DateAdd("n", -TimeInterval, Now)

Next, the query is set up and being executed. IMPORTANT! All service instances with service type id “BB3A1470-F5C4-47C3-B71F-EAABC260FBD0” are being excluded. These are CacheRefresh instances and are instances internally used in the BizTalk core.

Set svcInsts = objWMI.ExecQuery("SELECT * FROM MSBTS_ServiceInstance WHERE ServiceStatus = 2 AND ServiceTypeId <> '{BB3A1470-F5C4-47C3-B71F-EAABC260FBD0}' AND ActivationTime < '" & objDatetime.Value & "'")
When the results are loaded into svcInsts, the script will loop over every instance found and construct a description which will later be sent through email. Finally, when the full description is constructed, the ‘SendEmail function is called.

If svcInsts.Count <> 0 Then

 strDescription = "There are " & svcInsts.Count & " instance(s) active for more than " & TimeInterval & " minutes." & vbCrLf & vbCrLf

 For Each svcInst In svcInsts
   strDescription = strDescription & svcInst.ServiceName & "   " & svcInst.InstanceID & vbCrLf
 Next

 SendEmail(strDescription)

End If

Wscript.Quit


The function ‘SendEmail’ has the simple task to construct a full message which can be sent to the smtp server. The environment of the process executing the script (objEnv) is being loaded and an object is created to store the message (objMessage). As an extra, the mail is given priority “high”. The SMTP server is being read from the previously loaded environment (objEnv).


Function SendEmail (strDescription)

Dim objEnv,objMessage

Set objEnv = objShell.Environment("Process")
Set objMessage = CreateObject("CDO.Message")

objMessage.From = "thesender@yourcompany.com"
objMessage.To = strEmailAdresses
objMessage.CC = strEmailAdressesCC
objMessage.Subject = "Active Instances take too long to complete"
objMessage.Textbody = vbCrLf & strDescription & vbCrLf & "Please check the environment." & vbCrLf & vbCrLf

objMessage.Fields("urn:schemas:mailheader:Importance") = "High"
objMessage.Fields.Update

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = objEnv("BTS_SMTP_HOST")
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update

objMessage.Send

End Function

Wscript.Quit


This way of working can also be used for other elements to monitor BizTalk. In the next post, I’ll be talking about the same type of script to process and terminate automatically dehydrated instances.

Thanks for reading, if you have any remarks or questions, please leave them in the comments section!

Author: Andrew De Bruyne