BizTalk Map – Suppress Element if Attribute is not required.

Scenario: The following question is taken from BizTalk.General NewsGroup (altered slightly for readability purpose)

“I’m mapping an element in the source schema to an attribute in the destination schema.  The element  does not exist in the source schema, but when I run the map it creates the element in the destination schema that houses the attribute I am mapping to.  The attribute does not show up in the result of the map, just the empty element. I need to have it not create the empty element if it is not going to put a value in the attribute.”

Here is the solution:

Thanks goes to my collegue Matthew Johnstone and same technique was explained by Kiran Pabba in the newsgroup. I know for sure Matthew worked out this sample himself 🙂

Lunch with Sam

Lunch with Sam

As my new friend Sam mentioned
on his blog, we’ve been hanging out yesterday and today exploring Windows Workflow. 
Just had lunch as this excellent place – http://philadelphia.menupages.com/restaurantdetails.asp?areaid=0&restaurantid=30368&neighborhoodid=0&cuisineid=58&home=Y.

If you are in the neighborhood – let Sam know – I’m sure he’d love to take you there
to get the free-range colard greens and chicken.

If you going to Philly Code Camp tomorrow – make sure to stop by his talk – http://www.phillydotnet.org/Default.aspx?tabid=589

 

Popfly!?

Popfly!?

 


One of the things that always interests me is the number of people that are building things for the web that aren’t in the IT industry. I liken this to when I was a young kid writing games for my Vic 20. One thing we often overlook is that kids have heaps of time! At first I copied the BASIC code line by line until I had written something like Blue Meanies from Outer Space. Later I experimented and started to build things of my own.


In 1975 Microsoft originally launched BASIC for the Altair 8080. Just over 10 years later BASIC enabled me to program for the first time. I won’t be suprised if in a decades time (or sooner if current progress is anything to go by) it is tools like Popfly that my daughter picks up and uses to build something cool. For me Popfly is Microsoft going back to its roots!


I’m a passonate photographer but I don’t take photos for a living. I always felt that there was a latent need to bring such a community together which is why IMO Flickr became so popular. Before Flickr (BF) I hung out here and here.


Popfly for me is exciting because it takes everyone back to the grassroots of no code raw creation. It leverages the web as a living sea of opinions news and applications… it allows you to sculpt your solution simply by reaching into to the web and linking things up and best of all it leverages an exciting new platform to get there.


Social Networks exist… there is no doubt about that… so do virtual worlds… but isn’t it cool to think that someday everyone (not just those that understand for loops and semicolons) will be connecting data, people and events together.


I come back to the SPARK model that I talked about briefly here.



Nothing has changed from this model the only thing that is altered by giving everyone the keys to construction is that the box that sits around the outside “the user” is now able to build their own “view” and share that as their piece of the web. Yes I know there are examples of this currently from everything from customisable homepages to mash-up makers to second-life to google earth but with only having seen screencasts of Popfly in action I have a feeling that this one may be a little bit different.


Unfortunately I need to sign up for the waitlist just like everyone else and try and get myself invited into the private alpha.


Watch screen casts here and here.


Check the news here, here, here and here


Oh yeah and did anyone else notice that we brought Avenue A | Razorfish’s parent company aQuantive?


Interesting times…


Tags: Popfly, Silverlight

Retrieving original filename and archived filename from BaseEDI accelerator

From within an Orchestration, there often times occurs the need to retrieve the original filename and/or the archived filename in the %documentshome% directory. The following stored procedure can be run from within the orchestration that consumes the messages that the BaseEDI adapter sends to BizTalk. All you have to do is create the call tothe stored procedure and pass it the BTS.MessageID.

In the expression to create the call to the stored procedure looks like this:

tempXML = new System.Xml.XmlDocument();

tempXML.LoadXml(“<ns0:Request xmlns:ns0=\”http://GetArchiveFileName\”><ns0:getarchivefilename MessageID=\””+ OrderMsg(BTS.MessageID)+”\” /></ns0:Request>”);

SprocRequestMsg.Request=tempXML;

The actual stored procedure needs to be installed in the BaseEDI database:

set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

go

— =============================================

— Description: Returns the EDI file ID given the MessageID context property in Biztalk

— =============================================

CREATEPROCEDURE [dbo].[getarchivefilename]

@MessageID VARCHAR(255)

AS

SET TRANSACTION ISOLATION LEVEL READ COMMITTED

BEGIN

SET NOCOUNT ON;

SELECT icin as archive_file_name,origfilename as originalfilename

FROM audin

WHERE (ref =

(

SELECT Replace([MessageInstance/InstanceID],’-‘,”)

FROM <server name>.BiztalkDTADb.dbo.dtav_MessageFacts

WHERE ([ServiceInstance/InstanceID] =

(SELECT [ServiceInstance/InstanceID]

FROM <servername>.BiztalkDTADb.dbo.dtav_MessageFacts

WHERE ([Event/Direction] = N’Send’) AND ([MessageInstance/InstanceID] = @MessageID))) AND

( [Event/Direction] = N’Receive’)

)

)

for xml auto

END

WebCast about Windows Workflow Foundation Rules

Tomorrow, there is a free webcast by Kavita Kamani (Microsoft) about using the rules engine that is part of Windows Workflow Foundation. You can register for this event here.

Microsoft’s rules engine is a bare bones forward-chaining rules engine. The rule engine can also be invoked without using the workflow engine. When you export a business rule policy from the Rule Manager, it will generate a C# solution that illustrates how rules are invoked without the workflow engine.

Start Date: 5/18/07
Start Time: 2:00 PM (GMT-05:00) Eastern Time (US & Canada)
End Time: 3:30 PM (GMT-05:00) Eastern Time (US & Canada)

Creating Custom EDI Schemas for use in the BizTalk BaseEDI accelerator or BizTalk BaseEDI adapter

Because there are so many entrieson the web about how todevelop a schemanot included in the standard install of the BaseEDI accelerator, I would like to share how to create schemas that can be successfully imported and used.

Use http://www.disa.org/x12workbook/ts/ as implementation guide

Referring to http://msdn2.microsoft.com/en-us/library/aa559550.aspxand http://support.microsoft.com/?id=840113

1.Ensuretheheaderof the schemalooks like the following. I’ve highlighted the important values that need to be verified for each transaction. The encoding should beutf – 8.

Manually add the following data types to the schema

2. Use correct Rules subjects. The4 subject rules are the following:

Covast =EDI Implementation

All = Either

Any = One Present, Other Required

Grouped = Either Present, Other Required

One = Only one may be present

Example:

This creates the rules in the database and eif that checks for the Syntax Rules, example

Syntax Rules

At least one of DTM02, DTM03 or DTM05 is required.

If DTM04 is present, then DTM03 is required.

If either DTM05 or DTM06 is present, then the other is required.

This creates the internal rules that generate errors like in the following example:

Error encountered: ERROR (81), interchangenr 10209 :

The check condition has not been met. Contact the sender.source format: [5 00401 ,X12-4010]

source document: [812 004010DEFAULT X,CreditDebitAdjustment]

source segment: [data#4,def#4,tag=PER ,name=812_004010_DEFAULT_X_<PER]

source element: [def#3,elm#3,comp#0,name=812_004010_DEFAULT_X_<PER03>],

value: [CR]

undefined!

((812_004010_DEFAULT_X_<PER03> <> [] OR

812_004010_DEFAULT_X_<PER04> <> [] ) AND

(812_004010_DEFAULT_X_<PER05> <> [] OR

812_004010_DEFAULT_X_<PER06> <> [] ) AND

(812_004010_DEFAULT_X_<PER07> <> [] OR

812_00, (msgnr:1 segnr:4)(line:17 pos:6 filepos:761)

3. Ensure that all Subject names have “@” before the attribute name

4. Do not include an ISA, GS, or ST segments in your schema

5. All EDI elements must be XSD attributes not elements

6. Verify Schema Node Properties are correct. Highlighted properties are unique for XSD.

7. Verify Root Properties are correct. Highlighted properties are unique for each XSD.

8. Use Requirement, EDI datatype, and Maximum/Minimum Length must be explicitly declared in XSD. If you leave the Use Required as (Default) there is no attribute written to the XSD, and validation of documentswill fail, you will need to explicidly declare all elementsto be either Optional or Required. Verify by looking at actual XSD to make sure they are declared. Do not include Notes on any Attribute, Segment, or Loop.

If there are notes in the schema, what happens is that during the XSD2EDI.exe load it loads theNotes into the dbo.segcon table ‘Transaction<Notes>’instead of the ‘Transaction<segmentname>{occurrence}’, and then tries to load the non-uniquecolumn into the dbo.elmnts table, violating a primary key contraint:

xsd2edi : xsd2edi started
xsd2edi : Start parsing schema.
xsd2edi : End of parsing schema.
xsd2edi : Compare hashtotals 1QkjjiQpdJOb6SceeNzjNrQ==
xsd2edi : Start dumping definition to TEMP directory.
xsd2edi : End dumping definition to TEMP directory.
xsd2edi : Start deleting old document definition from repository.
xsd2edi : End deleting old document definition from repository.
xsd2edi : Start inserting new document definition to repository.
xsd2edi : Error in inserting document definition: Error = [Microsoft][SQL Native Client][SQL Server]Violation of PRIMARY KEY constraint ‘PK__elmnts__1A14E395’. Cannot insert duplicate key in object ‘dbo.elmnts’.
xsd2edi : End inserting new document definition to repository.
xsd2edi : (-2160) <Description for error (-2160) cannot be found. Please refer to the Trouble Shooting Guide for this description>
xsd2edi : xsd2edi finished

(who uses Notes anyway?!)

9. Date and Time attribute Properties. Advanced Base Data Type should be set to “xs:string” and General Data Type should be set to either“X12_DT (Simple Type)”or “X12_TM (Simple Type)” .

10. Covast Codelists are saved in the <install directory>\Microsoft BizTalk Server 2006\EDI\Adapter\CodeLists\EDICodelists.mdb database. Use the correct code list according to the implementation guide, an example code list is here.

11. Save the schema as <DocumentNumber>Schema.xsd.

12. Load the schema into the EDI Adapter using <install directory>\Microsoft BizTalk Server 2006\EDI\Subsystem\xsd2edi.exe “[Path to your XSD Schema]\<DocumentNumber>Schema.xsd”

13. Use <install directory>\Microsoft BizTalk Server 2006\EDI\Subsystem\compeif.exe utility to complete import.

14. Deploy the schema

If there is a problem with the XSD2EDI import process, to remove it you simply add the -r switch: <install directory>\Microsoft BizTalk Server 2006\EDI\Subsystem\xsd2edi.exe “[Path to your XSD Schema]\<DocumentNumber>Schema.xsd” -r

As a side note, if you would like to save yourself some time, you can easly contact me through my contact page and I can assist in producing a valid EDI schema.

WOW LIVE EARTH Will Be Huge!

Live Earth is a monumental music event that will bring together more than 2 billion people on 7/7/7 to raise awareness about global warming. With 24 hours of music across 7 continents, and performances by more than 150 of the world’s top musicians, Live Earth will engage, connect, and inspire individuals, corporations and governments to take action to solve the climate crisis.

The concerts will hit Sydney (I sooo sooo wish I could have said Auckland)

With bands including… Crowded House and Jack Johnson. UK has a huge lineup including Beastie Boys, Foo Fighters and the Chili’s. US has the recently reformed Smashing Pumpkins, old skool bands like the Police and Bon Jovi and new crowd pleasers like Fall Out Boy. Other venues are still to announce their bands.

This is huge! I haven’t seen anything like this since the Beastie Boys organised the Tibetan Freedom Concerts.

Now now do we get New Zealand and New Zealand music a part of this?

Looking for the 6 Best Web Site Creators in New Zealand

Natasha and the Webstock team have just launched Full Code Press.

On Friday the 6th of July the New Zealand team will be chosen.

On Saturday the 18th of August (Saturday after Tech.Ed) teams from Australia and New Zealand will spend 24 hours (yup no sleep) duking it out creating the best website for a non-profit organisation.

The “match” will be held in Australia

Friday 17/8/07
  • New Zealand team arrives in Australia

It is a bit unclear to me as to who is paying for the NZ team to travel but there is more about this in the Logistics and Sponsorship section.

If you think you have got what it takes register for the New Zealand team today!

New release of QuickCounters…

There is a new release of QuickCounters up at http://codeplex.com/quickcounters
Great new useability additions to the viewer application by Dave Comfort, as well
as fewer priviliges required against remote servers.  See here for
the quick tour…

I’ll be talking about using QuickCounters with BizTalk at tonight’s Minnesota
BizTalk User Group meeting.  (Last night, I was presenting on using Scrum
with Team Foundation Server at the Minnesota VSTS User
Group – it’s been a busy week!)