Showing posts with label BizTalk. Show all posts
Showing posts with label BizTalk. Show all posts

Tuesday, May 5, 2009

Business Rule Engine and Static .net Classes

When using static classes together with the Rule Engine you will get an error when testing the policy

Fact unrecognized.

The solution is explained in the following link, in a few words,Business Rule Engine needs an instance of a class and don’t know how to work with Static classes but by changing a parameter it can be solved.

http://geekswithblogs.net/cyoung/articles/111169.aspx


Thanks to Jean-Francois Philagor for pointing this article.

Monday, March 30, 2009

SQL Adapter – Generating a Schema

When using the Stored Procedures in SQL Server and BizTalk, we need to add the XSD to the project.  When using the Add Adpater MetaData feature of BizTalk (Add –> Add Generated Items…) BizTalk generates the schema, but the result is equal to the Success element and is of atype  AnyType.

This behavior is not the one we want as we want to use the return values.

Solution:

1. First create the Store Procedure
    ex. SELECT Id, Name FROM Countries FOR XML AUTO, XMLDATA

   Be sure to add FOR XML AUTO, XMLDATA at the end.

2. Run the Add Adapter MetaData wizard, within Visual Studio and your   
    BizTalk Project.

3. At the Statement Information screen, you need to enter valid values
    into the Value column

4. Click the Generate button

5 Finish the Wizard, you will see that now the XSD will contain the

   structured results and not anymore the AnyType element.

6.  After the XSD is generate, remove the XMLDATA clause from the
     Stored Procedure;
    ex. SELECT Id, Name FRO Countries FOR XML AUTO

Wednesday, March 11, 2009

Business Rules Engine – Conditions with Count Node

I needed to create a condition in the Business Rule Egine as follows:
If Field PDF is repeated more than 5 times, take the 5th record

So I needed in the conditions to count how many times the PDF field is repeated within the Xml file

I did the vfollowing:

1. Create a new vocabulary

2. Add New Definition
3. Select Xml Document Element or Attribute
4. Enter a Definition name, ex PDFCount
5. Browse for the Xsd file and select the Field
6. Update the XPath Field Value
    a. Add count(./  in front
    b. Add ) at the end
7. Select System.Double as Type
8. Select Perform “Get” operation
9. Enter a display name
10. Click Finish
11. Use the definition name in the Rule Conditions

Monday, February 9, 2009

Naming Conventions

The raison to write this article is because I still see many multi-nationals struggling with naming conventions within their IT department.

Naming conventions are as old as IT itself, but still many companies do not have proper naming conventions, and even worse, they use internal of external sources to create one.

What is the reason to have Naming Conventions in the first place?
The main reason to introduce naming conventions is to :

  • - to reduce the effort needed to read  and understand source code
  • - to enhance source code appearance

The most important reason is the first one, to reduce the effort needed to read and understand source code

Code must be easy and quick readable and understandable when new employees (internal of external) enters the IT department or when other teams takes over the project..

The answer I gave to my customers is very easy: take the naming conventions found on the Internet.  The goal is not only to have company related Naming conventions, but general naming conventions.

New employees or external consultancy will loose less time understanding the general naming conventions, as they were used too with their previous work, instead of learning the company related ones, which will never be followed 100%.

Some links:

BizTalk: http://wes.fehler.ca/weblog/biztalk/2005/01/biztalk-naming-conventions.html

General Naming Conventions: http://msdn.microsoft.com/en-us/library/ms229002.aspx

And many more are available on the net. 

 

Don’t let your IT department loose time to write company related naming conventions, re-use them!

Wednesday, August 20, 2008

Schema Validation at Port level

Situation:
When receiving a message at the Receive Port (Location). BizTalk isn't really validating the incoming Xml against th Xsd.

What is happening is that BizTalk looks at the NameSpace + Root Element, place it in the MessageBox and the Orchestrations will pick it up.

But in meany cases, we want to validate the incoming Xml and be sure that the Xml corrspond to the Xsd

Solution:
- On the receive port, select the XmlReceive Pipeline



- Click on th Properties of the XmlReceive Pipeline
- Set ValidateDocument to true
- Fill in the DocumentSpecNames property



How to find the DocumentSpecNames Value ?

- In the BizTalk Admin Console, go to the BizTalk Application
- Click on the Schemas
- Got to the properties of the Schema you want to Validate
- Concatenate the value of Name and Assembly, using a comma

[Name Value],[Assembly Value]



When using this method, the incoming Xml file will be validated against the given schema. When an error occured in th validation, an error will be written to the eventlog.

Thursday, July 24, 2008

btsharepointadapterws.asmx - Server Error - No Access

Situation:
After installing the BizTalk Adapter on a SharePoint (SPA1) Server, I wanted to have access to the btsharepointadapterws.asmx webservice via internet explorer.

Problem:
I receive a Server error, with no extra information.
Even if I played by changing the CustomErrors tag in the web.config, I didn’t receive any extra information.




Solution:
Open the file
C:\Program Files\Microsoft BizTalk Server 2006\Business Activity Services\BTSharePointV3AdapterWS\web.config

Under System.Web -> WebServices - >Protocols you will see

Put this line as comment and save the file.



No you will have access to the webservice.

Tuesday, July 8, 2008

Stored Procedures parameters and empty nodes.

Situation:
An Xml file contains data and needs to be uploaded to a DB2 database (Or other database).
The xsd tells us that one of the field’s isn’t mandatory.



A stored procedure who accepts some IN parameters.




A mapping that converts the data from the xml file to the stored procedure schema.



Problem:
When you use the mapping above, and the name isn’t available in the Import Xml (minoccures = 0), and phone is available, then the stored procedure will throw an error.
The raison is as in the Import Xml file, the mapping can’t find a Name node, the CustomerName node will not be created. This means in our example that we only send 2 parameters instead of 3, and the stored procedure will not find the CustomerName input parameter/

Solution:

Add to the mapping the ‘Value Mapping’, set the first parameter to true, the second the node you want to copy.
This way, every node in the Xml will be created, even if you send a null value.

List of supported macros

%datetime%: Coordinated Universal Time (UTC) date time in the format YYYY-MM-DDThhmmss (for example, 1997-07-12T103508).

%datetime_bts2000%: UTC date time in the format YYYYMMDDhhmmsss, where sss means seconds and milliseconds (for example, 199707121035234 means 1997/07/12, 10:35:23 and 400 milliseconds).

%datetime.tz%: Local date time plus time zone from GMT in the format YYYY-MM-DDThhmmssTZD, (for example, 1997-07-12T103508+800).

%DestinationParty%: Name of the destination party. The value comes from the message context property BTS.DestinationParty.

%DestinationPartyQualifier%: Qualifier of the destination party. The value comes from the message context property BTS.DestinationPartyQualifier.

%MessageID%: Globally unique identifier (GUID) of the message in BizTalk Server. The value comes directly from the message context property BTS.MessageID.

%SourceFileName%: Name of the file from where the File adapter read the message. The file name includes the extension and excludes the file path, for example, Sample.xml. When substituting this property, the File adapter extracts the file name from the absolute file path stored in the FILE.ReceivedFileName context property. If the context property does not have a value, for example, if a message was received on an adapter other than the File adapter, the macro will not be substituted and will remain in the file name as is (for example, C:\Drop\%SourceFileName%).

%SourceParty%: Name of the source party from which the File adapter received the message.

%SourcePartyQualifier%: Qualifier of the source party from which the File adapter received the message.

%time%: UTC time in the format hhmmss.

%time.tz%: Local time plus time zone from GMT in the format hhmmssTZD (for example, 124525+530).

Friday, May 30, 2008

File transport does not have read/write privileges for receive location

Situation:When creating a File Locations, linked to a share directory, i always received the following 2 errors:
The errors are telling that the "File transport does not have read/write privileges for receive location..."

The Host Instance User has modify permissions on the shared folder.


and



Solution
You need to
Delete Subfolders and Files attribute is not set when the Modify property is set, you need to add the FILE_DELETE_CHILD "Delete Subfolders and Files" Attribute

Wednesday, April 16, 2008

Error: ...The failure may be cuased by the fact that under the default settings SQL Server does not allow remote connections

Situation:
While deploying my BizTalk Project i received the following error



Solution:
- Open the Properties of the project,
- Under Configuration properties, select Deployment
- Check if the server is correct

Friday, April 4, 2008

Replace " (double quotes) from Field Elements with Xslt

Situation:
I receive a CSV file, all string values are surrounded by " (double quotes).
This is normal for a CSV file, to use with Excel. But when I need the values of these fields in my Xml to send to SharePoint, you can understand that I don't want to have those double quotes in the fields.

Problem:
I didn't find in my map a functiod to Replace those double quotes

Solution:
I created a map with a Custom Xlst, and used the function Translate for each field



I added this map to the receive port. Once the Xml file arrives in my Orchestration,the double quotes are gone.

Friday, March 7, 2008

Documentate BizTalk Applications

This will be a short blog message, to documentate your BizTalk Applications download UK SDC BizTalk 2006 Documenter

UK SDC BizTalk 2006 Documenter
Creates compiled help files for a given BTS 2006 installation. This tool can be run on an ad-hoc basis using the UI or from the command line as a post build/deploy task to create a compiled help file describing a BTS 2006 installation. It will compile: BTS Host configuration, Send/Receive port configuration, Orchestration diagrams, Schema and Map content, Pipeline process flow, Adapter configuration, Rule engine vocabularies and policies, More… and publish them as compiled help files. Optionally you can embed custom HTML content and custom descriptions for all BTS artifacts to produce a more customized look and feel to the CHM output.

Download link: http://code.msdn.microsoft.com/BTS2006Scripts/Release/ProjectReleases.aspx?ReleaseId=237

Wednesday, March 5, 2008

Determine the Version of BizTalk Installed

Situation:
Check the version on Test, Validation and Production Server.

Solution:
Open regedit and got to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BizTalk Server\3.0\

You will find the information you need and compare with the other systems.

Monday, February 4, 2008

Receiveing a File from a File or Ftp Adapter

Situation:
I have an orchestration, receiving an XML-file from via the File Adapter. I need the filename to store in a database.
When placing the project in the production environment, we decided to use the FTP adapter instead of the File Adapter.
With BizTalk, It should be easy to change the receive ports.

Problem
I used in my orchestration line of codes like ReceiveXmlMessage(FILE.ReceivedFileName), but when changing the File Adapter to FTP adapter in the BizTalk Administration Console, something went wrong.

Solution
- Create a variable: fileName in your Orchestration
- Add an Expression Shape to you Orchestration
- Add the following Code into the expression shape:

tempString = "UNKNOWN";
if(FILE.ReceivedFileName exists ReceiveXmlMessage)
{
fileName =ReceiveXmlMessage(FILE.ReceivedFileName);
}
else if(FTP.ReceivedFileName exists ReceiveXmlMessage)
{
fileName =ReceiveXmlMessage(FTP.ReceivedFileName);
}

Not working Solutions:
I thought the following code would work, but I received an error saying that ReceiveXmlMessage(FTP.ReceivedFileName) was empty while using the File Adapter.

Not working code:
fileName = ReceiveXmlMessage(FILE.ReceivedFileName) + ReceiveXmlMessage(FTP.ReceivedFileName)