Sunday, October 30, 2011

Changing BizTalk Mapper Item templates

 

To be able to configure default value for artifacts that are created from within Visual Studio we can leverage the ‘Item Template‘ functionality.

I have done this to adjust the mapping behavior , specifically the value for setting ‘GenerateDefaultFixedNodes’ which is default ‘YES’. See my previous post on this subject.

Below are the steps to follow

The ItemTemplates is a folder that contains the template files used when you create a new item.

clip_image001

The map template can be found in the folder: Map Files

This is a .zip file that contains a .BTM file. Change the value of ‘GenerateDefaultFixedNodes’ to one of the above values and save the .zip file.

clip_image002

After changing the value, the template is not working, why??? The templates are cached in the folder:

C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCached\BizTalk\Map Files

clip_image003

clip_image004

You have to register the value by entering the following command (devenv /installvstemplates):

clip_image005

Note: if you have multiple zips files, the FIRST zip file is used, i made the mistake to rename the original Map.old.zip, which still resulted in the old template to be registered.

If you create a new MAP, the template will now be used:

clip_image006

clip_image007

Note: The only supported values are: ‘Yes’ / ”” / ‘RequiredDefaults’, i recommend to use ‘RequiredDefaults’

Be sure to read this (Accommodating Schemas with Large Footprints)!

http://msdn.microsoft.com/en-us/library/aa561485(v=bts.10).aspx

“when the GenerateDefaultFixedNodes flag is set to No, the default field values set in the target schema are not preserved in the instance produced by the map. This is a problem when these values are required in the target instance”.

 

HTH,

Sander Nefs

BizTalk Mapper vs Attributes with Defaults….Schema Elements with an attribute having a default value are ALWAYS generated

 

‘Challenge’:

Schema Elements with an attribute having a default value are ALWAYS generated, this is because of the default mapping behavior.

Structure of this post:

What is the problem

Attributes with a Default Value are generated even though the element is optional. Consider this schema, which has an Data element.

image

The element ‘OptionalAttributeDefault’ is optional (minoccurs:0) and has an attribute with a Default value: ‘LINUX’

image

The element ‘RequiredAttributeDefault’ is mandatory (minoccurs:1) and has an attribute with a Default value: ‘CAT141.12’

image

The element ‘RequiredDefaultValue’ is mandatory (minoccurs:1) and has a default value: ‘Test’

image

When we execute the map which does not map the ‘Data’ element like this:

image

The XML output generated is:

<ns0:Destination xmlns:ns0="http://AttributeTest.Schema2">
    <Name>Name_0</Name>
    <ID>ID_0</ID>
    <Data>
        <OptionalAttributeDefault Type="LINUX"></OptionalAttributeDefault>
        <RequiredAttributeDefault Type="CAT141.12"></RequiredAttributeDefault>
        <RequiredDefaultValue>Test</RequiredDefaultValue>
    </Data>
</ns0:Destination>

Issue: All [DATA] elements are generated, optional elements with an attribute default as well

 

Why is this

This is because the .btm file is configured with a behavior to always generate the default values, even for optional elements.

Although we can state that the default values have to be removed, that is not always possible. I came across this issue when implementing UBL (from OASIS).

 

How to overcome this

We can overcome this be altering the behavior of the map, this can be done by opening the .BTM file and navigate to the attribute: ‘GenerateDefaultFixedNodes’, which is default “YES”.

Before making any changes, we have to understand which options there are:

  • GenerateDefaultFixedNodes=”Yes” : default behavior
  • GenerateDefaultFixedNodes=”” : this will generate no elements if the attribute has a value, even when the element is mandatory!

Note: you can set the value to whatever (no, false, etc) however when you save the map it will become “”

Example result:

<sns0:Destination xmlns:ns0="http://AttributeTest.Schema2">
  <Name>Name_0</Name>
  <ID>ID_0</ID>
</ns0:Destination>

Issue: No [DATA] element is generated

  • GenerateDefaultFixedNodes=”RequiredDefaults” : this will generate elements with minoccurs=1 in case it has attributes with a default value

Example result:

<ns0:Destination xmlns:ns0="http://AttributeTest.Schema2">
    <Name>Name_0</Name>
    <ID>ID_0</ID>
    <Data>
        <RequiredDefaultValue>Test</RequiredDefaultValue>
    </Data>
</ns0:Destination>

Issue: results are still not valid (Required elements with default attribute value are not created, thus validation fails

 

This means that even though you can configure the behavior of the mapping there is no perfect solution. You either have:

  • to modify the default values and use the default behavior
  • have to ensure that elements/attributes are set (you can not rely on any of the default attributes anymore since elements are not created)

 

Since this is quite important, I’ve created a sample project that has a map for each setting, and a readme.txt with information about the results.

In the next post I will explain how to change the ‘template’ used when creating maps.

HTH,

Sander Nefs

 

Friday, October 28, 2011

BizTalk Scripting functoid explorer (codeplex)

 

I came across this tool to extract the scripts from maps found in a folder and really like it.

Running the tool on my project BizTalk 2010, I had some errors (minor), I have posted a patch with some minor modifications.

If anyone is an Xslt Guru, please contribute because this would make it a perfect tool to generate Mapping documentation!

 

Cheers,

Sander

Wednesday, October 26, 2011

Flat File schema - The tag overlaps one or more fields that contain a fixed data value

 

I recently had to patch up a schema that was defined but had to be evaluated for re-usability.

This warning was generated:

Warning    1    Record "RecepientOrderShipDetail" - The tag overlaps one or more fields that contain a fixed data value.    \OrderShipped_FF_<System>.xsd

 

The record RecepientOrderShipDetail had a TAG identifier which was correct, however for some reason a child atrribute @RecordID has a FIXED value with the same value as the parents TAG identifier.

image

Since both the TAGS were working on the same Offset the positional ‘bandwidth’ was used by the Attribute.

To prevent this warning I removed the fixed value of the Attribute

 

Since this error is rather unclear I hope this helps in solving the problem when you run into this.

 

Regards,

Sander

Saturday, October 15, 2011

BizTalk Deployment Framework – Always provide the OutputPath!

A hard lesson I learnt….as I was fiddling around with the BizTalk Deployment Configuration, ALWAYS make sure to define a property group applicable to your configuration and be sure to set the OutputPath. I had defined several propertygroups and modified the conditions to make sure it would work on a build server (provided additional MSBuild properties), however I forgot one combination, the PropertyGroup for the ‘Release’ configuration. I had set my BTDF project to configuration ‘Release’….which led to a not so cool outcome…files were removed from C:\

This is caused by the WixTargets file (MSBUILD\Deployment Framework For BizTalk\5.0\BizTalkDeploymentFramework.WiXSetup.targets;

      <!-- Delete any existing output files -->
    <CreateItem Include="$(OutputPath)\**\*.*">
      <Output TaskParameter="Include" ItemName="OutputsToClean" />
    </CreateItem>

If the $(OutputPath) is not provided the value become “.” causing the effect.

You can overcome this (until RC2 is out) by adding the following to you targets file:

  <Target Name="Installer" DependsOnTargets="Redist">
           <Error Text="The build was aborted, no OutputPath provided"  

          Condition="'$(OutputPath)'" />

Which will stop the build;

Build FAILED.

"C:\Projects\Rfs.Integration\Dev\Rfs.Integration.Common\Rfs.Integration.Common.Deployment\Rfs.Integration.Common.Deployment.btdfproj" (Installer target) (1) ->
(NoOutputPath target) ->
  C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.WiXSetup.targets(206,3): error : The build was aborted, no OutputPath provided [C:\Projects\Rfs.Integration\Dev\Rfs.Integration.Common\Rfs.Integration.Common.Deployment\Rfs.Integration.Common.Deployment.btdfproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.23

 

Hope this prevents someone from making the same mistake. Also, make sure you make enough backups! (and keep them Bedroefde emoticon)

 

Sander

ESB Toolkit ‘DSL Itinerary error (XML Node not serializable)’

Today I received this error;

Cannot save 'C:\Projects\<SolutionFolders>\<NameOfItinerary>.itinerary': Type 'System.Xml.XmlNode' in Assembly 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

 

As stated in the Biztalk social forum ;

- Somehow one of the shapes led to a corrupted itinerary

- Remove the shapes one by one to identify the one generating the error

- Recreate the shape

- It now works…magic!

 

Also make sure that everything is properly deployed  (when using an orchestation extender) before changing the itineraries.

 

HTH,

Sander

Saturday, October 08, 2011

WCF-Oracle and Oracle Advanced Queing (AQ) – tips

If you use the WCF-Oracle adapter to communicate with Oracle Advanced Queing you are in for a treat. We followed the steps suggested in a very good MSDN post. There are however some caveats;

  • Username is case sensitive
  • The generated schemas have a reference to the package, and Database schema, make sure this is consistent throughout the environments
  • The generated schemas are slightly different then what the WCF-Oracle adapter expects in some cases (more on that below)
  • Use a count procedure to determine if there are messages

Generated the schemas is done by following the standard ‘Add Generated items’ wizard so that should not be hard to do. When you generate schemas for Oracle they will typically have the targetnamespace:

/Package/http://Microsoft.LobServices.OracleDB/2007/03/<DATABASESCHEMA>/Package/<PACKAGENAME>

Where the <DATABASESCHEMA> could be something like ‘DBOWNER’ and the packagename could be whatever.

When you implement this everything seems ok, until you start testing, receiving messages won’t work (not supported exception stating that the action is invalid;

image

This is because the WCF-Oracle adapter expects a different targetnamespace!!

See the namespace below with the subtile change from ‘Package’ to ‘PollingPackage’ ;

 

http://Microsoft.LobServices.OracleDB/2007/03/<DATABASESCHEMA>/PollingPackage/<PACKAGENAME>

  • I therefore strongly recommend to generate a separate schema for each receiving procedure (this allows you to alter the targetnamespace), as it works fine for non receiving procedures which can be generated into a single schema.

 

Another thing that will get in the way is that the generated schema is somehow now in lign with the message returned;

The message structure is pretty logical;

clip_image001

The generated items wizard however generates somewhat different;

clip_image002

  • Take this into account when receiving the message in my case I had to extract the message body out of an envelope so I used the WCF feature to extract this body out using XPath

/*[local-name()='DEQUEUE']/*[local-name()='DEQUEUEResult']

 

To be sure to only receive messages when there are messages on the queue, define a stored procedures that checks for messages.

The adapter can then be configured like this:

Property

Configuration

PolledDataAvailable Statement

SELECT <DATABASESCHEMA>.<PACKAGE>.<PROCEDURE> FROM DUAL

PollingAction

http://Microsoft.LobServices.OracleDB/2007/03/<DATABASESCHEMA>/PollingPackage/<PACKAGENAME>/<PROCEDURE>

PollingStatement

<ns0:DEQUEUE xmlns:ns0=/Package/">http://Microsoft.LobServices.OracleDB/2007/03/<DATABASESCHEMA>//Package/">Package/Package/">/<PROCEDURE> />

 

This should get you right on track!

 

Sander

Friday, October 07, 2011

New look and feel

Hi there,

Minor update on my blog, I completely changed to look and feel, hopefully it’s now more accessible.

I will try to update my blog more often!

 

Regards,

Sander