Gorgo.Live.ToString()

Mariusz, Gorzoch tech Blog

BizTalk 2006R2 + Moss 2007 + InfoPath 2007 integration

with 3 comments

Today I found a task where I needed to create “error” InfoPath form on SharePoint, where this form will be created on the fly by BizTalk. On the beginning I just didn’t know where to start as I wasn’t sure if I should start by creation of InfoPath form, or maybe I should start by creating schema inside BizTalk and then base on that create InfoPath form. On the end I manage to do so, so have look here and find all necessary steps to achieve that.

1. Create your schema. This should be done on BizTalk, so go to Visual Studio and create new schema.

2. Go to InfoPath and start designing new form template based on schema you have created in visual studio

 

3. When you finish designing your template then you are publishing it to the destination form library. To do so you can use “Publish form template” wizard in InfoPath

4. Design your orchestration. This is the step where you are coming back to visual studio and creating orchestration, which in some point will emit document to SharePoint library. In my case I’ve created really simple one, where I just getting a message from message box, transforming it into destination schema (created in point 1), and…

…and here we are getting to really important point. Transforming input message into output SharePoint/InfoPath document is not only about converting input document into output. To make your document work properly you need to perform one additional step. So first, we are transforming out document to the output one, and then we need to adjust default namespace name used inside document created by BizTalk to be “ns0” instead of “ns1” (default one created by BizTalk). If you will not go for that, then you will not see promoted field on the SharePoint list. Here is some good post and solution for that (look into comments): http://seroter.wordpress.com/2007/10/25/problem-with-infopath-2007-and-sharepoint-namespace-handling/ 

To adjust namespaces you need to place new “Assign message” shape and fill it with (please notice that this block is already placed on the picture above under name “AdjustSharepointDocument”):

where,

  • WSSForm = System.Xml.XmlDocument
  • WSSNodeList = System.Xml.NodeList
  • WSSNode = System.Xml.Node
  • WSSForm_Internal <- InfoPath message created by transforming orchestration input message into our SharePoint message
  • WSSForm_ToSend <- InfoPath message which we are going to send to SharePoint site

Now, build, compile and deploy.

5. Set-up “Windows SharePoint service adapter” (WSS adapter). Go to BizTalk administration console, open your application and create new “Send port” based on “WSS adapter”

and configure it as fallow:

  • Destination Folder URL = “Name of you SharePoint library, where you published you InfoPath template”
  • FileName = “Name of the file BizTalk should use to create file name”
  • Overwrite = “Yes” (so BizTalk will overwrite file if it exists)
  • SharePoint Site URL = “URL of you SharePoint site”
  • Microsoft Office Integration = “Yes (InfoPath Form Library)
  • Templates Document Library = Destination Folder URL
  • Templates Namespace Column = “NameSpace”

When you do so, then go and bind this port to your orchestration.

If you did everything as described above then after your orchestration will get message your should get new file on SharePoint created based on the template created in point 2.

If you need Visual Studio project for that, then you can get it from here

Advertisements

Written by Mariusz Gorzoch

15 December 2009 at 11:53

Posted in BizTalk

3 Responses

Subscribe to comments with RSS.

  1. Your post has really useful information in it. I am trying to update my solutoin to use your trick to set the namespace prefix. I declared the 3 wss variables you listed on the orchestration view. I then set up the message assignment as you described. However, when I build my project I get the following error

    a non-serializable object type ‘System.Xml.XmlNodeList wssNodeList’ can only be declared within an atomic scope or service

    I tried putting the message assignment inside an atomic scope, but it won’t let me set the scope to atomic “A Non-transactional Orchestration cannot contain any other Transactions”.

    I’m not sure how you got your example to work. The link to download your project did not work, so I was not able to look at the details. Only your screen shots.

    If you can provide any other pointers, I would be extremely grateful.

    Ellen

    10 May 2011 at 22:18

    • Hi Eydeak

      “I tried putting the message assignment inside an atomic scope, but it won’t let me set the scope to atomic “A Non-transactional Orchestration cannot contain any other Transactions”.

      reason of that is that by default orchestration is working in “non-transactional” way. Go to the orchestration properties (I think you can also just click on the white area on orchestartion designer) and change “Transaction type” from none to “atomic” (in that case you will even do not need the scope)

      hope that this help and if not, then let me know and I’ll find my project for you

      Mariusz Gorzoch

      10 May 2011 at 22:37

  2. Thanks for the quick reply. Duh. That of course allows me to create the variables. Unfortunately, I’m using a correlation set inside my orchestration, so cannot set the scope to Atomic. I think I’m going to have to do something tricky. Either write a utility function where I pass in the message, use your trick for setting the namespace prefix and returning the message with the new namespace prefix. Or, I can try setting up a called orchestration which takes the message in, executes the assignment and returns the updated message.

    Nothing is ever easy 🙂

    Ellen

    10 May 2011 at 22:50


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: