首页 > 解决方案 > 为什么我在尝试从 WSO2 ESB 流执行此 REST API POST 请求时收到此错误?

问题描述

我在尝试从 WSO2 ESB 流向外部 REST API 执行 HTTP POST 请求时发现了一些问题。

这是必须在我的 ESB 流程中复制的原始 cURL 调用:

curl -v -X POST -k -H "Content-type: text/plain" -d @fpma_payload.json https://us-central1-fao-gift-app.cloudfunctions.net/fpmaGetData

这是fpma_payload.json文件中包含的有效负载:

{
    "source":"pricingdata",
    "filters": {
        "country_iso3": "KGZ",
        "granularity":"daily",
        "pricing_date_from": "2018-01-01",
        "pricing_date_to": "2018-01-12",
        "commodity":["Пшеница"],
        "measureunit":["килограмм"]
   }
}

请注意,“Content-type: text/plain”是强制性的(否则调用会出错)。

另请注意,商品度量单位字段的值包含(并且是正确的)西里尔字符。

我创建了这个执行上一个调用的 ESB API:

<?xml version="1.0" encoding="UTF-8"?>
<api context="/fpma" name="fpma" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET" protocol="http" uri-template="/insert_prices">
        <inSequence>
            <!--  FPMA data import procedure -->
            <log level="full"/>
            <payloadFactory media-type="json">
                <format>
                    {
                        "source":"pricingdata",
                        "filters": {
                            "country_iso3": "KGZ",
                            "granularity":"daily",
                            "pricing_date_from": "2018-01-01",
                            "pricing_date_to": "2018-01-12",
                            "commodity":["Пшеница"],
                            "measureunit":["килограмм"]
                       }
                    }
                </format>
                <args/>
            </payloadFactory>
            <log level="full"/>

            <!--  <property name="messageType" scope="axis2" type="STRING" value="text/plain"/>-->
            <header name="Content-type" value="text/plain" scope="transport"/>
            <!--<property name="HTTP_METHOD" scope="axis2" type="STRING" value="post"/>-->
            <send>
                <endpoint>
                    <http method="POST" uri-template="https://us-central1-fao-gift-app.cloudfunctions.net/fpmaGetData"></http>
                </endpoint>
            </send>

            <log level="full"/>

            <send/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>

但是电话打不通。

我在 WSO2 上启用了有线日志来分析进出流量,并在我获得的日志中:

TID: [-1234] [] [2018-07-25 17:33:17,933]  INFO {org.apache.synapse.mediators.builtin.LogMediator} -  To: /fpma/insert_prices, MessageID: urn:uuid:ba89498b-4390-4233-8e62-f3977f733602, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body/></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
TID: [-1234] [] [2018-07-25 17:33:17,933]  INFO {org.apache.synapse.mediators.builtin.LogMediator} -  To: /fpma/insert_prices, MessageID: urn:uuid:ba89498b-4390-4233-8e62-f3977f733602, Direction: request, Payload: {
                                        "source":"pricingdata",
                                        "filters": {
                                                    "country_iso3": "KGZ",
                                                    "granularity":"daily",
                                                    "pricing_date_from": "2018-01-01",
                                                    "pricing_date_to": "2018-01-12",
                                                    "commodity":["Пшеница"],
                                                    "measureunit":["килограмм"]
                                           }
                                        } {org.apache.synapse.mediators.builtin.LogMediator}
TID: [-1] [] [2018-07-25 17:33:17,936] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "POST /fpmaGetData HTTP/1.1[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,936] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "Cookie: menuPanel=visible; menuPanelType=main; MSG15300927033010.08314103813905904=true; MSG15300932814920.5357072672721377=true; MSG15300932994690.44521356304801096=true; MSG15300934411460.44113716886259824=true; MSG15300934869410.15746889419679078=true; MSG15300935602530.9837205220752084=true; MSG15300936377690.43597674899579=true; current-breadcrumb=; MSG15300940478590.3560053556575622=true; MSG15300940681790.508915573273117=true; MSG15301076976860.34706595108609606=true; MSG15301077197010.056644649231122=true; MSG15301084435740.15345684552090277=true; MSG15301084696130.5772015484314896=true; MSG15301087328050.3361499060620474=true; MSG15301087720070.6749826290330851=true; MSG15301088151740.19997727205958538=true; MSG15301089280490.3627187142406275=true; MSG15301090365030.7839973796080631=true; MSG15301090629850.6877850318688251=true; MSG15301092307000.5205278144547598=true; MSG15301092531880.4629871774961323=true; MSG15301094361720.6629725843946891=true; MSG15301094574170.27184447405389056=true; MSG15301097803480.10978424797337216=true; MSG15301098008270.12748753081678443=true; MSG15301102268730.3276951744740767=true; MSG15301102641010.6239881066989812=true; MSG15301107274220.04851816448395019=true; MSG15301107683040.07420144905714599=true; MSG15301109639130.5258798677831885=true; MSG15301109919990.9732345788224521=true; MSG15301111621620.6158618286311967=true; MSG15301112702520.4518805398788772=true; MSG15301112870730.8987837551079324=true; MSG15301114031740.9916257091839474=true; MSG15301114591920.4780584053217459=true; MSG15301114931050.1263165319073043=true; MSG15301116230260.5441157330889683=true; MSG15301116934970.8007338031825404=true; MSG15301117305000.5077048305409918=true; MSG15301118677280.6604388733282427=true; MSG15301119036780.09612281376922693=true; MSG15301123345060.44625622334585213=true; MSG15301123582220.712540751694251=true; MSG15301126078670.5501569234109295=true; MSG15301811599960.5313780151427575=true; MSG15301811880220.13415493196561712=true; MSG15301925561190.08439879503282399=true; MSG15301925778900.6224834889627043=true; MSG15301939641600.4419719474155984=true; MSG15301940815160.024600648168317307=true; MSG15301940922840.0442093147518926=true; MSG15301942219450.11962981705444009=true; MSG15301942497810.8521154839422239=true; MSG15301981490230.9979357834630281=true; MSG15301982473000.07660390924643601=true; MSG15301982657640.8850156547023191=true; MSG15301985678950.3949811147024118=true; MSG15301986000360.609438169003127=true; MSG15307852470080.7047537623401262=true; MSG15307852795810.9472304892350244=true; MSG15307858037720.5608585749180316=true; MSG15307858310580.015533643512227968=true; MSG15307869446300.6403458795659791=true; MSG15307869506470.7589557013345228=true; MSG15307869853060.34940288636561356=true; MSG15307871824290.45084322535072874=true; MSG15307876011010.6588657890942881=true; MSG15307876299390.4196503852977894=true; MSG15307876982560.878553309800932=true; MSG15307877247090.06819911960691338=true; MSG15307877982440.4694498774279511=true; MSG15307878304080.41052678083047967=true; MSG15307881743070.13612174112720732=true; MSG15307882018450.0015161872249979114=true; MSG15307942402740.36452474390504064=true; MSG15307942994670.7661679863598515=true; MSG15307944023770.4279540011171803=true; MSG15307949132760.1333882166879682=true; MSG15307949736060.0682408557421641=true; MSG15307950241180.6145789976090101=true; MSG15307951897910.34686891944199283=true; MSG15307954484260.0951732649866116=true; MSG15307955227420.6760530186861446=true; MSG15307961486070.12422224383505354=true; MSG15307964163850.7156300219043767=true; MSG15307965374480.27570454438333003=true; MSG15307968874440.9411234541705256=true; MSG15307978258110.5516310771839682=true; MSG15307979165900.6378810085914935=true; MSG15307982058280.28771861962885603=true; MSG15307985362020.19532266420054023=true; MSG15311253794120.11505182226486232=true; MSG15311254237100.28348410221997955=true; MSG15311260102680.8349296454094678=true; MSG15311260732990.6053739065465301=true; MSG15311268374680.9409739077444785=true; MSG15311268810760.4938667758383042=true; MSG15311271085920.41558603628566915=true; MSG15311271631300.2443971750828594=true; MSG15311273225370.1340123535936234=true; MSG15311273508650.1902542593659058=true; MSG15311274406270.33591228334742873=true; MSG15311274875870.9177559770867882=true; MSG15311313415090.2687600817646535=true; MSG15311316185870.29228299823869175=true; MSG15311386973950.24165283777870905=true; MSG15311387302330.4192024933214493=true; MSG15311387752350.5258465012473292=true; MSG15311395578300.8571685091142072=true; MSG15311413469480.7538616084696782=true; MSG15311417155510.28253970402577544=true; MSG15311417953170.4621782133998883=true; MSG15311424228030.8887328695787063=true; MSG15311424801850.5948530540389352=true; MSG15311425504200.1423661665913205=true; MSG15311425909380.7053391130409361=true; MSG15320926947060.01234042390807999=true; MSG15320928987990.8494923844068988=true; MSG15320929199270.7563797401543695=true; MSG15320929958070.011112167022719333=true; MSG15320933125310.7309137720942638=true; MSG15320945244710.38601299423546165=true; MSG15320948498120.7280840400894509=true; MSG15325068564980.7618584064771339=true; MSG15325068828950.8629230180540267=true; MSG15325069589230.6928354132165143=true; MSG15325075771930.995126924115311=true; MSG15325077502680.7979804606573333=true; MSG15325211950400.4325858902426478=true; MSG15325212133990.37454457962168464=true; MSG15325217699650.49615179216070016=true; MSG15325218064070.7988130482371919=true; MSG15325241101370.16744901824968017=true; MSG15325241364790.9103119215107321=true; MSG15325304068060.8768836587900447=true; MSG15325304540190.8034666119618694=true; MSG15325306505150.5095223558103537=true; MSG15325306857390.3242763669487366=true; MSG15325326019010.17428578778096693=true; MSG15325326087710.6114400931701384=true; region3_registry_menu=none; region4_monitor_menu=none; region5_tools_menu=none; MSG15325326826770.3136728766202924=true[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "Upgrade-Insecure-Requests: 1[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "Accept-Encoding: gzip, deflate[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "Content-Type: application/json[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "Transfer-Encoding: chunked[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "Host: us-central1-fao-gift-app.cloudfunctions.net[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "Connection: Keep-Alive[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "13c[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "{[\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,937] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9]    [0x9]"source":"pricingdata",[\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9]    [0x9]"filters": {[\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9][0x9][0x9]    "country_iso3": "KGZ",[\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9][0x9][0x9]    "granularity":"daily",[\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9][0x9][0x9]    "pricing_date_from": "2018-01-01",[\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9][0x9][0x9]    "pricing_date_to": "2018-01-12",[\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9][0x9][0x9]    "commodity":["[0xd0][0x9f][0xd1][0x88][0xd0][0xb5][0xd0][0xbd][0xd0][0xb8][0xd1][0x86][0xd0][0xb0]"],[\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9][0x9][0x9]    "measureunit":["[0xd0][0xba][0xd0][0xb8][0xd0][0xbb][0xd0][0xbe][0xd0][0xb3][0xd1][0x80][0xd0][0xb0][0xd0][0xbc][0xd0][0xbc]"][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9][0x9]   }[\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[0x9][0x9][0x9][0x9][0x9]}[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "0[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:17,938] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 << "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,372] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "HTTP/1.1 500 Internal Server Error[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,373] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "Content-Type: text/plain; charset=utf-8[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,373] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "X-Content-Type-Options: nosniff[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,374] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "X-Cloud-Trace-Context: 15339efb91222a704ab9eef98da7cc25;o=1[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,374] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "Date: Wed, 25 Jul 2018 15:33:23 GMT[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,374] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "Server: Google Frontend[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,375] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "Content-Length: 36[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,375] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "Alt-Svc: quic=":443"; ma=2592000; v="44,43,39,35"[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,376] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2018-07-25 17:33:23,376] DEBUG {org.apache.synapse.transport.http.wire} -  HTTPS-Sender I/O dispatcher-1 >> "Error: could not handle the request[\n]" {org.apache.synapse.transport.http.wire}

最后有这个错误:

HTTPS-Sender I/O dispatcher-1 >> "Error: could not handle the request[\n]" {org.apache.synapse.transport.http.wire}

查看日志可能是什么问题?我不确定执行调用的中介链是否正确,或者问题是否与西里尔字符有关(查看线路日志,发送中介似乎将这些字符翻译为:

"commodity":["[0xd0][0x9f][0xd1][0x88][0xd0][0xb5][0xd0][0xbd][0xd0][0xb8][0xd1][0x86][0xd0][0xb0]"], 
                                                                                                                                                     "measureunit":["[0xd0][0xba][0xd0][0xb8][0xd0][0xbb][0xd0][0xbe][0xd0][0xb3][0xd1][0x80][0xd0][0xb0][0xd0][0xbc][0xd0][0xbc]"]

如何尝试修复它并正确执行此 REST 调用?

标签: jakarta-eewso2wso2esbesbwso2ei

解决方案


在调解员之后,您不能有任何调解send员。您可以登录outSequencesend返回对客户端的响应


推荐阅读