Wednesday, May 30, 2012

BizTalk 2010 - CRM 2011 Errors and Resolution

Hi,
I just thought of posting few common and few uncommon Errors :) you might face during Integrating BizTalk with CRM 2011.


<Fault xmlns="http://www.w3.org/2003/05/soap-envelope"><Code><Value>Sender</Value><Subcode><Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:    DeserializationFailed </Value></Subcode></Code><Reason><Text xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity. The InnerException message was 'There was an error deserializing the object of type Microsoft.Xrm.Sdk.Entity. The value '' cannot be parsed as the type 'Int32'.'.  Please see InnerException for more details.</Text></Reason></Fault>


Resolution: The File send to CRM has a field with wrong format. Ie the field in CRM expects a Integer Value but a string is send. Check CRM for "Whole Number" fields or Option Set fields. Even Option Set fields needs number as a int without any characters like "," or "." . Change the XSLT value script in BizTalk map to have xs:int as datatype for the Integer field.

For a Float Field in CRM = xs: double in BizTalk value mapping XSLT.

I will keep updating this Post with new Errors encountered in CRM.


Database Lookup Functoid : Multiple Where Clause : CRM PickList field

When integrating CRM I came across a Scenario while mapping a PickList field in CRM using BizTalk. Since we need to send the Index (AttributeValue) of the Value in the Xml to CRM for the PickList field I had to do a look up first to get the Picklist value Index.
Assume my Query is
Select top 1 from StringMap where Value='Staff' and AttributeName='lucky_title'
Staff comes from the Title field in the Input Xml.

Now in traditional Database Lookup Functoid we know about single where clause parameters but what if we have a multiple where clause?
Here is the StringMap table in CRM 2011


In that case what we have to do is add a String Concatenate Functoid or a Scripting Functoid for the Multiple Column and Multiple Value parameter with a separator.
I have used a Scripting Functoid.
select top 1 * from StringMap where Value + '|' +  AttributeName = Title|lucky_title






Sunday, April 15, 2012

CRM 2011 Attribute Lookup: Integrating BizTalk with CRM 2011

Hi Friends,
I have been working on a CRM 2011 Integration using WCF Adapter from BizTalk. Richard Seroter has done a very good job by posting 2 Articles on it which clears most of the basics.
Past few days I have been struggling to get this Lookup thing right. I tried the solution which Richard mentioned but seems he dint test it well...it fails.  I had also posted over msdn forum for help but nothing came up.
http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/3b08958a-cd8e-480d-9b35-eccbdfca04f8/#3b08958a-cd8e-480d-9b35-eccbdfca04f8

But this German link helped me a lot. I had to translate it to English but it was worth every penny.
http://www.msdynamics.de/viewtopic.php?f=60&t=12408

So what was the solution?
I had 2 Script functoids as shown in the map below as Richard has in the basic one first Series of CRM Integration.
http://seroter.wordpress.com/2011/02/10/the-good-bad-and-ugly-of-integrating-dynamics-crm-2011-and-biztalk-server-2010/

The C# Script in Functoid1 returns the name of the Key(Attribute Name) which is simple.

The important thing is mapping the value field where we lookup the other Entity which is shown as below

The Script is as below.


This XML works fine against CRM
LogicalName is always the name of the Entity.

So if you would like to work with CRM lookup its easy but hardly any resources online and strangely nothing from Microsoft on documentation regarding Integrating CRM 2011 with BizTalk.
I wasted good enough days banging my head to make this lookup work but its all is worth when you see it working finally.
Just mail me if you have any questions regarding Integration CRM 2011 using WCF Adapter in Biztalk.
Finally thanks Richard for post such valuable content regarding Integrating CRM 2011 using WCF BizTalk Adapter.

Hope this post helps you all!

Saturday, January 28, 2012

Bm.exe is not a valid Win32 App

Hi,
Recently I had an Issue with BAM Bm.exe. I tried to run it through command prompt got a wierd error sayign its not a Valid Win32 Application. I thought its an issue since I installed BizTalk in 32 bit mode on a 64 Bit Windows 7 machine. On googling found nothing ..seems nobody encountered it ever. Finally I thought google wont help looked at bm.exe and found the file size was 0.
Seems it got corrupted somehow. By replacing it with a new bm.exe solved the problem.







So basics do help when google fails to help you.

Saturday, November 19, 2011

Exposed Orchestration as Web service returning void?

Hi,
I was working on an Integration Scenario where we needed to call the BizTalk Orchestration from MS Access.
SO first thing started looking at how could we could send request from MS Access to Biztalk. We wanted a Synchronous Scenario where MS Access sends Request and waits for a Response.
The best option we had was to Expose the Orchestration as Webservice.
We did that and after googling we understood

  •  MS Access cannot consume a WCF Service.
  • To Comsume a BizTalk WCF Service we need to create a Proxy Class.
So finally we thought to settle down for normal SOAP Web-services and exposed our Orchestration as Soap Web-service.
It looked good but we planned to make it more easy to be called from MS Access we thought to have the Web-service Input/Output parameter as string.
So MS Access will send XML in string and get response XML i nstring object.

So we made the changes in Orchestration and republished the Orchestration as Webservice and tried to consume it from a WebService testing tool caleld WCF Strom.
The input was passed on and the Webservice returned void though in BizTalk I noticed that I am returning the right XML.



After googling I found this link where it says we need to fine tune the Webservice to work it out.

I made the changes in my Webservice created by the Webservice Publishing Wizard.

And finally got the Response as string.

Hope it helps you in working with Exposing Orchestration as Webservices.

Friday, September 16, 2011

Message as Mail Attachment?

How to send any message as a mail attachment?
  1. No need to create Multipart messages.
  2. No need to set any parameters.
Just set the Dynamic SendPort SMTP properties like.
UserName,Password,Hostname,To email address.
You can find more settings here

Important thing is using the Mime Encoder in the Send Pipeline if you want to send attachments.
It seems like I tried setting the property in Orchestration as
msgXmlDocumentOut(SMTP.MessagePartsAttachments) = 1;
It dint work.Finally I added the PipelineComponent and it worked fine. You can also set the FileName Overriding the Mime.FileName property as shown below.
public static void SetMimeFileName(Microsoft.XLANGs.BaseTypes.XLANGPart msgpart, string MimeFileName)
            {
                msgpart.SetPartProperty(typeof(MIME.FileName), MimeFileName);
            }

Saturday, September 3, 2011

Global Context Field which is independent of a Message

I was thinking of writing about a Context field which is independent of message. Imagine a Scenario where you would like to promote a field only for routing no matter what the incoming file content is, you know one thing for sure that there is a field in the content of the file(FF,XML,EDI) which has the data for routing to destination system. In this case it never makes sense to create a Schema and promote the field as Distinguished or Property field and only for routing you don’t even need to create an Orchestration.Message In….. MessageOut ….simple J
So I thought to show you how simple is it to do with BizTalk.
  1. Create a new BizTalk project and add a new Property Schema which will have our Global PropertySchema field.
  2. Let’s add a field called Property1 to this Property Schema. Set the PropertySchemaBase as MessageContextPropertybase. So by this we say that the field Property1 will not be dependent upon the message content or it won’t be linked to any field in the message. 
  3. This namespace below is important. This is the namespace in which this property field (Property1) will be promoted globally.
  4. Deploy the solution to BizTalk so our global property Schema is in BizTalk.
  5. You can promote this field from any pipeline or Orchestration as shown below. pInMsg.Context.Promote(“Property1”,"https://BizTalk_Server_Project3.PropertySchema1", "Test");
  6. If you want to access it from Orchestration then it’s important to know the .Net Namespace the property belongs to as shown below in the properties.
The Property field (Property1) can easily be accessed from the Orchestration with the .Net namespace. strProp=Msg_XmlDocumentIn(BizTalk_Server_Project3.Property1);
Simple enough…promotions are important as they can save lot of your design time to plan complex Integration's. Promotions can help you route any message from a ReceivePort to SendPort but I limit the use of such uncontrolled scenarios and use Orchestration as it gives me full control over the message for complex scenarios… ;) .