WSO2 EI: HTTPSender Невозможно отправить ViaPost на URL - PullRequest
0 голосов
/ 02 марта 2020

Я использую WSO2 EI 6.4.0

Я создал API, который будет вызывать внешний URL для получения информации. Ниже приведен мой код для API в WSO2 EI

<?xml version="1.0" encoding="UTF-8"?>
<api context="/api/seqadd" name="seq_mediator" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST GET">
<inSequence>
<property  name="basicAuth" scope="default" type="STRING" value="xxxxx"/>
    <property name="grant_type" scope="default" type="STRING" value="client_credentials"/>
    <property name="scope" scope="default" type="STRING" value="vvv/.drer"/>


<payloadFactory media-type="xml">
<format>
<root>
<grant_type>$1</grant_type>
<scope>$2</scope>
</root>
</format>
<args>
<arg1 evaluator="xml" expression="$ctx:grant_type"/>
<arg2 evaluator="xml" expression="$ctx:scope"/>
</args>
</payloadFactory>


<property expression="fn:concat('Basic ', get-property('basicAuth'))" name="Authorization" scope="transport" type="STRING"/>
<property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded"/>

<property expression="$body/*" name="payload created"/>
<property expression="get-property('axis2','REST_URL_POSTFIX')" name="resource" scope="default" type="STRING"/>
<property action="remove" name="REST_URL_POSTFIX" scope="default"/> 

<call blocking="true">
<endpoint name="URL">

<http method="post" uri-template="https://example.com/login/v1.0/token"/>
</endpoint>
</call>

<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<property expression="json-eval($.access_token)" name="Authorization" scope="default" type="STRING"/>
<property expression="fn:concat('Bearer ', get-property('Authorization'))" name="Authorization" scope="transport" type="STRING"/>

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

При вызове этого API я получаю сообщение об ошибке ниже

[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> GET /api/seqadd HTTP/1.0
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> X-Forwarded-Host: example.com
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> X-Forwarded-Server: example.com
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> Connection: close
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> Content-Type: application/x-www-form-urlencoded
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> User-Agent: PostmanRuntime/7.22.0
[2020-03-02 14:36:52,830] [EI-Core] DEBUG - headers http-incoming-2 >> Accept: */*
[2020-03-02 14:36:52,830] [EI-Core] DEBUG - headers http-incoming-2 >> Cache-Control: no-cache
[2020-03-02 14:36:52,830] [EI-Core] DEBUG - headers http-incoming-2 >> Accept-Encoding: gzip, deflate, br
[2020-03-02 14:36:52,983] [EI-Core] DEBUG - header >> "POST /login/v1.0/token HTTP/1.1[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Content-Type: application/x-www-form-urlencoded; charset=UTF-8[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Accept: */*[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Authorization: Basic xxxxx[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Cache-Control: no-cache[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "X-Forwarded-Host: example.com[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "X-Forwarded-Server: example.com[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "User-Agent: Axis2[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "Host: example.com[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "Transfer-Encoding: chunked[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "[\r][\n]"
[2020-03-02 14:36:52,991] [EI-Core] DEBUG - content >> "53[\r][\n]"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "grant_type=client_credentials&scope=vvv%2F.drer"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "[\r][\n]"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "0"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "[\r][\n]"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "[\r][\n]"
[2020-03-02 14:36:53,001] [EI-Core] DEBUG - header << "HTTP/1.1 404 Not Found[\r][\n]"
[2020-03-02 14:36:53,001] [EI-Core] DEBUG - header << "HTTP/1.1 404 Not Found[\r][\n]"
[2020-03-02 14:36:53,002] [EI-Core] DEBUG - header << "Cache-Control: private[\r][\n]"
[2020-03-02 14:36:53,002] [EI-Core] DEBUG - header << "Strict-Transport-Security: max-age=31536000; includeSubDomains[\r][\n]"
[2020-03-02 14:36:53,002] [EI-Core] DEBUG - header << "X-Content-Type-Options: nosniff[\r][\n]"
[2020-03-02 14:36:53,003] [EI-Core] DEBUG - header << "Set-Cookie: x-ms-gateway-slice=prod; path=/; SameSite=None; secure; HttpOnly[\r][\n]"
[2020-03-02 14:36:53,003] [EI-Core] DEBUG - header << "Date: Mon, 02 Mar 2020 14:36:52 GMT[\r][\n]"
[2020-03-02 14:36:53,003] [EI-Core] DEBUG - header << "Content-Length: 0[\r][\n]"
[2020-03-02 14:36:53,003] [EI-Core] DEBUG - header << "[\r][\n]"
[2020-03-02 14:36:53,006] [EI-Core]  INFO - HTTPSender Unable to sendViaPost to url[https://example.com/login/v1.0/token]
org.apache.axis2.AxisFault: Transport error: 404 Error: Not Found
        at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:371)
        at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:200)
        at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:81)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:459)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:286)
        at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
        at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:441)
        at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:227)
        at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
        at org.apache.synapse.message.senders.blocking.BlockingMsgSender.sendReceive(BlockingMsgSender.java:490)
        at org.apache.synapse.message.senders.blocking.BlockingMsgSender.send(BlockingMsgSender.java:382)
        at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:88)
        at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:85)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:547)
        at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:384)
        at org.apache.synapse.endpoints.HTTPEndpoint.send(HTTPEndpoint.java:85)
        at org.apache.synapse.mediators.builtin.CallMediator.handleBlockingCall(CallMediator.java:164)
        at org.apache.synapse.mediators.builtin.CallMediator.mediate(CallMediator.java:119)
        at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:108)
        at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:70)
        at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
        at org.apache.synapse.rest.Resource.process(Resource.java:351)
        at org.apache.synapse.rest.API.process(API.java:399)
        at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:135)
        at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:113)
        at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:71)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:303)
        at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:92)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337)
        at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Я также добавил SSL-сертификат для URL-адреса токена , Может кто-нибудь, пожалуйста, руководство. Я могу получить URL-адрес токена от Почтальона. Я не понимаю, что может go здесь не так, так как это обычный API, и я ранее также использовал его для других URls.

Спасибо

...