Microsoft Dynamics CRM 2011 is the latest version of Microsoft’s CRM platform. The SaaS version is already live and the on-site version will likely be released within a couple weeks. Unlike previous versions of Dynamics CRM, the 2011 release does NOT have a BizTalk-specific send adapter. The stated guidance is to use the existing SOAP endpoints through the BizTalk WCF adapter. So what is this experience like? In a word, mixed. In this post, I’ll show you what it takes to perform both “query” and “create” operations against Dynamics CRM 2011 using BizTalk Server.
Before I start, I’ll say that I really like using Dynamics CRM 2011. It’s a marked improvement over the previous version (CRM 4) and is a very simple to use application platform. I’m the architect of a project that is leveraging it and am a fan overall. It competes directly with Salesforce.com, which I also like very much, and has areas where it is better and areas where it is worse. I’ll say up front that I think the integration between Salesforce.com and BizTalk is MUCH cleaner than the integration between Dynamics CRM 2011 and BizTalk, but see if you agree with me after this post.
Integration Strategies
Right up front, you have a choice to make. Now, I’m working against a Release Candidate, so there’s a chance that things change by the formal release but I doubt it. Dynamics CRM 2011 has a diverse set of integration options (see MSDN page on Web Service integration here). They have a very nice REST interface for interacting with standard and custom entities in the system. BizTalk Server can’t talk “REST”, so that’s out. They have (I think it’s still in the RC) as ASMX endpoint for legacy clients, and that is available for BizTalk consumers. The final option is their new WCF SOAP endpoint. Microsoft made a distinct choice to build an untyped interface into their SOAP service. That is, the operations like Create or Update take in a generic Entity object. An Entity has a name and a property bag of name/value pairs that hold the record’s columns and values. If you are a building a .NET client to call Dynamics CRM 2011, you can use the rich SDK provided and generate some early bound classes which can be passed to a special proxy class (OrganizationServiceProxy) which hides the underlying translation between typed objects and the Entity object. There’s a special WCF behavior (ProxyTypesBehavior) in play there too. So for .NET WCF clients, you don’t know you’re dealing with an untyped SOAP interface. For non-.NET clients, or software that can’t leverage their SDK service proxy, you have to use the untyped interface directly.
So in real life, your choice as a BizTalk developer will have to be either (a) deal with messiness of creating and consuming untyped messages, or (b) build proxy services for BizTalk to invoke that take in typed objects and communicate to Dynamics CRM. Ideally the Microsoft team would ship a WCF behavior that I could add to the BizTalk adapter that would do this typed-to-untyped translation both inbound and outbound, but I haven’t heard any mention of anything like that.
In this post, I’ll show option A which includes dealing directly with the bare Entity message type. I’m scared. Hold me.
Referencing the Service
First off, we need to add a reference to the SOAP endpoint. Within Dynamics CRM, all the links to service endpoints can be found in the Customization menu under Developer Resources. I’ve chosen the Organization Service which has a WSDL to point to.
Within a BizTalk project in Visual Studio.NET, I added a generated item, and chose to consume a WCF service. After added the reference, I get a ton of generated artifacts.
Now in an ideal world, these schemas would be considered valid. Alas, that is not the case. When opening the schemas, I got all sorts of “end of the world” errors claiming that types couldn’t be found. Apparently there is a lot of cross-schema-referencing missing from the schemas. Wonderful. So, I had to manually add a bunch of import statements to each schema. To save someone else the pain, I’ll list out what I did:
- To OrganizationService_schemas_datacontract_org_2004_07_System_Collections_
Generic.xsd schema, I added an Import directive to OrganizationService_schemas_microsoft_com_xrm_2011_Contracts.xsd. - To OrganizationService_schemas_microsoft_com_2003_10_Serialization_Arrays.xsd schema I added an Import directive to OrganizationService_schemas_microsoft_com_2003_10_Serialization.xsd.
- To OrganizationService_schemas_microsoft_com_crm_2011_Contracts.xsd schema I added Import directives to both OrganizationService_schemas_microsoft_com_2003_10_Serialization_Arrays.xsd and OrganizationService_schemas_microsoft_com_xrm_2011_Contracts.xsd.
- To OrganizationService_schemas_microsoft_com_xrm_2011_Contracts.xsd schema, I added an Import directive to OrganizationService_schemas_microsoft_com_2003_10_Serialization_Arrays.xsd, OrganizationService_schemas_microsoft_com_xrm_2011_Metadata.xsd and OrganizationService_schemas_datacontract_org_2004_07_System_Collections_
Generic.xsd. - To OrganizationService_schemas_microsoft_com_xrm_2011_Contracts_Services.xsd schema I added Import directives to both OrganizationService_schemas_microsoft_com_2003_10_Serialization_Arrays.xsd and OrganizationService_schemas_microsoft_com_xrm_2011_Contracts.xsd.
- To OrganizationService_schemas_microsoft_com_xrm_2011_Metadata.xsd schema I added an Import directive to OrganizationService_schemas_datacontract_org_2004_07_System_Collections_
Generic.xsd and OrganizationService_schemas_microsoft_com_xrm_2011_Contracts.xsd.
Ugh. Note that even consuming their SOAP service from a custom .NET app required me to add some KnownType directives to the generated classes in order to make the service call work. So, there is some work to do on interface definitions before the final launch of the product.
UPDATE (2/17/11): The latest CRM SDK version 5.0.1 includes compliant BizTalk Server schemas that can replace the ones added by the service reference.
For my simple demo scenario, I have a single message that holds details used for both querying and creating CRM records. It holds the GUID identifier for a record in its Query node and in its Create node, it has a series of record attributes to apply to a new record.
Mapping the Query Message
Retrieving a record is pretty simple. In this case, all you need to populate is the name of the entity (e.g “contact”, “account”, “restaurant”), the record identifier, and which columns to retrieve. In my map, I’ve set the AllColumns node to true which means that everything comes back. Otherwise, I’d need some custom XSLT in a functoid to populate the Columns node.
Mapping the Create Message
The “create” message is more complicated as we need to successfully build up a set of name/value pairs. Let’s walk through the steps.
The first “page” of my map links the entity’s name and sets a few unused elements to null.
Now it gets fun. You see a node there named KeyValuePairOfstringanyType. This node is repeated for each column that I want to populate in my created Entity. I’m going to show one way to populate it; there are others. On this map page, I’ve connected each source node (related to a column) to a Looping functoid. This will allow me to create one KeyValuePairOfstringanyType for each source node.
Got that? Now I have to actually map the name and value across. Let’s break this into two parts. First, I need to get the node name into the “key” field. We can do this by dragging each source node to the “key” field, and setting the map link’s Source Links property to Copy Name. This copies the name of the node across, not the value.
So far so good. Now I need the node’s value. You might say, “Richard, that part is easy.” I’ll respond with “Nothing is easy.” No, the node’s name, KeyValuePairOfstringanyType, gives it away. I actually need to set an XSD “type” property on the “value” node itself. If I do a standard mapping and call the service, I get a serialization error because the data type of the “value” node is xsd:anyType and Dynamic CRM expects us to tell it which type the node is behaving like for the given column. Because of this, I’m using a Scripting functoid to manually define the “value” node and attach a type attribute.
My functoid uses the Inline XSLT Call Template script type and contains the following:
<xsl:template name="SetNameValue">
<xsl:param name="param1" />
<value xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:attribute name="xsi:type">
<xsl:value-of select="'xs:string'" />
</xsl:attribute>
<xsl:value-of select="$param1" />
</value>
</xsl:template>
I also built an orchestration that calls the service and spits the result to disk, but there’s not much to that. At this point, I deployed the solution.
Configuring the Send Port
Now within the BizTalk Admin Console, I imported one of the bindings that the WCF Service Consuming Wizard produced. This makes life simple since there’s virtually nothing you have to change in the BizTalk send port that this binding produces.
The WCF-Custom adapter uses a custom WCF binding.
The only thing I added was on the Credentials tab, I added my Windows credentials for calling the service. After creating the necessary receive port/location to pick up my initial file, send port to emit the service result to disk, and bound my orchestration, I was ready to go.
Executing the Query
In my Dynamics CRM environment, I added a customer account record for “Contoso”. You can see a few data points which should show up in my service result when querying this record.
After calling the “Query” operation, I can see the result of the service call. Not particularly pretty. In reality, you’d have to build some mapping between this result and a canonical schema.
As for creating the record, when I send my command message in to create a new record, I see the new (Fabrikam) record in Dynamics CRM and a file on disk with the unique identifier for the new record.
Summary
So what’s “good”? Dynamics CRM 2011 is an excellent application platform for building relationship-based solutions and has a wide range of integration options. The REST interface is great and the SOAP interface will be useful for those that can leverage the CRM SDK. What’s “bad”? I don’t like the untyped interface. I know it makes future flexibility easier (“add an attribute to an entity, don’t change the interface!”), but it really handicaps BizTalk and other tools that can’t leverage their SDK components. I can’t see that many people choosing to build these functoid heavy maps just to create key/value pairs. I’d probably opt to just use a custom XSLT stylesheet every time. What’s “ugly”? Not thrilled with the shape of the software, from an integration perspective, this close to general release. Adding a simple WCF service reference to a .NET app should work. It doesn’t. Generated BizTalk schemas should be valid XSD. They aren’t. I don’t like the required “typing” of a node that forces me to do custom XSLT, even on a simple mapping.
I suspect that we’ll either see partner solutions, or even Microsoft ones, that make the integration story from BizTalk a tad simpler. And for all I know, I’m missing something here. I’ve vetted my concerns with the Microsoft folks, and I think I’ve got the story straight, however.
Thoughts from you all? Are you a fan of untyped interfaces and willing to deal with the mapping sloppiness that ensues? Other suggestions for how to make this process easier for developers?



Mike Kolling
November 29, 1999
Hi
How about Integrating OUT OF CRM 2011 Online?
Scribe has to use Workflows to do this, is this because PLUGIN functionality is not able to pass the XML to somewhere that Biztalk can get hold of it?
Would rather not have to keep calling WCF with date range to check what has been modified in the time range.
What are the options?
Mike
Richard Seroter
February 28, 2011
Hey Mike. I actually show one option in my upcoming book that leverages plugins calling BizTalk-exposed WCF services
Sam Yates
February 11, 2011
Totally agree on the clunkiness of integration for anything other than a .NET 4-based application that can leverage the generated classes and proxy to do early binding. Even if you’re willing to deal with generic entities, communicating with the Organization service from something like Silverlight is a total nightmare right now, although MS has promised the Basic HTTP binding will be cleaned up in the RTM release. For the project I’m working on we’ve basically had to take the “wrapper” approach you describe, where we wrote our own WCF services to sit on top of the early-bound calls to CRM, and we do a fairly simplistic mapping to classes that actually expose a real data contract, to make for easy handling of data binding and such on the client side. Too bad this leaves yet another layer to maintain any time changes get made to the CRM data model.
It’s definitely a promising product for the XRM/app “building” scenario though. I’m pretty impressed with the capability there. I’d be shocked if they don’t improve the integration story in subsequent releases or add-ons.
Kent Weare
February 11, 2011
Thanks Richard…I hope this story improves before we upgrade CRM 4.0 to CRM 2011.
Walter Michel
February 11, 2011
Thanks for providing this example, Richard. A nice, real world, introduction to integrating with the latest version of Dynamics CRM. I’m kind of surprised that they are moving to a RESTful API. Is this a pattern with MS products?
Richard Seroter
February 14, 2011
Hey Walter, I think we’re definitely seeing more REST APIs available in MS products. SharePoint 2010 has such an interface as well.
Iftekhar Ahmed
February 14, 2011
I started work on a project to integrate these 2 technologies in December 2010 and came accross the same isssues. I decided to go for option (b) you mention above – I am now glad I did that.
I am a big fan of your blog. Just purchased your latest book. Keep up the excellent work.
Dharmendra Mishra
February 14, 2011
Hi,
Nice article. Thank you for post.
I would like to know few things more.
1. Whether you are using local installed version for integration or online instance.
2. How to pass user credential to wcf service if both CRM server and BizTalk are not in same domain and BizTalk user is not in same Active Directory where CRM user exists.
3. In case of accessing CRM online how you handle authentication as No place to specify CRM token to message in BizTalk.
It will be great if you could provide more detail. I need these information as i am working on integration of CRM 2011 online and BizTalk 2010. But i am stuck with Message Security Exception and unable to proceed without involving .Net code.
Some more detail regarding issue is at “http://social.msdn.microsoft.com/Forums/eu/crmonline/thread/44fb9a46-5f07-40a8-8b20-a3f3f90d070b”
Waiting for your response on same.
Richard Seroter
February 14, 2011
Hi Dharmendra,
1. Using a local (internal network) instance, not online
2. I had a big issue with this, but apparently things were corrected in the latest release candidate. I was building such examples myself, and while I got it working in straight .NET code, I couldn’t get it right from BizTalk.
3. I’ve seen some examples online of integrating with online, and suspect that a proxy service is going to be the best choice.
David Foster
February 14, 2011
Hi Richard,
I came across your blog through search.. I am an architect for an early adopter of CRM 2011 , Like you mention in the post , the product is fantastic – we are very happy with all the changes in the product especially the new REST OData API (although it is restrictive) and the integration with Azure AppFabric, Charts , custom activities and so on..
I wanted to point out that we ran into similar difficulties with RC , but i was told that they are fixed with the final release. Overall, adding a reference to the WCF service from other tools works like a charm – we use it for one of our internal integrations, You can also see examples in the SDK.. I was told that this issue is because of the way BizTalk interprets WSDL..Either way, I was given the schema files that did not have the type schema errors , You should ask your MS contact if they can give you an early copy. The schema is all static , so there should not be an issue with me posting it , let me confirm with the MS team.
There are other techniques to get early binding as well – So i do not agree with some of your conclusions.Feel free to ping me at davidfo@live.com
Richard Seroter
February 14, 2011
Thanks for the thoughts, David. I have confidence that quirks just as consuming services would be ironed out by the final release. Glad that you can provide confirmation of this.
To which other early binding techniques do you refer to? Is there another option for BizTalk consumption of the service? While I could convert early bound classes to XSD schemas for use in BizTalk (maybe), I still need to build something to convert to the base entity and back, no?
Alexander A. Krotov
February 15, 2011
Microsoft finally listened. I told them Visual Studio/WCF-style stuff Axapta won’t work with the BizTalk as of 2006 version. A very different approach. So, now they are re-writing WCF under a different labe.
Ben Cline
February 16, 2011
Well named!
I heard there are new BizTalk schemas distributed with an updated CRM 2011 SDK. I had reported the schema gen issue to Microsoft a few weeks ago so it is nice they worked the schema updates into the CRM sdk: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=420f0f05-c226-4194-b7e1-f23ceaa83b69.
Thanks,
Richard Seroter
February 16, 2011
Hey Ben. Yes, the new SDK has schemas. The README for the schemas says:
“These schema files should be used to develop Microsoft BizTalk applications that interface with Microsoft Dynamics CRM. For example, these schema files can be used with the out-of-box Microsoft BizTalk WCF adapter. Currently, these schema files are required because connecting to the Microsoft Dynamics CRM endpoints directly from within a BizTalk project does not result in the schema files for the endpoint being generated correctly.”
Ryan CrawCour
February 17, 2011
wow!
i’ve done a lot of CRM integration from BizTalk before and it’s always been a relatively simple process. i’ve never really used the adapter before, always just used WCF directly (with a custom behavior to deal with the additional MSCRM4 header). Always had access to strongly typed entities before.
seems bizarre that they’ve dropped this.
is it official that there will be no further CRM adapter? Probably cause they now want to push their OOB Dynamics connector tool.
perhaps there’s a market for someone to build a decent WCF-LOB adapter!
Jonathan
February 23, 2011
Any chance you can post this solution, im having a nightmare getting an orchestration to work.. also what did you put in the finctoid for the key pairs…. as i cant see it …
great tutorial
and thanks in advance
Jon
Richard Seroter
February 23, 2011
Hey Jonathan, thanks for reading. Somehow my XSLT script got cut off in the post, but I’ve re-added it. Hopefully that makes it clear as to how I built each output node.
Jonathan
February 23, 2011
Hi Richard
Thanks for that , it makes more sense now, i have managed to follow your tutorial, its the calling the service bit im struggling on.
when building the request, how do you know what should be entered? is it solely using the schema or is there another way (couldnt really find it in the SDK and online)
Thanks for your quick response
Richard Seroter
February 23, 2011
Jonathan, I usually cheat and look at the orchestration that gets generated by the generated service reference. In that orchestration you’ll find a series of port types which in turn point to the message types that each operation expects.
In terms of what should be there, it was a bit of trial and error. My newly announced book includes a chapter on CRM 2011 integration which hopefully clears this up further.
Jonathan
February 23, 2011
Hi Ricard, tried emailing you through the site, but not sure if your getting them?
i have been using only the schemas from the SDK.
However generating the schemas has supplied me with a blank odx file?
Any ideas?
thanks
Jonathan
Richard Seroter
February 25, 2011
The ODX will be blank it that there are no shapes on it, but if you look at the Orchestration properties window, you’ll see items under port types and message types.
Jonathan
February 23, 2011
Hi Richard
which book is this?
Many thanks
Jonathan
Richard Seroter
February 23, 2011
You can find details here (https://www.packtpub.com/microsoft-biztalk-2010-line-of-business-systems-integration/book). I’ll write more about it when it gets formally available for pre-order.
Nikolai Sklobovsky
February 24, 2011
Great article, Richard!
Helps a lot!
–
Nikolai
John Donaldson
March 2, 2011
Excellent and timely article.
I’m thinking the map will become very uncomfortable if you have a large inbound message.
Wouldn’t a custom pipeline component be a reasonable, general solution?
John D.
Richard Seroter
March 3, 2011
Hey there John. Agreed that this map will likely get unsustainable after a while. A custom pipeline would be needed on both sides (send/receive) of a send port in many cases. You need to transform the outbound content (e.g. create “account”), and in some cases, the inbound content as well (“account” returning from a query).
Mike Kolling
March 3, 2011
Richard
What is the title of your upcoming book?
Will keep an eye out for it.
Mike
Richard Seroter
March 3, 2011
Hi Mike. The book is called Microsoft BizTalk Server 2010: Line of Business Systems Integration. You can read more about it on the publisher’s web site here.
joon
March 9, 2011
Hello
Does it mean that I can directly add the schemas provided in SDK to my projects for further use instead of adding CRM schemas by Add Genrated Items?
Regards
Joon
joon
March 9, 2011
I have no clue how to use those schemas provided in the SDK tool. All look generic schemas, not for early binding.
Regards
Joon
Richard Seroter
March 9, 2011
Joon, they are only used for late binding as that’s all that works with BizTalk right now. You can directly add them to your project and don’t HAVE to do the Add Generated Items process. However, you may still want to run that wizard JUST to get the binding files.
joon
March 11, 2011
Thanks very much Richard.
What I know about CRM 4.0 WCF adapter is that they provide you a schema called “CrmService_schemas_microsoft_com_crm_2007_WebServices.xsd” where you can find out the exact entity name and its all attribute lists. You need to pass SOAP header to that message with Organiztaion name, Authentication type etc.
But it is completely different in CRM 5.0 WCF Adapter schemas. There are benefits for UnType messaging, but there are additional actions to be performed (which I assume well suited for well educated people only).
Well to be very frank, I tried to search the WCF Schemas where I can map my data into and it took me some time to find out(“organizationservice_schemas_microsoft_com_xrm_2011_contracts_services.xsd”).
Thanks a lot again for your assistance and very hard work.
David Sporer
April 15, 2011
Hi Richard,
your post was a great help. But I have one problem left:
How to set lookup values?
With the BizTalk Adapter of CRM 4.0 I’ve just inserted the ID of the related entity and it worked. Now nothing happens…
Do you know how to do this?
Thanks a lot!
Richard Seroter
April 20, 2011
Haven’t done it yet David, but it’s on the list!
David Sporer
April 21, 2011
Hi Richard,
got it!
I think it’s ugly but it is a solution that works
I’ve set the type of the referencing value-node to EntityReference and added two additional nodes (Id and LogicalName) in the Scripting Functoid.
Now the Lookup gets set.
cust_language
If you have an idea how to do this better please let me know.
David Sporer
April 21, 2011
Don’t know how to post the script here. WordPress strips my code away…
Anand Venkat
May 16, 2011
Hi David,
Could please, please send the script to pvsanand@yahoo.com
Thanks,
Anand
Anand Venkat
April 18, 2011
Hi Richard,
Great post. Thank you.
I have an issue that I am not able to resolve. I am tying to update an OptionSet field in CRM and I get deserialization error if use xs:string type in my xslt in the map. What type should I use for OptionSet?
Thanks,
Anand
Richard Seroter
April 20, 2011
Hi Anand,
I haven’t built that specific type yet. Is that the formatted values? I’d look at an example of a retrieval of option set values, and mimic that when you send data back in.
Anand Venkat
May 9, 2011
Hi Richard,
I tried your suggestion, I am getting the following error. I also bought your book and tried the method specified in that, i did not get back any error, but the optionset field never gets updated.
-
Sender
-
a:DeserializationFailed
-
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 ‘Error in line 1 position 939. Element ‘http://schemas.datacontract.org/2004/07/System.Collections.Generic:value’ contains data from a type that maps to the name ‘http://www.w3.org/2005/08/addressing:OptionSetValue’. The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name ‘OptionSetValue’ and namespace ‘http://www.w3.org/2005/08/addressing’.’. Please see InnerException for more details.
itvt
May 10, 2011
Hi Anand,
I’m trying to figure out the same thing. I tried using ns4:OptionSetValue as type and an additional Value-element (not the value element of the key-value pair).
With that I get the error “A validation error occurred. The value of ‘fieldxy’ on record of type ‘entityxy’ is outside the valid range”.
I doubled checked if the OptionSetValue that I pass to the service – it really exists.
itvt
May 10, 2011
Update: I had to use the namespace prefix also for the Value element. OptionSetValue is now set correctly. I wish it would be that hard to do such a simple task. For me the new appraoch is a step backwards.
Richard Seroter
May 10, 2011
Yes, working with Option Sets appears to force you to set the option set value instead of just letting you set the FormattedValue. I’m working on a blog post that digs into this a bit more.
Anand Venkat
May 10, 2011
Hi itvt,
Thanks for the response. Could you please send me a screen shot of the map and the script in the scripting functoid? it sitll dosent seem to work for me.
Thanks,
Anand
itvt
May 10, 2011
Hi Anand,
don’t know if pasting xml in the comment works but here is what I use currently:
x:OptionSetValue
Other field-types like Money also seem to need this kind construct.
Anand Venkat
May 10, 2011
yes. I understand that part, but i dont understand what you mean by “additional Value-element (not the value element of the key-value pair).”
Thanks,
Anand
itvt
May 10, 2011
unfortenatly xml can’t be inserted in the comments… What I ment was that you have the key/value elements and under the element “value” you need another element “Value” that contains the actual integer value of the optionlistvalue.
Anand Venkat
May 16, 2011
Hi itvt,
i have got to the point upto which I get the validation error. but still coldn’t get it to work.
Could you please strip the xml stuff from your xslt template and paste it as text?
or send the script to pvsanand@yahoo.com
Thanks,
Anand
Anand Venkat
May 16, 2011
Hi itvt,
When you test the map in visual studio providing a sample input instance, does it succeed?
Anand
Richard Seroter
May 20, 2011
All, I’ve done a follow up post which covers option sets and entity references. http://seroter.wordpress.com/2011/05/20/creating-complex-records-in-dynamics-crm-2011-from-biztalk-server-2010/
claus
June 28, 2011
great post!
with an “on premise” installation of crm it works like a charm!
Then i tried to do it with crm 2011 online. so far so good…
but i got a problem. when i use the binding-file which is created by visual Studio (with credentials off course…) i get a fault message that says: “An error occurred when verifying security for the message”. i`ve googled and found a lot of pages that states the problem is a time synch problem. but i dont have influence on the cloud server (how could i *g*)
did you edit the binding info?
because i dont have a security node in the binding-tab.
would be great if you can help me!
Claus
Richard Seroter
July 7, 2011
Hi Claus,
I haven’t done this yet with CRM Online although I keep threatening to.
Make sure that you use the “custom” binding file in the case that two binding files get created. The custom one exposes all of the extended properties of the adapter (such as security).
Andy Materdy
August 19, 2011
Although this post is of great help, I’m running into an error which I cannot seem to solve. The error I get from the CRM trace logs is:
Microsoft.Crm.CrmException: The user Id is invalid.
Any idea what might cause this error?
Richard Seroter
August 29, 2011
Hey Andy. Are you explicitly passing in credentials or is the caller on the same domain as the CRM server?
S.Mueller
September 8, 2011
Hi Richard,
we could not succeed yet in creating a new account. Please see the input XML and the Output error message. We have tried “everything”…
And what is the purpose of the “LogicalName”?
We would appreciate your help very much.
S.Mueller
========INPUT XML==============
StateCode
0
AccountNumber
BE01TEST
Telephone1
12345678
WebSiteUrl
http://www.test.com
Name
TestAccount01
OwnerIdType
8
OwnerId
FCCE6527-01FB-DF11-8748-18A9054B319E
Account
========Output error message==============
The adapter failed to transmit message going to send port “SP_CRM2011Output” with URL “http://10.16.216.58:5555/MarlinkTest2″. It will be retransmitted after the retry interval specified for this Send Port. Details:”System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.CreateChannelFactory[TChannel](IBaseMessage bizTalkMessage)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.InitializeValues(IBaseMessage message)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2..ctor(IBaseMessage message, WcfTransmitter`2 transmitter)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfTransmitter`2.GetClientFromCache(String spid, IBaseMessage message)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfAsyncBatch`2.BatchWorker(List`1 messages)”.
David Sporer
September 8, 2011
As we can’t see your XML-Code it will be difficult to help you out…
S.Mueller
September 13, 2011
Sorry for reply now, unfortunately the XML formatted code was removed while posting it from this website. I will try this (please remove the “123″ in front.
123
123
1232010793C-A4C0-DF11-8455-18A9054B31A2
123Account
123
123
123Account
123TestAccount01
123www.test.com
12312345678
123BE01TEST
1238
1230
123FCCE6527-01FB-DF11-8748-18A9054B319E
123
123</ns0:DemoInput
S.Mueller
September 13, 2011
It does not work….the XML format will be destroyed while posting….do you have an email where I can send it?
S.Mueller
September 13, 2011
Let’s try this….
“”
”
“2010793C-A4C0-DF11-8455-18A9054B31A2″
“Account”
“”
“”
“Account”
“TestAccount01″
“www.test.com”
“12345678″
“BE01TEST”
“8″
“0″
“FCCE6527-01FB-DF11-8748-18A9054B319E”
“”
“</ns0:DemoInput"
Richard Seroter
September 21, 2011
Any luck on this or are you still facing the issue?
Ricardo Bessa
September 20, 2011
Hi,
This article help me a lot on my first steps with CRM integration with BizTalk. Thanks for that.
Right now I’m facing a big issue that, in the comments, it was already discussed but still no solution.
”
2. How to pass user credential to wcf service if both CRM server and BizTalk are not in same domain and BizTalk user is not in same Active Directory where CRM user exists.
”
I already tried the wcf-custom with lot of customization (many sites talk about this, but no solution). Can you, or someone, help me on this?! Always getting the frustrating message “The caller was not authenticated by the service”.
Thanks in advance,
Sonia
December 8, 2011
This is a great article and certainly helped get me started, but I think I have missed something. My task is to get a message from CRM 2011 into biztalk, I have the schema for how I want it to appear, I have consumed the service and replaced the schemas from the SDK, but now I am completely stuck. Your example shows your message (DemoInput.xsd) being mapped for consumption by CRM, what I need is to map from CRM into my xml format.
I have no idea which xsd I should use.. Am I being a complete idiot?
Thanks
Richard Seroter
December 9, 2011
So you’re going from CRM to BizTalk. So the SDK schemas shouldn’t come into play since you are just creating a BizTalk-generated endpoint and consuming it from a CRM component (plug-in, workflow, etc). Is that right? Or are you trying to pull (vs push) from CRM into BizTalk? For the push-from-CRM-to-BizTalk scenario, I did write about this exactly scenario in the recent book.
Sonia
December 12, 2011
Thanks Richard, have got a copy of your book which I will read with much interest. I have to admit to knowing nothing about CRM but am assuming that it will push the message. I also re read and had a bit of an aha moment about the KeyValuePairs and how that relates to the actual fields in CRM, so hopefully with your book in hand it will all fall into place, thank you for getting back to me
Neil
March 20, 2012
Thanks for a brilliant article. It would have taken me a very long time to figure this out!
Ravi Shankar
August 14, 2012
replacing the schemas generated by the “add generated item” with those in the CRM SDK (5.0.10) invalidates all the multipart message types created in the “organizationservice.odx”… and I had to manually reassign the type for each multipart message.
Ravi Shankar
August 14, 2012
The issue seems to stem from difference in filenames generated by the “add generated item” wizard and those that exist in the SDK. The ones generated by the wizard has mixed case like “OrganizationService_……._Metadata.xsd” while those in the SDK are all lowercase. Setting them to the correct case and importing them into the projects set things right.
Shoaib Faruq
September 12, 2012
Hi Richard,
I am getting an error while adding generated items through Consume WCF Service wizard.
When I enter the service URL and press get button it gives the following error.
Metadata not available
Failed to get metadata from “https://mycrm/myorg/XRMServices/2011/Organization.svc”.
(Microsoft.BizTalk.Adapter.Wcf.Consuming.MetadataExchange.MetadataExchangeException) Unable to download metadata from “https://mycrm/myorg/XRMServices/2011/Organization.svc” using WS-Metadata Exchange. (System.InvalidOperationException) Metadata contains a reference that cannot be resolved: ‘https://mycrm/myorg/XRMServices/2011/Organization.svc’. (System.ServiceModel.Security.MessageSecurityException) The HTTP request was forbidden with client authentication scheme ‘Anonymous’. (System.Net.WebException) The remote server returned an error: (403) Forbidden.
CRM is configured using claim based authentication over IFD
When I add the URL
“https://mycrm/myorg/XRMServices/2011/Organization.svc?wsdl”. and press get button it shows the wsdl but when I press next
it gives object reference not set to an instance of an object error and it does not generate bindings and schemas.
However I have add a service reference in another test project and imported the app.config file from this project to the send port import configuration.
When I enable the send port after the configuration it gives following error
Error details: System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. —> System.ServiceModel.FaultException: ID3242: The security token could not be authenticated or authorized.
— End of inner exception stack trace —
Server stack trace:
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)
Exception rethrown at [0]:
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)
Exception rethrown at [1]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.Channels.IRequestChannel.EndRequest(IAsyncResult result)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)
MessageId: {0BF10E0C-B87D-4B5C-93BC-EC4C774D7983}
InstanceID: {4E80460A-0D8F-4949-8449-BE389818EE6F}
Any help in this regard would be much appreciated.
Thanks