Reputation: 173
How can I set the endpoint address dynamically?
I set endpoint address in a property at runtime, and need to replace the URI of endpoint address with its value.
How can I set the URI value of address with this value?
Upvotes: 6
Views: 8309
Reputation: 46
Another way to dynamically change the target endpoint url is through the use of the REST_URL_POSTFIX property.
Upvotes: 0
Reputation: 5083
This method is worked for me correctly.
I need to create bellow dynamic url
http://localhost:8787/{dynamic parameter}
Inside the end point url is like this
http://localhost:8787/{uri.var.servicepath}
Set "test" variable as my dynamic parameter (If you need to set Expression value set it). Set "test" value inside the property mediator.(I did this insideproxy service)
<property name="uri.var.servicepath" scope="default" type="STRING" value="test"/>
create endpoint
In here I created HTTP End point
<endpoint name="ServiceEP" xmlns="http://ws.apache.org/ns/synapse">
<http method="post" uri-template="http://localhost:8787/{uri.var.servicepath}"/>
</endpoint>
Then add this endpoint inside your Proxy service or API
<send>
<endpoint key="ServiceEP"/>
</send>
Finally your proxy look like this
<inSequence>
<property name="uri.var.servicepath" scope="default" type="STRING"
value="test"/>
<send>
<endpoint key="SurepayVASAppsEP"/>
</send>
</inSequence>
Like this you can change every url parameter.Ex-:
http://{uri.var.hostname}:{uri.var.port}/{uri.var.servicepath}
Upvotes: 0
Reputation: 186
You can create your endpoint like
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="MyEndpoint">
<http uri-template="{uri.var.full}?f={uri.var.f}{+uri.var.extra}" method="put">
</http>
</endpoint>
Then before calling the endpoint 'MyEndpoint' set the properties .. the properties, to be parsed for an endpoint must begin with uri.
I also found out, that if you put a + before the property name, it doesn't URI encode it, so it's handy for creating parameters on the fly.. otherwise for known parameters, you can do like above for paramameter f
so .. something like
<property name="uri.var.full" value="http://jarhedz.com/viewtopic.php"/>
<property name="url.var.f" value="2"/>
<property name="uri.var.extra" value="&t=39"/>
<send>
<endpoint key="MyEndpoint"></endpoint>
</send>
should bring you to the url http://jarhedz.com/viewtopic.php?f=2&t=39
(btw just as a note, if you're using the web editor, it'll complain about the & .. its buggy as hell .. save it as
&
.. and that saves it as & or set the property using javascript )
Upvotes: 5
Reputation: 1109
When the server doesn't publish its WSDL, see Myobis comment here. Tried addPort without success.
Upvotes: 0
Reputation: 9692
Use Header meditaor to set "to" header and use default endpoint..Check this post for sample.
Upvotes: 2
Reputation: 1753
Use header mediator to set the "To" Address header with the value you extract from your assigned property.
Upvotes: 1