Pages

Thursday, June 6, 2013

Dynamics CRM 2011 and BizTalk 2010 Server Integration - Exception


Exception 1
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. End element 'value' from namespace 'http://schemas.datacontract.org/2004/07/System.Collections.Generic' expected. Found element 'Value' from namespace 'http://schemas.microsoft.com/xrm/2011/Contracts'. Line 1, position 4190.'. Please see InnerException for more details.

Solution
Data Type is wrong.

For example, In CRM attribute type is int, but in BizTalk Schema contains string and in the Map, Script Functionid contains <xsl:attribute name="xsi:type"><xsl:value-of select="'xs:string'" /> , the CRM will throw the above error.

Change to  int in the schema and <xsl:attribute name="xsi:type"><xsl:value-of select="'xs:int'" /> in the Map


 Exception 2
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 2058. 'EndElement' 'KeyValuePairOfstringstring' from namespace 'http://schemas.microsoft.com/xrm/2011/Contracts' is not expected. Expecting element 'key'.'. Please see InnerException for more details.

Solution
 key is not passing

For example, in your map point to the Looping is point 'KeyValuePairOfstringstring', paris point to different   <ns4:KeyValuePairOfstringType />, so BizTalk will create the xml tag without key and value (<ns4:KeyValuePairOfstringstring />)

 Exception 3
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs

Solution
It could be any kind of error, first check Inline XSLT Call Template, template name may be repeated
<xsl:template name="SetFirstNameValue"> - dns_auditid
<xsl:template name="SetFirstNameValue"> - dns_firstname

Exception 4
Incorrect attribute value type System.String

Solution
Mostly data format is wrong.

For example, Date Attribute, must contain 2010-05-10T00:00:00.000-05:00 (dateTime Format in both Schema and value)

Exception 5
The adapter failed to transmit message going to send port "WcfSendPort_OrganizationService_CustomBinding_IOrganizationService_Custom" with URL "http:/<CRM Server>/XRMServices/2011/Organization.svc". It will be retransmitted after the retry interval specified for this Send Port. Details:"System.ServiceModel.CommunicationException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. ---> System.ServiceModel.QuotaExceededException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

Solution
Increase the macBufferSize and maxReceivedMessageSize size in the BizTalk Server Administation

Goto BizTalk Server Administration ConsoleApplication -> [Project Name] -> Send Port -> WcfSendPort_OrganizationService_CustomBinding_IOrganizationService_Custom ->Configure -> Binding -> httpTransport ->
increase macBufferSize and maxReceivedMessageSize 65536 to 2147483647

Exception 6
The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.

Solution
Check your 'Inlinse XSLT Call Template' in  Scripting Functioid, both schema may calling same template name.
For example
PlaceOfBirth -> <xsl:template name="SetPlaceOfBirthValue">
<xsl:param name="param1" />
<key xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic">dns_placeofbirth</key> ....</xsl:template>

RegNumber -> <xsl:template name="SetPlaceOfBirthValue">
<xsl:param name="param1" />
<key xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic">dns_regnumber</key> ....</xsl:template>

http://social.technet.microsoft.com/wiki/contents/articles/7204.biztalk-list-of-errors-and-warnings-causes-and-solutions.aspx

Exception 7
The adapter failed to transmit message going to send port "WcfSendPort_SqlAdapter_TypedStoredProcedure" with URL "mssql://localhost//adv_dev?". It will be retransmitted after the retry interval specified for this Send Port. Details:"Microsoft.ServiceModel.Channels.Common.XmlReaderParsingException: The start element with name "bookid" and namespace "http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/BizTalk" was unexpected. Please ensure that your input XML conforms to the schema for the operation.

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.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
   at System.ServiceModel.Channels.IRequestChannel.EndRequest(IAsyncResult result)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)".
<br/>

Solution
The problem is the parameter case sensitive, make sure that your both schema and stored procedure parameters are same botha and case sensitive. In my code Stored procedure contain "bookID" and schema contains "bookid", make it both are bookid, the above problem will be resolve.

<xs:element name="prGetVotingHistoryList">
    <xs:annotation>
      <xs:documentation>
        <doc:action xmlns:doc="http://schemas.microsoft.com/servicemodel/adapters/metadata/documentation">TypedProcedure/BizTalk/prGetBookList</doc:action>
      </xs:documentation>
    </xs:annotation>
    <xs:complextype>
      <xs:sequence>
        <xs:element maxoccurs="1" minoccurs="0" name="bookid" nillable="true" type="xs:int">
      </xs:element></xs:sequence>
    </xs:complextype>
  </xs:element>
  
   ALTER PROCEDURE [BizTalk].[prGetBookList]
       @bookID int
   AS
   SELECT
       *
   FROM
       BookHistory vh
   WHERE
    BookID =  @bookID
   

No comments:

Post a Comment