serving the solutions day and night

Pages

Tuesday, June 4, 2013

Dynamics CRM 2011 and BizTalk 2010 Server Integration - Handling Fault Exception

Dynamics CRM 2011 and BizTalk 2010 Server Integration - Handling Fault Exception

1)Refer the previous blog Querying Dynamics CRM 2011 Entrity Record from BizTalk 2010 Server

 
2)Right click the project -> Select Add -> New Item ->  Schema (SFault.xsd) -> Press 'Add' button



3)Double Click 'OrganizationService.odx' -> Select 'Orchestration View'
  Select Types -> IOrganizationService -> Retrieve -> OrgnizationServiceFaultFault -> Message Type -> Schemas => <Select from reference assembly...> => References => Microsfot.BixTalk.GloblaPropertySchemas => 'Fault - BTS.soap_envelope_1__2.Fault'.
 

  Select Messages -> Right Click 'New Message'(Mes_FaultResponse) -> Message Type -> Schemas -> 'BTS.soap_envelope_1__2.Fault'.
 
 
  Select Messages -> Right Click 'New Message'(Mes_FaultList) -> Message Type -> Schemas -> 'DNS_BTS_CRM.SFault'.

4)Drop 'Scope' shape from 'Toolbox', name it (ScopeList) -> TransactionType ('None') 
  Right click '{}(ScopeList)' -> Add 'New Exception Handler' (CatExFault) -> Exception Object Name (SoapFault) -> Exception Object Type (PortCRMService.Retrieve.OrganizationServiceFaultFault).

  Move SendQuery, ReceiveList, TranList, SendList shapes to ScopeList scope shape.
 
  Drop Message Assignment in CatExFault ->
  Rename ConstructMessage_1 (CMFault) -> Message Constructed (Mes_FaultList).
  Rename MessageAssignment_1 (MAssi_Fault) -> Expression => Mes_FaultResponse = SoapFault;
 
  Drop 'Transform' Shape
      CMTFault -> select 'Message Constructred' - 'Mes_Requst'
      TransFaultList -> select 'Map Name' -> choose 'New Map' -> Map Name 'DNS_BTS_CRM.TransFaultList' -> Select Source 'Mes_FaultResponse' -> select Destination 'Mes_FaultList' -> Press 'OK' button.
        New 'TransFaultList.btm' map file will be create.

  Drop 'Send'(SendFault) ->  Message -> Mes_FaultList.

  Drop 'Port' shape (PortFault) -> Enter Port Type Name (PortTypeFault) -> Select 'I'll always br sending message on this port.' from Port direction of communication -> Press 'Finish' button -> Select Opertation_1, rename it (OpFault).
  Map 'PortFault' port to 'SendFault' shape.

 5)Double Click 'TransFaultList.btm' map, add 3 'Scripting' from 'Advanced Functiods' Toolbox.
 Double click the 'Scripting' -> Choose 'Script Functiod Configuraiton' -> select 'Inline XSLT' from script type.

 <Code>
 <xsl:value-of select="//*[local-name()='Code']/*[local-name()='Value']"/>
 </Code>
 Map  'Scripting' to destination 'code'

 <Subcode>
 <xsl:value-of select="//*[local-name()='Subcode']/*[local-name()='Value']"/>
 </Subcode>
  Map  'Scripting' to destination 'subcode'
 
 <Detail>
 <xsl:value-of select="//*[local-name()='Reason']/*[local-name()='Text']"/>
 </Detail>
  Map  'Scripting' to destination 'detail'




7)Build and Deploy the project.   

8)Open BizTalk Administration -> Collapse All -> Select 'DNS_BTS_CRM'

9)Select 'Send Ports' (SendPortFault) -> c:\BTS\Audit\Fault -> Press 'Ok'.

10)Select 'Orchestation' -> Double Click 'DNS_BTS_CRM.OrganizationServiceClient' -> select Bindings -> select PortFaultt (SendPortFault)

11)Right click the 'DNS_BTS_CRM' -> 'Start' the project.

12)Place the below xml in the 'c:\BTS\Audit\Query' folder (invalid GUID format or wrong GUID)
<ns0:Audit xmlns:ns0="http://DNS_BTS_CRM.SFAXML">
  <Select>
    <EntityName>dns_audit</EntityName>
    <ID>FE97FE5B-EAA2-E211-AC12-0050568C2EE81</ID>
  </Select>
  <List/>
</ns0:Audit>

13)You will get the fault exception xml file in the c:\BTS\Audit\Fault folder

<?xml version="1.0"?>
<ns0:Fault xmlns:ns0="http://BTS_CRM.SchFault">
    <Code>Sender</Code>
    <Subcode>a:DeserializationFailed</Subcode>
    <Detail>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:id. The InnerException message was 'There was an error deserializing the object of type System.Guid. The value '7DF41832-A6C4-E211-BC9E-0050568C2EFF1' cannot be parsed as the type 'Guid'.'. Please see InnerException for more details.</Detail>
</ns0:Fault>

<?xml version="1.0"?>
<ns0:Fault xmlns:ns0="http://BTS_CRM.SchFault">
    <Code>Sender</Code>
    <Subcode/>
    <Detail>dbs_audit With Id = 7df41832-a6c4-e211-bc9e-0050568c2eff Does Not Exist</Detail>
</ns0:Fault>


No comments: