Encoding issue when passing URL Parameters with BizTalk WCF-WebHttp Send Port

佐手、 提交于 2020-08-09 17:51:52

问题


I'm trying to call an RESTful API within BizTalk. I need to make a GET against the following endpoint:

https://mycompany.com/buyer/sandboxevol/

I have below mappings configured in my Send Port

<BtsHttpUrlMapping>
  <Operation Name='Operation_1' Method='GET' Url='/page.aspx/en/eai/api/supplier/{id}?apikey={apikey}&amp;format={format}' />
</BtsHttpUrlMapping>

paramater apikey has value as XXXXXXXXXXzvrpZHbMdKY75zbszhGOu%2bfnmP7Ms%3d. I have checked this and verified from suspended instance. Suspended message But error message different apikey value present. Refer screenshot Error message (hkey value highlighted)

Error information

character % is being encoded as %25 in error message. I believe there are 2 issues

  1. Invalid APi key issue (this post talks about this) and
  2. Some firewall/proxy opening between BizTalk and 3rd party system (I shall check this with internal Admin team)

Any thoughts on resolving this encoding/weird issue


回答1:


Based on the error, its most likely happening due to TLS version mismatch. BizTalk 2013 by default use TLS1.0. The recommended version now is to use TLS1.2 or up. You can check with API provider which version of TLS they use. You can change BizTalk behavior by creating a custom send pipeline component and then set TLS version using following code in Execute method. There is no change required to BizTalk message in pipeline component, just place this one line code and return same pInMsg from execute method.

System.Net.SecurityPointManager.SecurityProtocol = SecurityProtocolType.Tls12

ref like Microsoft doc

You can also use external tools such as Postman, Fiddler to test API calls outside BizTalk to make sure API works outside BizTalk.

    public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
    {


        System.Net.SecurityProtocolType protocolType;
        if (!String.IsNullOrEmpty(TlsVersion)
            && Enum.TryParse<System.Net.SecurityProtocolType>(TlsVersion, true, out protocolType))
            System.Net.ServicePointManager.SecurityProtocol = protocolType;
        else
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;


        return pInMsg;
    }


来源:https://stackoverflow.com/questions/62590234/encoding-issue-when-passing-url-parameters-with-biztalk-wcf-webhttp-send-port

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!