none
WCF-WebHttp REST configuration RRS feed

  • Question

  • I'm trying to configure the WCF-WebHttp adapter to retreive data from a REST endpoint, specifically a contact in CRM.  I need to include a filter to return only the contact that I want.  When I include a hardcoded value in the Uri it works fine:

    <BtsHttpUrlMapping>
      <Operation Name="Query" Method="GET" Url="?$filter=bsg_ProLicenseNumber eq '74309'" />
    </BtsHttpUrlMapping>

    However, I need to use a parameter here.  I have configured a parameter in the variable mapping section called PCCNUM.  When I include that in my Uri I get an error:

    <BtsHttpUrlMapping>
      <Operation Name="Query" Method="GET" Url="?$filter=bsg_ProLicenseNumber eq {PCCNUM}" />
    </BtsHttpUrlMapping>

    Error:  The Uri Template '?$filter=bsg_ProLicenseNumber eq {PCCNUM}' is not valid; each portion of the query string must be of the form 'name=value', when value cannot be a compound segment. 

    I have tried several ways of formatting {PCCNUM}, (single quotes, double quotes, parenthesis, encoding, etc.) but no luck.  Any ideas?

    Thanks,

    Frank

    Friday, February 7, 2014 3:19 PM

Answers

  • Hi,

    The Variable Mapping options in the Send Port are limited. Another option is to use an Dynamic Send Port. In that case you have full control over the URI in the Orchestration.

    How to Configure a WCF-WebHttp Send Port
    http://msdn.microsoft.com/en-us/library/jj572853(v=bts.80).aspx

    Calling Restful Service using Dynamic Send Ports – BizTalk 2013
    http://masteringbiztalkserver.wordpress.com/2013/11/11/calling-restful-service-using-dynamic-send-ports-biztalk-2013/ 

     

    Kind regards,

    Tomasso Groenendijk

    Blog  |  Twitter
    MCTS BizTalk Server 2006, 2010

    If this answers your question please mark it accordingly

    • Marked as answer by FrankD302 Saturday, February 15, 2014 8:52 PM
    Monday, February 10, 2014 10:15 AM
  • Suleiman--I think you are right.  Variable Property Mapping won't work with OData queries.

    Tomasso--I ended up using a dynamic send port and got it to work.  I used Richard's article as a starting point and then had to add some additional properties for security as follows:

    MsgCard = MsgRcv;

    MsgCard(*) = MsgRcv(*);

    MsgCard(WCF.HttpMethodAndUrl) = @"<BtsHttpUrlMapping>

      <Operation Name='RESTGet' Method='GET' />

      </BtsHttpUrlMapping>";

    PCBCRD = System.Convert.ToString(MsgCard.Body.content.properties.bsg_cardnumber);

    Port_sndCRMCardQuery(Microsoft.XLANGs.BaseTypes.Address) = "http://[Organization Root URL]/BSGPOC/XRMServices/2011/OrganizationData.svc/bsg_cardSet?$filter=bsg_cardnumber eq " + "'" + PCBCRD + "'";

    Port_sndCRMCardQuery(Microsoft.XLANGs.BaseTypes.TransportType) = "WCF-WebHttp";

    MsgCard(WCF.SuppressMessageBodyForHttpVerbs) = "GET";

    MsgCard(WCF.SecurityMode) = "TransportCredentialOnly";

    MsgCard(WCF.TransportClientCredentialType) = "Ntlm";

    MsgCard(WCF.EndpointBehaviorConfiguration) = @"<behavior name='clientEndpointCredential'><clientCredentials><windows allowedImpersonationLevel='Impersonation' allowNtlm='True' /></clientCredentials></behavior>";

    MsgCard(WCF.HttpHeaders) = "Content-Type: application/atom+xml";

    • Marked as answer by FrankD302 Saturday, February 15, 2014 8:58 PM
    Saturday, February 15, 2014 8:58 PM

All replies

  • I am not sure but I think OData System Query Options Using the REST Endpoint is not supported with BizTalk WCF-WebHttp adapter

    Try to use this

    <BtsHttpUrlMapping>
      <Operation Name="Query" Method="GET" Url="EntityName/bsg_ProLicenseNumber={PCCNUM}" />
    </BtsHttpUrlMapping>

    Note: Make sure to replace EntityName with yours.

    I hope this will help you

    Sunday, February 9, 2014 8:27 PM
  • Hi,

    The Variable Mapping options in the Send Port are limited. Another option is to use an Dynamic Send Port. In that case you have full control over the URI in the Orchestration.

    How to Configure a WCF-WebHttp Send Port
    http://msdn.microsoft.com/en-us/library/jj572853(v=bts.80).aspx

    Calling Restful Service using Dynamic Send Ports – BizTalk 2013
    http://masteringbiztalkserver.wordpress.com/2013/11/11/calling-restful-service-using-dynamic-send-ports-biztalk-2013/ 

     

    Kind regards,

    Tomasso Groenendijk

    Blog  |  Twitter
    MCTS BizTalk Server 2006, 2010

    If this answers your question please mark it accordingly

    • Marked as answer by FrankD302 Saturday, February 15, 2014 8:52 PM
    Monday, February 10, 2014 10:15 AM
  • Suleiman--I think you are right.  Variable Property Mapping won't work with OData queries.

    Tomasso--I ended up using a dynamic send port and got it to work.  I used Richard's article as a starting point and then had to add some additional properties for security as follows:

    MsgCard = MsgRcv;

    MsgCard(*) = MsgRcv(*);

    MsgCard(WCF.HttpMethodAndUrl) = @"<BtsHttpUrlMapping>

      <Operation Name='RESTGet' Method='GET' />

      </BtsHttpUrlMapping>";

    PCBCRD = System.Convert.ToString(MsgCard.Body.content.properties.bsg_cardnumber);

    Port_sndCRMCardQuery(Microsoft.XLANGs.BaseTypes.Address) = "http://[Organization Root URL]/BSGPOC/XRMServices/2011/OrganizationData.svc/bsg_cardSet?$filter=bsg_cardnumber eq " + "'" + PCBCRD + "'";

    Port_sndCRMCardQuery(Microsoft.XLANGs.BaseTypes.TransportType) = "WCF-WebHttp";

    MsgCard(WCF.SuppressMessageBodyForHttpVerbs) = "GET";

    MsgCard(WCF.SecurityMode) = "TransportCredentialOnly";

    MsgCard(WCF.TransportClientCredentialType) = "Ntlm";

    MsgCard(WCF.EndpointBehaviorConfiguration) = @"<behavior name='clientEndpointCredential'><clientCredentials><windows allowedImpersonationLevel='Impersonation' allowNtlm='True' /></clientCredentials></behavior>";

    MsgCard(WCF.HttpHeaders) = "Content-Type: application/atom+xml";

    • Marked as answer by FrankD302 Saturday, February 15, 2014 8:58 PM
    Saturday, February 15, 2014 8:58 PM
  • In fact I am facing the same issue

    And I noticed that it is the ? (question mark) that is causing the issue.

    The URL above  : <EntityName>?$filter=bsg_ProLicenseNumber eq {PCCNUM}

    should have been rewritten to something like <EntityName>$filter=bsg_ProLicenseNumber eq {PCCNUM}

    Is there any way to escape the question mark?

    Stefan


    Reporting Solution for BizTalk | follow-us on twitter

    Tuesday, June 14, 2016 10:27 AM
  • Still continuing with my testings

    When I escape the ? with %3F, I got the error of the REST Odata provider the exception : 

    invalid entity (or function) name: ?$filter=bsg_ProLicenseNumber eq {PCCNUM}

    Any idea on this?


    Reporting Solution for BizTalk | follow-us on twitter

    Tuesday, June 14, 2016 10:40 AM