0

I have service chaining in wso2 REST to REST. Here is the scenario :

  1. First REST API (GET) just produce simple json
  2. Second REST API (PUT) consume the first rest api result, and produce it as json.

To achieve that i make some component in wso2 :

  1. REST API

    <?xml version="1.0" encoding="UTF-8"?>
    <api context="/flight" name="Flight" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="PUT" uri-template="/">
    <inSequence>
        <property expression="//airport_cd/text()" name="airport_cd"
            scope="default" type="STRING" />
        <property name="HTTP_METHOD" scope="axis2" type="STRING"
            value="GET" />
    
        <send receive="insertFlightSeq">
            <endpoint>
                <address format="rest"
                    uri="https://jsonplaceholder.typicode.com/posts/1" />
            </endpoint>
        </send>
        <send />
    </inSequence>
    <outSequence>
        <send />
    </outSequence>
    <faultSequence />
    

  2. Sequence to aceess the second rest API (insertFlightSeq)

    <?xml version="1.0" encoding="UTF-8"?>
    <sequence name="insertFlightSeq" trace="disable"xmlns="http://ws.apache.org/ns/synapse">
    <payloadFactory media-type="json">
    <format>
        {"hello":"hello"}
    </format>
    <args>
        <arg evaluator="json" expression="$."/>
    </args>
    </payloadFactory>
    
    <property name="HTTP_METHOD" scope="axis2" type="STRING" value="PUT"/>
    <property name="messageType" scope="axis2" type="STRING" value="application/json"/>
    <send receive="sendFlightSeq">
        <endpoint>
            <address format="rest" uri="http://localhost:8084/AeroData/flight/"/>
        </endpoint>
    </send>
    </sequence>
    
  3. Another sequence to output it

    <?xml version="1.0" encoding="UTF-8"?>
    <sequence name="sendFlightSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
         <send/>
    </sequence>
    

But in wso2 log console it shows illegal character and the second API cant accept that character.

Caused by: org.codehaus.jackson.JsonParseException: Illegal character
((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is
allowed between tokens

This is the wso2 console log. It's shows like [0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0xab]V[0xca]H[0xcd][0xc9][0xc9]W[0xb2][0x82][0xd2][0xb5][0x0][0x92]H[0x81];[0x11][0x0][0x0][0x0][\r][\n]

enter image description here

Is this happen because of messager formatter like this question ?

Community
  • 1
  • 1
Lyan Dwi Pangestu
  • 463
  • 1
  • 7
  • 23

0 Answers0