5

I have to connect a REST service via BizTalk. The service returns a JSON response as shown below. When the BizTalk response port tries to decode the JSON message I get an error about JSON to XML conversion. This error happen because of embedded HTML tags in the JSON Message.

Error:

(There was a failure executing the response(receive) pipeline: "Avansas.Paritus.Suggest.T.JSONReceive, Avansas.Paritus.Suggest.T, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7b2984270a9ffd13" Source: "JSON decoder" Send Port: "Avansas.Ibrahim.Suggest.T.SendPort" URI: "api1.test.com/services/rest"; Reason: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. )

For Example:

As below response message has a label element in JSON. Label element has a text with html tag (City) that's why when BizTalk tries to convert JSON to XML I get an error. I think BizTalk tries to convert JSON as figure 2 but I want to convert it as figure 3.

How can I solve this issue?

Is there any way to passthru transmit on orchestration without any schema?

Figure1

{
    "suggestion": [
        {
            "id": "[31 31 31 30 30 39]",
            "label": "Global <b>City</b> 2. Etap Global <b>Cıty</b> ",
            "value": "Global <b>City</b> 2. Etap Villaları "
        },
        {
            "id": "[39 33 36 32 35 36]",
            "label": "<b>City</b> Aqua Villas Sk.  Kuşadası Aydın",
            "value": "<b>City</b> Aqua Villas Sk.  Kuşadası Aydın"
        }
    ]
}

Figure 2:

<root>
    <suggestion>
        <id>[31 31 31 30 30 39]</id>
        <label>Global 
            <b>City</b> 2. Etap Global 
            <b>Cıty</b>
        </label>
        <value>Global 
            <b>City</b> 2. Etap Villaları 
        </value>
    </suggestion>
    <suggestion>
        <id>[39 33 36 32 35 36]</id>
        <label>
            <b>City</b> Aqua Villas Sk.  Kuşadası Aydın
        </label>
        <value>
            <b>City</b> Aqua Villas Sk.  Kuşadası Aydın
        </value>
    </suggestion>
</root>

Figure 3:

<root>
    <suggestion>
        <id>[31 31 31 30 30 39]</id>
        <label>Global 
            &lt;b&gt;City&lt;/b&gt; 2. Etap Global 
            &lt;b&gt;Cıty&lt;/b&gt;
        </label>
        <value>Global 
            &lt;&gt;City&lt;/b&gt; 2. Etap Villaları 
        </value>
    </suggestion>
    <suggestion>
        <id>[39 33 36 32 35 36]</id>
        <label>
            &lt;b&gt;City&lt;/b&gt; Aqua Villas Sk.  Kuşadası Aydın
        </label>
        <value>
            &lt;b&gt;City&lt;/b&gt; Aqua Villas Sk.  Kuşadası Aydın
        </value>
    </suggestion>
</root>

Also my service can be return xml response and when i try to handle xml response a get an below error.

XML Error There was a failure executing the response(receive) pipeline: "Microsoft.BizTalk.DefaultPipelines.XMLReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Source: "XML disassembler" Send Port: "aaa.bbb.Suggest.T.SendPort" URI: "https://api1.test.com/services/rest" Reason: Finding the document specification by message type "html" failed. Verify the schema deployed properly

And response xml as shown below

<?xml version="1.0" encoding="UTF-8"?>
<suggestions>
   <suggestion>
      <id>111011</id>
      <label>Global &lt;b&gt;Cıty&lt;/b&gt; 1. Etap Vıllaları Sokak</label>
      <value>Global Cıty 1. Etap Vıllaları Sokak</value>
   </suggestion>
   <suggestion>
      <id>111009</id>
      <label>Global &lt;b&gt;Cıty&lt;/b&gt; 2. Etap Vıllaları Sokak</label>
      <value>Global Cıty 2. Etap Vıllaları Sokak</value>
   </suggestion>
</suggestions>
ibrahimsen
  • 173
  • 2
  • 9
  • Can you post the actual error message? – Johns-305 Jul 01 '15 at 00:19
  • Which version of BizTalk are you using? (2013 R2) – ibrahimsen Jul 01 '15 at 00:28
  • Can you post the actual error message? (There was a failure executing the response(receive) pipeline: "Avansas.Paritus.Suggest.T.JSONReceive, Avansas.Paritus.Suggest.T, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7b2984270a9ffd13" Source: "JSON decoder" Send Port: "Avansas.Ibrahim.Suggest.T.SendPort" URI: "https://api1.test.com/services/rest" Reason: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. ) – ibrahimsen Jul 01 '15 at 00:30
  • I solved problem its about server error thats why i could not handle message. If request value wrong then server return text/plain thats why biztalk could not serialize the message. When our request is correct server return a application/json content then my problem solved. But still I dont know how can i handle text/plain error message on biztalk. – ibrahimsen Jul 07 '15 at 21:56

1 Answers1

3

Using this schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://BizTalk_Server_Project1.JSONSchema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Root">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="suggestion">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" name="id" type="xs:string" />
              <xs:element minOccurs="0" name="label" type="xs:string" />
              <xs:element minOccurs="0" name="value" type="xs:string" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

And this pipeline:

JSON Pipeline

Produces this message:

<ns0:Root xmlns:ns0="http://BizTalk_Server_Project1.JSONSchema1">
  <suggestion>
    <id>[31 31 31 30 30 39]</id>
    <label>Global &lt;b&gt;City&lt;/b&gt; 2. Etap Global &lt;b&gt;Cıty&lt;/b&gt; </label>
    <value>Global &lt;b&gt;City&lt;/b&gt; 2. Etap Villaları </value>
  </suggestion>
  <suggestion>
    <id>[39 33 36 32 35 36]</id>
    <label>&lt;b&gt;City&lt;/b&gt; Aqua Villas Sk.  Kuşadası Aydın</label>
    <value>&lt;b&gt;City&lt;/b&gt; Aqua Villas Sk.  Kuşadası Aydın</value>
  </suggestion>
</ns0:Root>
Dan Field
  • 20,885
  • 5
  • 55
  • 71
  • Thank you for your suggestion but I have same pipeline and it is not solve my problem. Also my service can be return xml response and when i try to get xml response i get an below error. Reason: Finding the document specification by message type "html" failed. Verify the schema deployed properly. – ibrahimsen Jul 01 '15 at 06:50
  • @ibrahimsen Are you sure you have that pipeline in the response for your send port? Also what configuration do you have on your XML disassembler? – Dijkgraaf Jul 01 '15 at 20:58
  • @Dijkgraaf Yes I have XML disassembler on my pipeline. I solved problem its about server error thats why i could not handle message. If request value wrong then server return text/plain thats why biztalk could not serialize the message. When our request is correct server return a application/json content then my problem solved. But still I dont know how can i handle text/plain error message on biztalk. – ibrahimsen Jul 02 '15 at 10:39
  • @dan-field Thank you for your answer. – ibrahimsen Jul 02 '15 at 10:40
  • Ah yes. The good old HTML response message. Not a lot you can do except to enable routing for failed messages and have something subscribing to the failed messages so that support gets notified and can take action on the occasions that they happen. – Dijkgraaf Jul 02 '15 at 20:25