1
votes

When i try to call a remote web-service using a dynamic uri-template in send mediator, i receive this error. The url of the resource to call is : https://ec.europa.eu/esco/api/resource/skill?uri=http://data.europa.eu/esco/skill/a59708e3-e654-4e37-8b8a-741c3b756eee&language=it

For this purpose i use below in-sequence and out-sequence:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="EscoInSequence" xmlns="http://ws.apache.org/ns/synapse">
    <property expression="$url:resource" name="resource" scope="default"
        type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property expression="$url:uri" name="uri"
        scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property expression="$url:language" name="language" scope="default"
        type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property
        expression="concat('https://ec.europa.eu/esco/api/resource/',$ctx:resource,'?uri=',$ctx:uri,'&amp;language=',$ctx:language)"
        name="UrlToEsco" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
    <payloadFactory media-type="text">
        <format>$1</format>
        <args>
            <arg evaluator="xml" expression="$ctx:UrlToEsco"
                literal="false" xmlns:ns="http://org.apache.synapse/xsd"/>
        </args>
    </payloadFactory>
    <send>
        <endpoint>
            <http method="GET" uri-template="{UrlToEsco}"/>
        </endpoint>
    </send>
    <enrich>
        <source clone="true" type="body"/>
        <target action="child" property="rispostaEsco" type="property"/>
    </enrich>
    <loopback/>
</sequence>

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="EscoOutSequence" xmlns="http://ws.apache.org/ns/synapse">
    <send/>
</sequence>

When i try to call my api using a static uri ( https://ec.europa.eu/esco/api/resource/skill?uri=http://data.europa.eu/esco/skill/a59708e3-e654-4e37-8b8a-741c3b756eee&language=it ) i haven't problem, but when i use UrlToEsco property i obtain this error :

TID[-1234] [EI] [2019-09-03 12:31:53,029] ERROR {org.apache.synapse.core.axis2.Axis2Sender} - Unexpected error during sending message out org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:86) org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:116) org.apache.axis2.client.OperationClient.execute(OperationClient.java:149) org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:603) org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:85) org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:547) org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:384) org.apache.synapse.endpoints.HTTPEndpoint.send(HTTPEndpoint.java:85) org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:123) org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:108) org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:70) org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158) org.apache.synapse.rest.Resource.process(Resource.java:364) org.apache.synapse.rest.API.process(API.java:399) org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:123) org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:101) org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69) org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:303) org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:92) org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337) org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158) org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) java.lang.Thread.run(Thread.java:745)

1
If your question has been answered, please make sure to accept an answer for future references.ophychius

1 Answers

0
votes

Uri templates variables should be named as follows uri.var.[parameterName] so for example uri.var.UrlToEsco.

Try renameing your property

<property expression="concat('https://ec.europa.eu/esco/api/resource/',$ctx:resource,'?
    uri=',$ctx:uri,'&amp;language=',$ctx:language)"
    name="uri.var.UrlToEsco" scope="default" type="STRING"
 xmlns:ns="http://org.apache.synapse/xsd"/>

And using it like so:

    <send>
        <endpoint>
            <http method="GET" uri-template="{uri.var.UrlToEsco}"/>
        </endpoint>
    </send>