0
WSO2 ESB 4.8.1では、jsonメッセージを受け取るAPIを実装し、新しいjsonペイロードをバックエンドに送信します。 APIをデバッグして、jsonペイロードをxmlに変換し、それをバックエンドに送信することがわかりました。jsonを作成してWSO2の代わりにXMLを送信するESB
FYI:axis2設定ファイルでjsonストリームフォーマッタとビルダーのコメントを解除しました。
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse" name="SdpProductStatus" context="/SdpServices/1/Aggregator/Product/Status">
<resource methods="POST">
<inSequence>
<property name="messageType" value="application/json; charset=utf-8;" scope="axis2" type="STRING" />
<property name="ContentType" value="application/json; charset=utf-8;" scope="axis2" type="STRING" />
<property name="productId" expression="json-eval($.productId)" scope="default" type="STRING" />
<property name="customerId" expression="json-eval($.customerId)" scope="default" type="STRING" />
<property name="description" expression="json-eval($.description)" scope="default" type="STRING" />
<property name="time" expression="json-eval($.time)" scope="default" type="STRING" />
<property name="state" expression="json-eval($.state)" scope="default" type="STRING" />
<log />
<property name="time" expression="concat(substring($ctx:time,1,4),'-',substring($ctx:time,5,2),'-',substring($ctx:time,7,2),' ',substring($ctx:time,10,2),':',substring($ctx:time,12,2),':',substring($ctx:time,14,2))" scope="default" type="STRING" />
<script language="js">mc.setProperty("state", mc.getProperty("state").replace("0","deactive")); mc.setProperty("state", mc.getProperty("state").replace("1","active"));</script>
<property name="POST_TO_URI" value="true" scope="axis2" />
<property name="REST_URL_POSTFIX" value="ActiveOrDeactive" scope="axis2" type="STRING" />
<property name="FORCE_HTTP_CONTENT_LENGTH" value="true" scope="axis2" type="STRING" />
<property name="messageType" value="application/json; charset=utf-8;" scope="axis2" type="STRING" />
<property name="ContentType" value="application/json; charset=utf-8;" scope="axis2" type="STRING" />
<header name="Accept" scope="transport" value="application/json" />
<header name="Content-Type" scope="transport" value="application/json" />
<header name="ContentType" scope="transport" value="application/json" />
<payloadFactory media-type="json">
<format>{"productID":"$1","CustomerID":"$2", "Time":"$3","State":"$4","tempData":"$5","Description":"$6","Username":"$7","Password":"$8", "Instruction":"$9"}</format>
<args>
<arg evaluator="xml" expression="$ctx:productId" />
<arg evaluator="xml" expression="$ctx:customerId" />
<arg evaluator="xml" expression="$ctx:time" />
<arg evaluator="xml" expression="$ctx:state" />
<arg evaluator="xml" value="temp" />
<arg evaluator="xml" expression="$ctx:description" />
<arg value="test1" />
<arg value="test1" />
<arg value="create" />
</args>
</payloadFactory>
<log>
<property name="body" expression="json-eval($.)" />
</log>
<send buildmessage="true">
<endpoint>
<address uri="http://10.8.10.10:8080/service1.svc/" />
</endpoint>
</send>
</inSequence>
<outSequence>
<log />
<property name="message" expression="json-eval($.MESSAGE)" scope="default" type="STRING" />
<filter source="json-eval($.STATUS)" regex="-?\d.*">
<then>
<property name="statusCode" value="200" scope="default" type="STRING" />
</then>
<else>
<property name="statusCode" expression="json-eval($.STATUS)" scope="default" type="STRING" />
</else>
</filter>
<property name="messageType" value="application/json" scope="axis2" type="STRING" />
<header name="Accept" scope="transport" value="application/json" />
<payloadFactory media-type="json">
<format>{"productId":$1,"id":"$2","customerId":"$3","status":{"statusCode":$4,"message":"$5"}}</format>
<args>
<arg evaluator="xml" expression="$ctx:productId" />
<arg evaluator="xml" value="55" />
<arg evaluator="xml" expression="$ctx:customerId" />
<arg evaluator="xml" expression="$ctx:statusCode" />
<arg evaluator="xml" expression="$ctx:message" />
</args>
</payloadFactory>
<header name="Content-Type" scope="transport" value="application/json" />
<send />
</outSequence>
</resource>
</api>
そして、これは私がバックエンドで得るものです::
APIソースがある
<jsonobject>....my payload converted to xml...</jsonobject>
ありがとうございました。しかし、私はエラーを発見した、明日の答えを書くだろう '<プロパティ名=" messageType "値="アプリケーション/ json "スコープ=" axis2 "type =" STRING "/>' not 'プロパティ名= "messageType" value = "application/json; charset = utf-8;" scope = "axis2" type = "STRING" /> 'を順番にAPIの最初の行に追加します。 –