wso2 REST から REST へのサービス チェーンがあります。シナリオは次のとおりです。
- 最初の REST API (GET) は単純な json を生成するだけです
- 2 番目の REST API (PUT) は、最初の REST API の結果を消費し、json として生成します。
それを達成するために、 wso2 でいくつかのコンポーネントを作成します:
残りの 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 番目の 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>
それを出力する別のシーケンス
<?xml version="1.0" encoding="UTF-8"?> <sequence name="sendFlightSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse"> <send/> </sequence>
しかし、wso2 ログ コンソールでは、不正な文字が表示され、2 番目の API はその文字を受け入れることができません。
Caused by: org.codehaus.jackson.JsonParseException: Illegal character
((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is
allowed between tokens
これは wso2 コンソール ログです。みたいな番組です[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]
これは、この質問のようなメッセージフォーマッターが原因で発生しますか?