BizTalk WCF-WebHttp URI mapping problem with escaped variable

520 views Asked by At

I am trying to use BizTak WCF-WebHttp adapter to send to Service Desk Plus CMDB API using Variable Mapping.

When trying using the browser, it works fine. Service Desk Plus CMDB API requires an URI like (strictly shortened for readability):

http://host.com/api/cmdb/ci?OPERATION_NAME=read&TECHNICIAN_KEY=Mykey&format=XML&INPUT_DATA=<?xml version='1.0'?>
<API>
    <name>[email protected]</name>
</API>

I have used the URI http://host.com/api/cmdb/ci and URL Mapping.

<BtsHttpUrlMapping>
    <Operation Url="?OPERATION_NAME=read&amp;TECHNICIAN_KEY=MyKey&amp;format=XML&amp;INPUT_DATA=&lt;?xml version=&apos;1.0&apos;?&gt;
        &lt;API&gt;
            &lt;name&gt;[email protected]&lt;/name&gt;
        &lt;/API&gt;"/>  
</BtsHttpUrlMapping>

This works fine, but I need a more dynamic approach. I tried using Variable Mapping, so I replaced the hard coded email address with a variable.

<BtsHttpUrlMapping>
    <Operation Url="?OPERATION_NAME=read&amp;TECHNICIAN_KEY=MyKey&amp;format=XML&amp;INPUT_DATA=&lt;?xml version=&apos;1.0&apos;?&gt;
        &lt;API&gt;
            &lt;name&gt;{email}&lt;/name&gt;
        &lt;/API&gt;"/>  
</BtsHttpUrlMapping>

Trying to save the URL Mapping with the variable I get an error.

WCF-WebHttp Transport Properties

Error saving properties. (System.InvalidOperationException) The UriTemplate

?OPERATION_NAME=read&TECHNICIAN_KEY=MyKey&format=XML&INPUT_DATA=<?xml version='1.0'?><API><name>{email}</name></API>

is not valid; each portion of the query string must be of the form 'name=value', when value cannot be a compound segment. See the documentation for UriTemplate for more details.

If I try a variable that is not within the escaped XML string, like with the key, then it works fine.

<BtsHttpUrlMapping>
    <Operation Url="?OPERATION_NAME=read&amp;TECHNICIAN_KEY={key}&amp;format=XML&amp;INPUT_DATA=&lt;?xml version=&apos;1.0&apos;?&gt;
        &lt;API&gt;
            &lt;value&gt;[email protected]&lt;/value&gt;
        &lt;/API&gt;"/>  
</BtsHttpUrlMapping>

My intention is to be able to use a variable within the escaped XML string. If that is not possible; I will have to turn to a dynamic adapter and Create the URI and URL mapping in an orchestration.

1

There are 1 answers

2
r3verse On

Did u understand why it said each portion of the query string must be of the form 'name=value? There are just a few ways to make UriTemplates work.

See how a UriTemplate works here. Here is an example that is valid:

  • weather/{state}/{city}?forecast={day}

So in your case you should make everything after INPUT_DATA= a variable. Which means the whole escaped XML string you were talking about.