serving the solutions day and night

Pages

Monday, June 3, 2013

Select Dynamics CRM 2011 Entity Record from BizTalk 2010 Server

Dynamics CRM 2011 BizTalk 2010 Server Integration - Select Dynamics CRM 2011 Entity Record from BizTalk 2010 Server

Step 1 - Create Schema and Orchestration

1)Import Dynamics CRM 2011 Organization Service SOAP Protocol to BizTalk Server 2010
   Create New Project (CRMORGSOAP.dll) and add refernece to this project.

2)Right click the project -> Signing -> Check 'Sign the assembly' -> Create <New> 'Strong Name     Key' or <Browse> existing one
  Select Deployment -> Enter Application Name ('DNS_BTS_CRM') -> Restart Host Instances - True
 
3)Right click the project -> Select Add -> New Item ->  Schema (SAudit.xsd) -> Press 'Add' button
  <Select> used for pass entity name and record id to CRM.
  <List> used for response result from CRM.
 


4)Right click the project -> Select Add -> New Item ->  Map (MBTS_CRM.btm) -> Press 'Add' button
  Select 'Open Source Schema' -> Choose  'DNS_BTS_CRM.SAuditXML' from Schemas (Type Name)
  Select 'Open Destination Schema' -> Choose 'DNS_BTS_CRM.organizationservice_schemas_microsoft_com_xrm_2011_contracts_services' from Schemas -> select 'Retrieve' from Root Node for Target Name
 
 
  Map source 'Entity Name' to destination 'entityName'.
  Map source 'ID' to destination 'id'.
 
  Add 'Scripting' from 'Advanced Functiods' Toolbox -> Double click the 'Scripting' -> Choose 'Script Functiod Configuraiton' -> select 'Inline XSLT' from script type.
     
  Enter the following xml in the inline script (if you not mention any entity column (attribute) name, BizTalk won't reterieve it, so mention all the reterieve entity attribute name here)    
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_auditnumber</string>     
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_firstname</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_middlename</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_lastname</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_suffix</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_dischargedate</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_birthdate</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_state</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_county</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_ward</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_matchstatus</string>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">dns_auditstatus</string>
 

  Map  'Scripting' to destination 'string'
 

5)Right click the project -> Select Add -> New Item ->  Map (MCRM_BTS.btm) -> Press 'Add' button
  Select 'Open Source Schema' -> Choose 'DNS_BTS_CRM.organizationservice_schemas_microsoft_com_xrm_2011_contracts_services' from Schemas -> select 'RetrieveResponse' from Root Node for Target Name   
  Select 'Open Destination Schema' -> Choose  'DNS_BTS_CRM.SAuditXML' from Schemas (Type Name)
  Add 'Scripting' from 'Advanced Functiods' Toolbox -> Double click the 'Scripting' -> Choose 'Script Functiod Configuraiton' -> select 'Inline XSLT' from script type.
     
  Enter the following xml in the inline script
  <First>
  <xsl:value-of select="//*[local-name()='KeyValuePairOfstringanyType'][*[local-name()='key']='dns_firstname']/*[local-name()='value']"/>
  </First>

  Map  'Scripting' to destination 'First'
 
  Repeat the above steps for all the fields ID, AuditNumber, First, Middle, Last, Suffix, Birth, Discharge, State, County, Ward, Match, Audit.
 
 
6)Double Click 'OrganizationService.odx' -> Select 'Orchestration View'
  Select Messages -> Right Click 'New Message', name it (Mes_Select) -> Message Type -> 'DNS_BTS_CRM.SAuditXML' from Schemas.
 
  Right Click 'New Message'(Mes_List) -> Message Type -> 'DNS_BTS_CRM.SAuditXML' form Schemas.
  Right Click 'New Message'(Mes_Request) -> Message Type -> 'DNS_BTS_CRM.IOrganizationService_Retrieve_InputMessage' from Multi-part Message Type.
  Right Click 'New Message'(Mes_Response) -> Message Type -> 'DNS_BTS_CRM.IOrganizationService_Retrieve_OutputMessage' from Multi-part Message Type. (Another 'ReterieveResponse').

  Another Approach
  Right Click 'New Message'(Mes_Response) -> Message Type -> Schema <Select from Referenced assembly....>  -> DNS_BTS_CRM.organizationservice_schemas_microsoft_com_xrm_2011_contracts_services -> select 'Retrieve'.
 
     

  Drop 'Receive' shape from 'Toolbox', name it (SelectQuery) -> Select Message (Mes_Select) -> Select Activate (True).   
  Drop 'Port' shape -> Enter Port Name (PortSelect) -> Enter Port Type Name (PortTypeSelect) -> Press 'Finish' button -> Select Opertation_1, rename it (OpSelect).
  Map 'PortSelect' port to 'SelectQuery' shape.
 

  Drop 'Transform' Shape
      CMQuery -> select 'Message Constructred' - 'Mes_Requst'
      TranQuery -> select 'Map Name' -> choose 'Existing Map' -> select 'DNS_BTS_CRM.MBTS_CRM' -> Select Source 'Mes_Select' -> select Destination 'Mes_Request.parameters' -> Press 'OK' button.
 

  Drop 'Send' (Name -> SendQuery and Message -> Mes_Request) and 'Receive' (Name -> ReceiveList and Message -> Mes_Response) Shape.

  Drop 'Port' shape -> Enter Port Name (PortCRMService) -> Choose 'Use an exiting Port Type' (DNS_BTS_CRM.IOrganizationService) -> Select 'I'll be sending a request and receingin a respone.' from Port direction of communication -> Press 'Finish' button.
 
  Map 'SendQuery' shape to Retrieve 'Request' port and 'ReceiveList' shape to Retrieve 'Response' port.
 
  Drop 'Transform' Shape
      CMList -> select 'Message Constructred' - 'Mes_List'
      TranList -> select 'Map Name' -> choose 'Existing Map' -> select 'DNS_BTS_CRM.MCRM_BTS' -> Select Source 'Mes_Response.parameters' -> select Destination 'Mes_List' -> Press 'OK' button.

  Drop 'Send' (Name -> SendList and Message -> Mes_List) Shape.
  Drop 'Port' shape -> Enter Port Name (PortList) -> Enter Port Type Name (PortTypeList) -> Select 'I'll always br sending message on this port.' from Port direction of communication -> Press 'Finish' button -> Select Opertation_1, rename it (OpList).
  Map 'PortList' port to 'SendList' shape.
 
 
7)Build and Deploy the project.   

Step 2 - Configure the BizTalk Server

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

2)Right click the 'DNS_BTS_CRM' -> select Import -> Bindings -> Choose 'OrgnizationService_Custom_BindingInfo.xml' -> select 'Send Ports' -> Verify the 'WcfSendPort_OrganizationService_CustomBinding_IOrganizationService_Custom' Name exist.


3)Select 'Receive Ports' -> New -> One-way Receive Port... -> name it 'ReceivePortQuery' -> select 'Receive Locations' -> Select 'New..' -> name it 'Receive LocationQuery' -> Type 'File' -> Configure local folder (in my case c:\BTS\Audit\Query) -> select 'XML Receive' from Receive Pipeline -> Press 'Ok' 2 times.


4)Select 'Send Ports' -> New -> Static One-way Send Port... -> name it 'SendPortList' ->  Type 'File' -> Configure local folder (in my case c:\BTS\Audit\List) -> Press 'Ok'.


5)Select 'Orchestation' -> Double Click 'DNS_BTS_CRM.OrganizationServiceClient' -> select Bindings -> select Host (BizTalkServerApplication) -> select PortSelect (ReceivePortQuery) -> select PortCRMService (WcfSendPort_OrganizationService_CustomBinding_IOrganizationService_Custom) -> select PortList (SendPortList)


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

7)Place the below xml in the 'c:\BTS\Audit\Query' folder
<ns0:Audit xmlns:ns0="http://DNS_BTS_CRM.SFAXML">
  <Select>
    <EntityName>dns_audit</EntityName>
    <ID>FE97FE5B-EAA2-E211-AC12-0050568C2EE8</ID>
  </Select>
  <List/>
</ns0:Audit>


8)You will get the {BD379E18-0144-4706-AD12-CDEA3659B54C}.xml response file in the c:\BTS\Audit\List folder

<?xml version="1.0"?>
<ns0:Audit xmlns:ns0="http://DNS_BTS_CRM.SFAXML">
    <List>
        <ID>7df41832-a6c4-e211-bc9e-0050568c2ee8</ID>
        <AuditNumber>525083</AuditNumber>
        <Name>
            <First>EASY</First>
            <Last>LIFO</Last>
            <Middle>M</Middle>
            <Suffix>III</Suffix>
        </Name>
        <Date>
            <Birth>1990-05-11T05:00:00Z</Birth>
            <Discharge>2030-05-06T05:00:00Z</Discharge>
        </Date>
        <Address>
            <State/>
            <County>39294ecd-f4ed-e111-9564-0050568c5ad0dns_countySARPY COUNTY - 13</County>
            <Ward>b7d1b4f8-6c9d-e211-b6bb-0050568c2ee0dns_wardBELLEVUE Ward 1-3</Ward>
        </Address>
        <Status>
            <Match>810520002</Match>
            <Audit>810520001</Audit>
        </Status>
    </List>
</ns0:Audit>

No comments: