Tuesday, November 9, 2010

Error when importing bindings: "Failed to update binding information."

When importing bindings into a BizTalk application, the following error message might appear:



TITLE: Import Bindings
------------------------------
Failed to update binding information. (mscorlib)
------------------------------
ADDITIONAL INFORMATION:
Cannot update send port "MoAGSendPort". (Microsoft.BizTalk.Deployment)

Cannot update transport information (address "C:\temp\SHS\ut\1.mb510i1_%SourceFileName%"). (Microsoft.BizTalk.Deployment)

The following items could not be matched up to hosts due to name and/or trust level mismatches:
Item: 'FILE' Host: 'SendHost' Trust level: 'Untrusted'
You must do one of the following:
1) Create hosts with these names and trust levels and try again
2) Re-export the MSI without the binding files and have a post import script apply a suitable binding file. (Microsoft.BizTalk.Deployment)

While the message might be correct regarding the host name or trust level, a more common reason to the failure is that the host doesn't have an adapter handler specified that matches the bindings.

In the Admin Console, browse to BizTalk Server 2009 Administration > BizTalk Group > Platform Settings > Adapters and then look at the adapter mentioned in the message. In my case it says "Item: FILE", so the File adapter is where I'm heading and it is indeed missing a send handler for the SendHost host.


To add a send handler, right-click on the adapter (or in the detail view of the window) and select New > Send Handler...


Then select the host that needed the specific send handler and click Ok.


Restart the host instance in question and then try to import the binding again.

WCF exception Could not establish trust relationship for the SSL/TLS secure channel with authority 'server:port'

I was recently working with some WCF services using the wshttp binding and therefore calling them over SSL. I had a certificate set up, but when trying to browse the wsdl in my test client, I couldn't browse the metadata. In the eventlog, I found the following error messages.

Exception Information Type[SecurityNegotiationException] Source[mscorlib] Message[Could not establish trust relationship for the SSL/TLS secure channel with authority 'server:port'.]

Exception Information Type[WebException] Source[System] Message[The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.]

Exception Information Type[AuthenticationException] Source[System] Message[The remote certificate is invalid according to the validation procedure.]

The next step was to try to browse the wsdl in Internet Explorer, where I got this:





Now it made sense. I tried to browse the service using an endpoint URL of https://localhost:11001/path when the certificate I was using was issued to the actual server name as can be seen both in Internet Explorer when checking the certificate information as well as in the MMC Certificate snap-in.



In other words, even if localhost and my servers full name can be used interchangeably in most cases, it isn't so when we are talking about security certificates where the server name is quite vital. After switching to the correct endpoint URL, in my case https://server1.domain.com:11001/path, it worked as expected.

It should be noted that there is a way of bypassing the certificate verification in the client by setting the ServerCertificateValidationCallback property as below:

using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslError)
{
return true;
};
This is however quite dangerous and should not be used in production code. A good practice if code as this is used is to wrap it in #if DEBUG statements to keep it from getting to production (but then you risk having all tests go through without any problems and have a hard to find error in the production environment that cannot be replicated in test).

Monday, November 8, 2010

WCF exception PlainXmlWriter+MaxSizeExceededException

When logging and tracing are switched on for a WCF service, the following exception might be thrown

A message was not logged.
Exception: System.InvalidOperationException: There was an error generating the XML document. ---> System.ServiceModel.Diagnostics.PlainXmlWriter+MaxSizeExceededException: Exception of type 'System.ServiceModel.Diagnostics.PlainXmlWriter+MaxSizeExceededException' was thrown.
The reason is that the maxSizeOfMessageToLog configuration parameter is set to a value that is lower than the size of the message that was trying to be logged.

<system.servicemodel>
<diagnostics>
<messagelogging logentiremessage="true" logmalformedmessages="true" logmessagesatservicelevel="true" logmessagesattransportlevel="true" maxmessagestolog="30000" maxSizeOfMessageToLog="200000">
</diagnostics>
</system.servicemodel>
And while on the subject, it can be worth checking out the MSDN recommended settings for tracing and message logging at http://msdn.microsoft.com/en-us/library/aa702726.aspx.

Friday, November 5, 2010

T-SQL Select any row, but only one per key value

A colleague of mine asked me for help with a database query. The table in question where of the normal type with an id column and several columns of data. However, the id column was not holding unique id's but the same id could be used several times, with different data for each occurrence. The task was to select only one row per id and it could be any one of the available.

My example table looked like this


The first column, t1, is holding the to-be distinct id:s. t2 and t3 is random data.

A common solution to this problem seems to be to use cursors or temporary tables. I couldn't see why it shouldn't be possible to do such a select without using them, so after some thinking, I came up with the following

SELECT t1, t2, t3
FROM (
SELECT t1, t2, t3, ROW_NUMBER() OVER (PARTITION BY t1 ORDER BY t1) rowrank
FROM Table_1
) temp_a
WHERE rowrank <= 1

Basically we select over the rows creating a ranking value for each occurrence of the id. Then we select from this data set only the rows with the rank of 1, giving us just the first occurence per id. Hence we get this output


So for every occurrence of an id in the key column t1, only one row will be selected. With modification of the inner query, a choice can be made of which one of the rows that is deemed more interesting than the others (but in this case, it didn't matter).

Friday, October 29, 2010

Find all possible parameters for an MSI package installation using msiexec

While working on a library of powershell scripts to do unattended installations of BizTalk applications (and all adjacent files and packages) I needed to find out how to specify the settings for an MSI package in order to do a complete unattended install of it using msiexec.exe.

The MSI I was working with was a setup package for a WCF service. Since this installs to the IIS, both website, virtual directory as well as application pool is needed to be specified during the installation. The question is, what are the correct parameter switches for setting these?

Simple enough, these can be found by doing an install of the MSI and logging a verbose output to file. First, run msiexec with logging enabled:

msiexec /I package.msi /L*V installationlog.txt

Then look in the logfile for the text PROPERTY CHANGE. In the following example, the virtual directory is set using the property TARGETVDIR which then also can be used as a parameter to the msiexec command to set the property from outside the GUI:

Action start 15:41:42: WEBCA_TARGETVDIR.
MSI (c) (F4:8C) [15:41:42:943]: Note: 1: 2235 2: 3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'WEBCA_TARGETVDIR'
MSI (c) (F4:8C) [15:41:42:943]: PROPERTY CHANGE: Adding TARGETVDIR property. Its value is 'MyWcfServiceLibrary'.
Action ended 15:41:42: WEBCA_TARGETVDIR. Return value 1.
MSI (c) (F4:8C) [15:41:42:943]: Doing action: WEBCA_SetTARGETSITE
Action 15:41:42: WEBCA_SetTARGETSITE.
Action start 15:41:42: WEBCA_SetTARGETSITE.

Note that the custom parameters are not to be set as normal switches with a leading slash /. In my case, the command will look like this:

msiexec /I package.msi /qb TARGETSITE="/LM/W3SVC/1" TARGET VDIR="MyWCFLibrary" TARGETAPPPOOL="BtsAppPoolC"

This will do a complete unattended install of the WCF service to IIS with basic UI and set the needed properties to my preferred values instead of the defaults.

Monday, October 25, 2010

Starting instance of host on server failed. / Could not create SSOSQL

Every now and then the BizTalk hosts won't start with the following message in the BizTalk Administration console:

Starting instance of host on server failed.
For help, click: http://go.microsoft.com/fwlink/?LinkId=47400&ProdName=Microsoft+BizTalk+Server+2009&ProdVer=3.8.368.0&EvtSrc=Microsoft.BizTalk.Administration.SnapIn.Properties.Errors&EvtID=HostInstance_UnmapServerHostInstanceFailed

ADDITIONAL INFORMATION:
Failed to start the BizTalk Host instance. Check the event log on the server "" for more details.
Internal error: "The dependency service or group failed to start." (WinMgmt)

The dependency that failed can usually be found by looking at the error message in the event log. Most likely you will find that the Enterprise Single Sign-On Service is unable to start with the following two messages:


Log Name: Application
Source: ENTSSO
Date: 2010-10-26 09:47:25
Event ID: 11047
Task Category: Enterprise Single Sign-On
Level: Error
Keywords: Classic
User: N/A
Computer:
Description:
Could not create SSOSQL. To fix the problem, reinstall SSO or try 'regasm SSOSQL.dll' from a Visual Studio command prompt.
Error Code: 0x80131700

Log Name: Application
Source: ENTSSO
Date: 2010-10-26 09:47:25
Event ID: 10503
Task Category: Enterprise Single Sign-On
Level: Error
Keywords: Classic
User: N/A
Computer:
Description:
The SSO service failed to start.
Error Code: 0x80131700

This can as the message describes most likely be fixed by registering the SSOSQL binary. What the message doesn't mention is that the version of regasm.exe that you have to run is different if you run 32 or 64 bit Windows.

For 32 bit OS:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe "C:\Program Files\Common Files\Enterprise Single Sign-On\SSOSQL.dll"

For 64 bit OS:
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\RegAsm.exe "C:\Program Files\Common Files\Enterprise Single Sign-On\SSOSQL.dll"

After registering the binary, the Enterprise SSO service can be started and subsequently also the BizTalk host instances.

Thursday, October 21, 2010

Recorded sessions from Applied Architecture Patterns now online

Today the recorded sessions from the BizTalk 2010 Release Party / Applied Architecture Patterns on the Microsoft Platform in Stockholm earlier this fall got released onto Channel9. They can be found at http://channel9.msdn.com/Tags/biztalk+user+group+sweden.

While they are all interesting, the one I'll check out first will probably be Pattern #4 – Cross Organization Supply Chain with a presentation on AppFabric caching which I feel can be an interesting implementation in many cases.

Saturday, September 25, 2010

BizTalk Server 2010 has shipped!

A few days late, but BizTalk 2010 is finally finished. The European BizTalk Conference I attended were meant to be the release party, but the product just missed the deadline. Now it's here though.

I'm mostly looking forward to the new and improved mapper but the enhanced granularity of performance settings as well as a standard SFTP adapter and integration with AppFabric is nice additions as well. Now I just hope for a project to kick off where this new version is chosen as the platform to use.

Saturday, September 11, 2010

Flat file schemas, delimeter characters, wrap characters and escape characters explained

A question on the BizTalk Professionals group on LinkedIn caused me to write a short answer, but I thought I'd do a more comprehensive take on it here.

The question was: what is the difference between wrap characters and escape characters?

When parsing a flat file schema, delimiter characters are used in order to split the incoming data into separate entities. Let's say we have the following data:

Alpha,Beta,Gamma,Delta,Epsilon

In this case, comma (,) is used as a delimeter which will enable us to split the string into the five separate words we want.

However, if it were to be a list of numbers with decimals and we use comma as the decimal separator as we do in Europe, using comma as a delimeter would be tricky since we don't know whether to split the string on the comma, or use it as a separator. In this case, we can use wrap characters.

"2,25","1,14","5,34"

In this example, the quote character (") is used as a wrap character, i.e. it wraps the separate entities. These are in turn separated with the delimiter character which is a comma (,). This will make us use the delimiter character as part of our data.

The same can be pulled off using escape characters. An escape character is placed before an otherwise reserved character in order to not parse it but to use it as part of the data. Most common is to have backslash (\) as the escape character due to it's use as such in many programming languages.

2\,25,1\,14,5\,34

The above line will give a similar result as the one with wrapped entities if backslash (\) is defined as an escape character. It escapes the following comma (,) which then will not be parsed even if it is defined as the delimiter and so it will be used as part of the data instead.

Friday, September 10, 2010

European BizTalk Conference recap

I'm back at the office after two days at Microsoft in Stockholm and the European BizTalk Conference where I enjoyed myself together with another 150 attendees. A good event as always with the BizTalk User Group Sweden and great sessions that mostly covered the platform around BizTalk for a change.

The three speakers, Richard Seroter, Stephen W. Thomas and Ewan Fairweather, are three of the five authors of the recently published book Applied architecture patterns on the Microsoft platform, which in turn caused the event to follow the basic chapter layout of the book (a book I will review as soon as I have browsed through my copy).

Day one consisted to a large extent of sessions on the different technologies that are available. SQL Server, BizTalk 2010, AppFabric, Azure and WF 4.0 were covered. Day two had sessions covering scenarios where each of the technologies were used in the solution. On this second day, StreamInsight was used in a presentation as well as the last technology presented at the conference. All sessions got taped and so videos should be up on the net within a few weeks I presume.

A very important lesson learned at the conference was a discussion on the anxiety of BizTalk developers considering all this new technology emerging. The speakers made a strong point that BizTalk is not to be replaced by AppFabric, WF 4.0, StreamInsight, SQL Server functionality and whatever there might be. All this new technology can and will instead be used as a complement to BizTalk in order to leverage functionality that previously was hard or impossible to pull off using solely the BizTalk platform. A good example of this was shown in the StreamInsight session with a vast amount of data being streamed and analyzed in realtime.

All in all, a good two days with the crème de la crème of BizTalkers in the region as well as a few from further away in the world.