none
Using CRM Adapter 4.0 in Biztalk RRS feed

  • Question

  • Hello

    I'm using the biztalk adatper to retrieve a contact entity from CRM.

    - Request is based on: Retrieve_RetrieveRequest.xsd
    - crm_action = execute
    - tns:TargetRetrieveContact.EntityId = the guid of the contact entity to retrieve...

    As a response I receive a message based on the type CRMAdapterResponse_Response.xsd.

    The response look like this:

      <?xml version="1.0" encoding="utf-8" ?>
    - <ns0:Response xmlns:ns0="http://schemas.microsoft.com/crm/2007/BizTalkAdapter/RKV/Response">
    - <Header>
      <ReturnCode>1</ReturnCode>
      <ErrorCode />
      <ErrorString />
      <Retryable />
      </Header>
    - <Body>
      <Message><prefix:RetrieveResponse xmlns:prefix="http://localhost/schemas.microsoft.com/crm/2007/RKV/RetrieveResponse"><BusinessEntity xmlns:q1="http://schemas.microsoft.com/crm/2007/WebServices" xsi:type="q1:contact" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><q1:contactid>e6a29fd3-130f-df11-93f2-005056b540f7</q1:contactid><q1:firstname>Jurgen</q1:firstname><q1:owningbusinessunit>6a80cf13-360b-df11-b99c-005056b540f7</q1:owningbusinessunit></BusinessEntity></prefix:RetrieveResponse></Message>
      </Body>
      </ns0:Response>

    How can I configure or develop my solution in that way, that the adapter answers with a response of type RetrieveResponse.xsd ???

    Kind regards
    Wednesday, February 3, 2010 3:19 PM

Answers

  • I do not think you can promote the body content. Basically I was proposing you parse the message manually to get the part of the Xml you want to use.  

    I did not see a send port property to configure to get only the RetrieveResponse for the CRM 4 BizTalk adapter.

    If you call the CRMService using the WCF adapter then you can use the message body specification (see http://technet.microsoft.com/en-us/library/bb226478(BTS.10).aspx) to pull out only the RetrieveResponse using an XPath statement. The path would be something like:

    /*[local-name()='Response']/*[local-name='RetrieveResponse']

    Thanks,


    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Wednesday, February 3, 2010 10:46 PM
    Moderator

All replies

  • Sounds like there is extra schema information. If you do not have a schema for the whole thing then you could either try to debatch it using the xpath function in an orchestration or use a .NET reference to parse the Xml and return the prefix:Response message as an XmlDocument to the orchestration. You could also do this in a custom pipeline component on a custom pipeline - this would be the most useful way to handle this.

    If you cannot get a schema for the whole message returned (you could also try creating one), then you will need to use an Xml message type in an orchestration and parse it from there.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Wednesday, February 3, 2010 9:34 PM
    Moderator
  • That can be a solution.

    Again, this is the response I receive (In my previous post the receive was not very clear)

    <?xml version="1.0" encoding="utf-8" ?>
    <ns0:Response xmlns:ns0="http://schemas.microsoft.com/crm/2007/BizTalkAdapter/RKV/Response">
    <Header>
    <ReturnCode>1</ReturnCode>
    <ErrorCode />
    <ErrorString />
    <Retryable />
    </Header>
    <Body>
    <Message><prefix:RetrieveResponse xmlns:prefix="http://localhost/schemas.microsoft.com/crm/2007/RKV/RetrieveResponse"><BusinessEntity xmlns:q1="http://schemas.microsoft.com/crm/2007/WebServices" xsi:type="q1:contact" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><q1:contactid>e6a29fd3-130f-df11-93f2-005056b540f7</q1:contactid><q1:firstname>Jurgen</q1:firstname><q1:owningbusinessunit>6a80cf13-360b-df11-b99c-005056b540f7</q1:owningbusinessunit></BusinessEntity></prefix:RetrieveResponse></Message>
    </Body>
    </ns0:Response>

    What you are saying can be used as a solution: 
    1. promote the message element of the response
    2. create a variable in the orchestration of type XmlDocument
    3. load the content of the element message into the variable of type XmlDocument
    4. assign the variabel to a message of type RetrieveResponse (for wich the crm adapter generated a schema)

    But that is not really an answer to my question.

    The adapter is contacting the CrmService. The adapter executes the Execute method, with a parameter of type RetrieveRequest. The response of this methos is of type Response, which you can see above. In this response, in the message element, you can find the real response as embed xml of type String.

    My question: is there a wat to request the CrmService in that wat that I directly receive a response of type RetrieveResponse, and not of type Response. Note that both xsd schema's are generated by the adapter (Response.xsd and RetrieveResponse.xsd.

    Thx



    Wednesday, February 3, 2010 10:10 PM
  • I do not think you can promote the body content. Basically I was proposing you parse the message manually to get the part of the Xml you want to use.  

    I did not see a send port property to configure to get only the RetrieveResponse for the CRM 4 BizTalk adapter.

    If you call the CRMService using the WCF adapter then you can use the message body specification (see http://technet.microsoft.com/en-us/library/bb226478(BTS.10).aspx) to pull out only the RetrieveResponse using an XPath statement. The path would be something like:

    /*[local-name()='Response']/*[local-name='RetrieveResponse']

    Thanks,


    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Wednesday, February 3, 2010 10:46 PM
    Moderator