繁体   English   中英

如何通过WSO2 ESB发出API请求

[英]How to make an API request through the WSO2 ESB

我已按照本教程中给出的步骤进行操作。

https://docs.wso2.com/display/ESB500/Sending+a+Simple+Message

一切都正确完成,但是当我尝试通过ESB(通过8280端口)调用api时,显示错误代码202。 即使我没有指定任何故障顺序。

我已经正确尝试了每个步骤,并且还确保api的端点正常工作。

我也做了示例...在这里您有我的配置:-端点定义(右键单击示例->端点->创建新端点)-

<endpoint name="QueryDoctorEP" xmlns="http://ws.apache.org/ns/synapse">
    <http method="get" uri-template="http://wso2training-restsamples.wso2apps.com/healthcare/{uri.var.category}"/>
</endpoint>

-我的api定义(右键单击示例-> API Rest->创建新的API Rest)

<?xml version="1.0" encoding="UTF-8"?>
<api context="/healthcare" name="HealthcareAPI" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET" uri-template="/querydoctor/{category}">
        <inSequence>
            <log description="Request Log" level="custom">
                <property name="message" value="Welcome to HealthcareService"/>
            </log>
            <send>
                <endpoint key="QueryDoctorEP"/>
            </send>
        </inSequence>
        <outSequence>
            <send/>
        </outSequence>
        <faultSequence/>
    </resource>
</api>

等待服务器部署配置...请求:(我的偏移量是3)

curl -v http://localhost:8283/healthcare/querydoctor/surgery

在这里你有卷曲的反应

About to connect() to localhost port 8283 (#0)
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8283 (#0)
> GET /healthcare/querydoctor/surgery HTTP/1.1
> User-Agent: curl/7.25.0 (i386-pc-win32) libcurl/7.25.0 OpenSSL/0.9.8u zlib/1.2.6 libssh2/1.4.0
> Host: localhost:8283
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Thu, 26 Jan 2017 16:00:51 GMT
< Transfer-Encoding: chunked
<
[{"name":"thomas collins","hospital":"grand oak community hospital","category":"surgery","availability":"9.00 a.m - 11.00 a.m","fee":7000.0},{"name":"anne clement","hospital":"clemency
 medical center","category":"surgery","availability":"8.00 a.m - 10.00 a.m","fee":12000.0},{"name":"seth mears","hospital":"pine valley community hospital","category":"surgery","availa
bility":"3.00 p.m - 5.00 p.m","fee":8000.0}]* Connection #0 to host localhost left intact
* Closing connection #0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM