I was playing with idea of using Schematron for Biztalk. It turns out that it could be very powerful tool.
Schematron xslt like language wich allows to verify xml based on xpaths. And this is something xsd can't do.
Taking insipration from brilliant article from Sarvana; I decided to write a receive pipeline component that can validate incoming xmls based on xpaths. If the incoming xml fails the tests then I don't want that to enter the system rather than failing further down the line.My requirement was very simple to check for existence of certain nodes; if they dont' exists then message is invalid.
I've created a disassembler pipeline component which reads the message and fires schematron schema validation. If validation is failed it collects all validation errors and throws exception with it. Also it does the standard xsd based validation.e.g Title of person has to match with its sex if not then not a valid message etc.
Schematron.Net is fantastic set of libraries written to exploit schematron capabilities. I used this to execute schematron schemeas on biztalk schemas.
found
this interesting and clever way of using per-instance configuration in biztalk 2006
Recently I came across an interesting mapping problem; part of my input file looked like this
<Lines>
- <ns2:Line xmlns:ns2="http://GeneralLedger.Schemas.GJFLines_Xml">
<GLCode>GLCode_0< FONT>GLCode>
<ValueDate>ValueDate_0< FONT>ValueDate>
<Currency>Currency_0< FONT>Currency>
<Amount>Amount_0< FONT>Amount>
<Reference>Reference_0< FONT>Reference>
<Description>Description_0< FONT>Description>
<InfoName>ALLOCINV< FONT>InfoName>
<InfoValue>ANALYSIS1< FONT>InfoValue>
< FONT>Info>
- <InfoName>MATTERNO< FONT>InfoName>
<InfoValue>ANALYSIS2< FONT>InfoValue>
< FONT>Info>
<InfoName>PROJECTCODE< FONT>InfoName>
<InfoValue>ANALYSIS3< FONT>InfoValue>
< FONT>Info>-
< FONT>ControlInfo>
< FONT>ns2:Line>
< FONT>Lines>
This had to be mapped to output file like following
<Lines>
<AccountCode>GLCode_0< SPAN>AccountCode>
<AnalysisCode1>ANALYSIS1(InfoValue of InfoName ALLOCINV)< SPAN>AnalysisCode1>
<AnalysisCode2>ANALYSIS2(InfoValue of InfoName MATTERNO)< SPAN>AnalysisCode2>
<AnalysisCode3>ANALYSIS3(InfoValue of InfoName PROJECTCODE)< SPAN>AnalysisCode3>
<CurrencyCode>Currency_0< SPAN>CurrencyCode>
<DebitCredit>Sign_0< SPAN>DebitCredit>
<Description>Description_0< SPAN>Description>
<TransactionAmount>Amount_0< SPAN>TransactionAmount>
<TransactionDate>ValueDate_0< SPAN>TransactionDate>
<TransactionReference>Reference_0< SPAN>TransactionReference>
< SPAN>Line>
< SPAN>Lines>
The problem here source schema has untyped information e.g ALLOCINV...
which should go in which is typed information; apparently we couldn't do this without writing custom code in c# or xslt;
But after toying around with functoids I managed to do that
The map looks like this
(Fig showing the map; if you can't see this a better picture in Gallery on my blog)
Points to go:
1. I used logical functoid EQUAL with the normal Link ; both linking to same node in output schema
so what this does is; it checks for required value e.g ALLOCINV ; if it gets match then copies to output node
2. The one more problem in this was; I had a node in source schema which had no match in output schema ;
but I needed to loop ; I used LOOP functoid and mapped its input to output node
so it loops over each “Line” till it finds match as metioned in point 1
This approach eliminates requirement of reading the XML file and parsing it manually
I found this a complex problem as there was no ready made solution available for it :)
Cheers
Vishy
Probably SQL adapter is one of the most used BizTalk adapter; its only when u use it ; u find out its limitations.One such error I came across while importing binding file to setup ports for SQL adapter
Error: Failed updating Binding information.BindingException: Could not validate TransportTypeData or Address properties for Primary Transport of Send Port 'ReceivePortName'.Exception from HRESULT: 0x80131500
After googling a bit for possible causes and resolution; I found my solution.The trick to fix this is u need to absolutely sure that from Biztalk server machine you can access SQL server
1. Check if user account running BTS Application Host has enough rights to SQL server
2. Open the binding file change the password=************** to password=yourpassword
More information at http://www.faqts.com/knowledge_base/view.phtml/aid/35313/fid/1783
3. If your running BTS or SQL or both on Virtual Machines then check for connectivity
http://www.winterdom.com/weblog/archives/000496.html; this fixed problem in my case
4. If SQL server and BTS are on different machines then it may be worthwhile to check DTC settings
set DTC to “no authentication required“; this may compromise your security though
5. Install BTS SP1
Cheers
Vishy
I've exposed quite a lot of my orchestrations as web services; while doing that I faced numerous problems sojust thought of summarizing all possible resolutions techniques here
1. SOAP Port not created
2. All properties required for correlation are not promoted; so uninstall assembly are redeploy it
3. SOAP Port created is not bound to orchestration
4. Web service is using anonymous access; remove this anonymous access; keep only windows authentication
5. User account for web service application pool doesn't have access to %temp% folder
6. User account for web service application pool is not member of IIS_WPG group
7. Client to this web service is sending credentials
8. Do iisreset once to ensure all changes are reflected
9. User account for Isolated host has enough rights to access SQL server
10. If you are using Http and SOAP adapters both then create seperate instances of isolated hosts for them
11. Changing receive location pipeline to XML receive pipeline from default passthru pipeline
12. Finally check event log for more information
Cheers
Vishy
Sometimes we need to decide runtime which orchestrations to call or just want to avoid using that extra shape of call orchestration
We can use xlang in expression shape e.g.
To call Distribution.WorkFlow_Orchestration xlang is
call Distribution.WorkFlow_Orchestration (DistributionContext, out DistributionContext);
To start Distribution.WorkFlow_Orchestration xlang is
exec Distribution.WorkFlow_Orchestration (DistributionContext, out DistributionContext);
where DistributionContext is name of input message and out DistributionContext is out message; in this case they are same
Vishy
You can't call submit direct api from an orchestration; meaning you can't send message from orchestration directly to MessageBox Database using SubmitDirect adapter APIs
The error message you'll get is
“ The Messaging Engine failed to register the adapter for \"Submit\" for ...“
Workaround?
1. Call a function written in a web service which calls submit direct APIs
2. Consider using Direct binding i.e partner ports
Vishy
Don't know whether this is trivial; but still I thought that it may
help someone
I change my projects so frequently that I can't update my setup scripts
every now and then. I've quite some files to push into GAC
so I decided to find a simpler of option of adding files to GAC
We can invoke gacutil easily on right click of dlls
Steps to be followed are
1. Open registry
2. Go to HKEY_CLASSSES_ROOT->dllfile
3. Create following hierarchy of folders(keys)
dllfile->shell->gacutil->command
4. Set default value for command to path of gacutil followed by /i "%1"
so it will look like this
D:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\gacutil.exe /i "%1"
5. close the regedit
When u reopen win explorer u'll find an option called gacutil on right
click of dll files ; clicking that will send dll to GAC
My search for uniformaty in logging led me to Microsoft's Logging application block; Like all other or most of other blocks Logging blocks packs good functionality.
In short the architecture of logging block has 2 tiers at bottom is Event Sinks and top is Formatter
Events Sinks could be of different types (e.g Database, Flat File, Email, Event Log or custom).
Formatters could be text formatter, XML formatter or custom one
When we want to use this block ;
1. Download and install the Enterprise Library from microsoft site
2. Open your solution; add reference to Microsoft.Practices.EnterpriseLibrary.Loggging.dll
3. Import namespaces Microsoft.Practices.EnterpriseLibrary.Loggging
4. Add Logger.Write() calls whereever you require logging
and it will start logging
Now if you want to ur log to go into database instead of flat file just change the config file.
Actually there's interesting application that comes with Enterprise Library which will help doing this config stuff
Although all this sounds cool; I can't find what I was expecting out of it. The block stores information in Property Name and Property Value pair
so there are certain properties that block exposes e.g MachineName, ApplicationName, Message etc. but now if you want to have ur own property you need
to change the block code and recompile it. Other than that I found it very helpful I'm looking fwd to use it more and more
Cheers
Vishy
I couldn't believe how easy it was to encrypt and sign messages using digital certificates in BizTalk
Let me summarize the steps involved in process
1. Order certificate from certificate authority like VeriSign
2. Once you get certificate; open certificates snap-in
To open go to
(Start->Run->MMC )
File-> Add New Snap in -> select Certificates for Local Computer and Current User
3. Import private key in Current User->Personal folder
4. Import public key in Local Computer-> Other People
5. Create a new send pipeline (or u can use existing custom pipeline if you've) drag Mime/SMime encode shape on Encode block
6. In Properties of Mime shape set encryption = true
7. Deploy the pipeline
8. In biztalk explorer select send port which you want to use; assign this pipeline to it; select the certificate name
and you are ready to go
9. Process of creating receive pipeline for decrypting messges is fairly simillar to this; except there is decode block in there and not encode
Cheers
Vishy
I was trying to setup HTTPRequestResponse sample from BizTalk SDK samples
2 errors that I got after setting it up are
1. error 401 not authorized
2. error 404 not found
Fixes to these are
1. Run Application pool under user who is part of BizTalk User Groups
2. Add BTSHTTPReceive.dll to Web Services Extensions in IIS; set access to 'allow'. Web Services Extensions can from configured in IIS . ASP.net uses ISAPI to communicate with biztalk we need to enable it over here. By default Windows 2003 prohibits ISAPI applications. Adding BTSHTTPReceive.dll to this list we are saying that allow ISAPI for this dll
Cheers
Vishy
There are loads of things that we can't do in expression shape (more info)
Most obvious of them are can't use If/while for message assignment
e.g if(count==1)
{
somevariable = 1;
} is invalid but
if(count ==1)
{
//dosomethingbutassignment;
} is valid ;
I was just wondering why there are these limitations on expressions? One could argue that if it supports all constructs then we can have one expression shape in orchestration and thats it. I believe that discretion should be with developers.
Cheers
Vishy
Oversimplified definition of Aggregator design pattern is; pattern which helps in combining one or more messages to create a aggreagated message. e.g if you've a system where you get n orders from a vendor in a day ; at end of day you want to combine all these orders to create a single order; you need aggregator pattern
There are lot of examples how we can do this in BizTalk using Listen shape (with one branch having delay and other receiving messages)
and once the delay timesout a new message is created with all received once. We can find more information here
The other and simpler approach could be using Append option in Send Port configuration. You can find this in send port properties-> transport->AddressURI-> Copy Mode. FileName should be unique and not with variable like %MessageID%.txt etc
So once we have this setup biztalk will append all records to same file which is your aggregated message.
Whenever we want to use this file we can simply cut this file to new location and biztalk generates a new file.
Cheers
Vishy
I must say that most of the BizTalk projects I've worked with are in EAI or B2B area; but recently I happen to work with BizTalk in totally different way.
BizTalk Orchestration Editor gives us unique opportunity to design the process first without caring for details of it. So once we have the prcoess in place blocks inside the the Orchestration represents services within the process. For example consider process of purchase order
we know that there are several steps involved in it like purchase order creation; purchase order approval; invoice creation etc in specific order.Once we've blocks ready in orchestration representing each one of steps; we know what the process is and how it works.
Now we can sofisticate this process by sofisticating the each of blocks independtly; but ensure that final outcome is as desired.
The couple of advantages of this approach is
1. Bussiness Analyst can design the orchestration with little bit of training and hand it over to developers or developers can act as BAs and create orchestrations and validate it with users. As these are visually represented users I mean non technical will not have any difficulty comprehending diagrams
2. The other advantage is the project results are visible right from first day if you like unlike traditional waterfall model of requirements, analysis, development, testing, deployment
Well I know that this approach is not suitable for all the projects in the world; but this is something which is useful for products managing processs
Let me know guys what do u think!!
Cheers
Vishy
One of the less documented features of xpath is how to run multiple
search on nodes or attributes
e.g
<Book name="Harry Potter" price="10GBP"/>
<Book name="Harry Potter" price="5USD"/>
now if you want one of them following is xpath query
.//Book[@name="Harry Potter" and @price="10GBP"]
we can use or instead of and for 'OR'ing
Cheers
Vishy