Alessandro Santos
Alessandro Santos

Reputation: 51

WSO2 Problems to access on port 8082

1) I define my rest service: MyRestNode.png My rest services on Node

2) I created my service on eclipse studio dev tools: Eclise StudioDevTools

3) I Deploy to wso2, my EndPoint: EndPoint on Eclipse

4) API API

When I call curl on terminal: curl -v -i -H "Content-Type: application/json" -H "Accept: application/json" http://192.168.10.178:8280/mapa/1/101

Shows the message:

Trying 192.168.10.178...

> Connected to 192.168.10.178 (192.168.10.178) port 8280 (#0)
> GET /mapa/1/101 HTTP/1.1
> Host: 192.168.10.178:8280
> User-Agent: curl/7.43.0
> Content-Type: application/json
> Accept: application/json
> HTTP/1.1 404 Not Found
> HTTP/1.1 404 Not Found
> Date: Mon, 30 Jan 2017 12:38:51 GMT
> Transfer-Encoding: chunked
> Connection #0 to host 192.168.10.178 left intact

5) API XML:

    <?xml version="1.0" encoding="UTF-8"?>
<api context="/mapa" name="MapaServicesAPI" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET" uri-template="/mapa/{codigoAgenteCampo}/{codigoMunicipio}">
        <inSequence>
            <log description="Request Log" level="custom">
                <property name="message" value="&quot;Teste com o mapa services node&quot;"/>
            </log>
            <send>
                <endpoint key="MapaRestEP"/>
            </send>
        </inSequence>
        <outSequence>
            <send/>
        </outSequence>
        <faultSequence/>
    </resource>
</api>

6) Endpoint

<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="MapaRestEP" xmlns="http://ws.apache.org/ns/synapse">
    <http method="get" uri-template="http://localhost:8000/rest/rotas/completa/{codigoAgenteCampo}/{codigoMunicipio}"/>
</endpoint>

Upvotes: 0

Views: 499

Answers (1)

Jorge Infante Osorio
Jorge Infante Osorio

Reputation: 2153

****************************UPDATE: ****************************************

correct endpoint configuration:

<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="MapaRestEP" xmlns="http://ws.apache.org/ns/synapse">
    <http method="get" uri-template="http://localhost:8000/rest/rotas/completa/{uri.var.codigoAgenteCampo}/{uri.var.codigoMunicipio}"/>
</endpoint>

****************************END UPDATE************************************

The URL you need to call is api context + uri template. In this case:

http://localhost:8280/mapa/mapa/1/101

In my scenario I mock the backend json response with soapui.

My proxy:

<?xml version="1.0" encoding="UTF-8"?>
<api context="/mapa" name="MapaServicesAPI" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET" uri-template="/mapa/{codigoAgenteCampo}/{codigoMunicipio}">
        <inSequence>
            <log description="Request Log" level="custom">
                <property name="message" value="&quot;Teste com o mapa services node&quot;"/>
                <property name="codigoAgenteCampo" expression="get-property('uri.var.codigoAgenteCampo')"/>
                <property name="codigoMunicipio" expression="get-property('uri.var.codigoMunicipio')"/>
            </log>
            <send>
                <endpoint key="MapaRestEP"/>
            </send>
        </inSequence>
        <outSequence>
            <log level="full"/>
            <send/>
        </outSequence>
        <faultSequence/>
    </resource>
</api>

The endpoint:

<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="MapaRestEP" xmlns="http://ws.apache.org/ns/synapse">
    <http method="get" uri-template="http://localhost:8000/rest/rotas/completa/{uri.var.codigoAgenteCampo}/{uri.var.codigoMunicipio}"/>
</endpoint>

The curl response:

D:\integ\wso2am-2.0.0\bin>curl -v -i -H "Content-Type: application/json" -H "Accept: application/json" http://localhost:8283/mapa/mapa/1/101
* 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 /mapa/mapa/1/101 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
> Content-Type: application/json
> Accept: application/json
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
Content-Type: application/json; charset=UTF-8
< Date: Tue, 31 Jan 2017 05:50:45 GMT
Date: Tue, 31 Jan 2017 05:50:45 GMT
< Transfer-Encoding: chunked
Transfer-Encoding: chunked

<
{
        data:[
{
"id":1
},
{
"id":2
}
]
        }* Connection #0 to host localhost left intact
* Closing connection #0

And the wso2 ESB log:

[2017-01-31 00:50:45,409]  INFO - LogMediator message = "Teste com o mapa services node", codigoAgenteCampo = 1, codigoMunicipio = 101
[2017-01-31 00:50:45,421]  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:56597c92-d5fe-4003-b25a-d11b60dd28df, Di
rection: response, Payload: {
        data:[
{
"id":1
},
{
"id":2
}
]
        }

Upvotes: 2

Related Questions