Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Fetch lookup Data from MS CRM 4.0
- This topic has 5 replies, 1 voice, and was last updated 8 years, 3 months ago by
community-content.
-
AuthorPosts
-
-
February 4, 2009 at 12:42 AM #21637
HI,
i want to fetch data from CRM 4.0 using BTS 2006 adapter for MS CRM 4.0
For this i am using FetchXmlToQueryExpression crm action.
I am using FetchXmlToQueryExpression_FetchXmlToQueryExpressionRequest.xsd to send fetchXML request by setting attribute as:
crm_action : “execute“
FetchXML: FetchXML query as an output of Scripting Functoid.And using response.xsd coming with BTS 2006 adapter for MS CRM 4.0 to receive response from MS CRM
i set the target namespace for reponse.xsd as: targetNamespace=“http://schemas.microsoft.com/crm/2007/BizTalkAdapter/MicrosoftCRM/Response” according to the organization name here orgName: “MicrosoftCRM”Now i am getting an error:
Exception thrown from: segment -1, progress -1
Inner exception: Received unexpected message type ” does not match expected type ‘http://schemas.microsoft.com/crm/2007/BizTalkAdapter/MicrosoftCRM/Response#Response’Exception type: UnexpectedMessageTypeException
Source: Microsoft.XLANGs.Engine
Target Site: Void VerifyMessage(Microsoft.XLANGs.Core.Envelope, System.String, Microsoft.XLANGs.Core.Context, Microsoft.XLANGs.Core.OperationInfo)Thanks,
Kuldip
-
February 5, 2009 at 3:17 AM #21647
See: http://www.ascentium.com/blog/crm/post398.aspx
CRM Response Namespace
–
A core feature of the new adapter and of CRM 4.0 is supporting multiple organizations. While this is a really cool feature, we have found an issue with the new adapter that make truly supporting multiple organizations in BizTalk very challenging. The CRM response XSD, a generic XSD containing the success or failure message sent from CRM on each call, has an organization specific namespace. For example, in Ascentium’s development environment (organization is AscentiumCrmDev) has a CRM response XSD namespace of http://schemas.microsoft.com/crm/2007/BizTalkAdapter/AscentiumCRMDev
/Response
. The problem with this is that if the organization name changes from what the BizTalk solution was developed on, the response message will fail because of the differences in expected namespace.Here are a couple of possible solutions that we considered:
-
- Creating a custom receive pipeline to change the namespace.
- Create multiple inbound schema and maps for known organizations and map your ports to the appropriate maps.
- Ignore the response message from CRM.
There are many more possible solutions including keeping the organization names the same between all environments, but this defeats the purpose of supporting multiple organizations. For our solution, we implemented a custom receive pipeline to update the namespace as the message comes back from CRM. This is not a simple solution and requires a decent amount of coding, but it serves the long term need for our project.
-
February 9, 2009 at 11:19 PM #21669
HI,
Thanks for your reply.
I am working on same structure as described above.
When i use the response.xsd provided by Microsoft with the BTS 2006
adapter for MS CRM 4.0 to receive response by hard coding the
organization name in the target namespace.targetNamespace=“http://schemas.microsoft.com/crm/2007/BizTalkAdapter/MicrosoftCRM/Response” according to the organization name here orgName: “MicrosoftCRM”Still i am getting an error:
Exception thrown from: segment -1, progress -1
Inner exception: Received unexpected message type ” does not match expected type ‘http://schemas.microsoft.com/crm/2007/BizTalkAdapter/MicrosoftCRM/Response#Response’Exception type: UnexpectedMessageTypeException
Source: Microsoft.XLANGs.Engine
Target
Site: Void VerifyMessage(Microsoft.XLANGs.Core.Envelope, System.String,
Microsoft.XLANGs.Core.Context, Microsoft.XLANGs.Core.OperationInfo)Here is the Schema instance for response.xsd generated in Visual Studio 2005
– <ns0:Response xmlns:ns0=”http://schemas.microsoft.com/crm/2007/BizTalkAdapter/MicrosoftCRM/Response”>
– <Header>
<ReturnCode>ReturnCode_0</ReturnCode>
<ErrorCode>ErrorCode_0</ErrorCode>
<ErrorString>ErrorString_0</ErrorString>
<Retryable>Retryable_0</Retryable>
</Header>
– <Body>
<Message>Message_0</Message>
</Body>
</ns0:Response>and this the suspended message details of response from CRM
<ns0:Response xmlns:ns0=”http://schemas.microsoft.com/crm/2007/BizTalkAdapter/MicrosoftCRM/Response”>
<Header>
<ReturnCode>1</ReturnCode>
<ErrorCode></ErrorCode>
<ErrorString></ErrorString>
<Retryable></Retryable>
</Header>
<Body>
<Message><prefix:CreateResponse xmlns:prefix=”http://localhost/schemas.microsoft.com/crm/2007/MicrosoftCRM/CreateResponse”><id>f0650fb5-3ff7-dd11-b0f0-0003ff1a2a3c</id></prefix:CreateResponse></Message>
</Body>
</ns0:Response>Thanks,
Kuldip
-
February 18, 2009 at 3:58 AM #21761
Hi kuldip01.
Try that:
In yours BizTalk Administration Console\SomeAplication\SendPort you must have port called like CRMSendPort that send your requests to CRM.
Make sure that SendPipeLine and RecievePipeLine = XMLTransmit and XMLRecieve.Andrew.
[email protected]
-
-
-
April 14, 2009 at 8:53 AM #22134
I have jsut finished working out an issue with the Responce.xsd.
I needed the response GUID ID after creating an Activity. I created a Helper class to parse the string XML into XML. I then
used the Email_CreateResponce Schema to format to a message.
I modified the code to fit what i needed. by doing this wi can do Seardches and Fetch using the adapter.
Thanks to Chris Romp for is project I was able to do the following.In Expresion message construct
Create a verable string in the Orch and fill it.
strResponseXML = xpath(crmActivityResponce, “string(/*[local-name()=’Response’ and namespace-uri()=’http://schemas.microsoft.com/crm/BizTalkAdapter/Response’%5D/*%5Blocal-name()=’Body’ and namespace-uri()=”]/*[local-name()=’Message’and namespace-uri()=”]/text())”);
crmActivityEmailCreateResponce = CBN.BizTalk.HelperClasses.XMLString.GetMessageFromXmlString(strResponseXML);
Created a Class with the following.
public class XMLString
{
public static XmlDocument GetMessageFromXmlString(string XmlString)
{
XmlDocument doc = new XmlDocument();
XmlString = DecodeXmlString(XmlString);
//XmlString = InsertNamespaceString(XmlString, Namespace);
doc.LoadXml(XmlString);
return doc;
}private static string DecodeXmlString(string XmlString)
{
XmlString = XmlString.Replace(“<“, “”);
XmlString = XmlString.Replace(“"”, “\””);
XmlString = XmlString.Replace(“'”, “\'”);
XmlString = XmlString.Replace(“&”, “&”);return XmlString;
}private static string InsertNamespaceString(string XmlString, string Namespace)
{
return InsertNamespaceString(XmlString, Namespace, String.Empty);
}
} -
May 18, 2009 at 4:08 AM #22387
the target name sapce for response is fixed and cannot be changed as BTS CRM adaptor always returns the orginal targetnamespace and not the one you have provided.
The adaptor was orginally designed for CRM3.0 and with minor tweaks can be used with CRM4.0. Response namespace cannot be changed USE the default namespace.
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.