WSO2 ESB - Dynamic value for proxy parameters (transport) - proxy

I need to be able to specify a dynamic value for proxy parameter. Actually, I have to specify each parameter with complete URL like :
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
I see some samples with property mediator and I guess it's working for next proxies but the problem here is that I need to change the proxy parameters value before its execution I think. I tried with a "trigger" proxy calling a custom mediator which change SynapseConfiguration of required proxy but this wasn't working.
Is there a way to replace these fixed value with lookups to create some deployment configuration ?
Many thanks.

You can check out this post How to dynamically route message in WSO2 ESB based on XML configuration file for an example how to dynamically set values in a proxy sequence.
You can do something this:
<parameter name="transport.vfs.FileNamePattern">
<script language="js">mc.getProperty('MY_DYNAMIC_VALUE')</script>
</parameter>
I am not sure this will help you much, as I suspect that the vfs parameters are set when initializing the proxy and not on the fly. If you give it a try, if possible please post back to this thread if it works or not.
Regards, nidkil

The Parameters in the Proxy service definitions are service level Parameters which is in the Axis2Service Configuration . They are used when you are initialing the Axis2Service in this case its the Synapse/WSO2 ESB proxy service. So you can't change the parameters dynamically on the fly.
But i can suggest following approach. It might or might not applicable to your scenario.
Have set of VFS proxies that listen for separate locations. Each will look at a give file extension. (one for .txt one for .foo etc..)
Use another generic vfs proxy to copy files to correct places dynamically(which accepts any extension).(You can use vfs sender).
Hope this helps.
cheers,
Charith

Related

Handle different URL patterns in Zuul filters

I have two types of URL patterns as below.
/gateway/secure/api/user/getUser
/gateway/nonsecure/api/user/getUser
(Context root of zuul gateway application is gateway)
Using zuul filters I'm trying to implement two different logics based on secure and nonsecure URL patterns. I've written a pre-filter and seems it's not even executing that filter for above URL patterns. I could see gateway is throwing 404. When I try to access microservice without secure or nonsecure its working as expected. Below are the property changes I've done so far.
Context root of downstream microservice is api/user
zuul.prefix=/secure
zuul.routes.user.path=/api/user/**
zuul.routes.user.service-id=user
zuul.prefix=/nonsecure
zuul.routes.user.path=/api/user/**
zuul.routes.user.service-id=user
I've already tried by giving zuul.prefix and it seems prefix is setting as globally and cant apply only for specific routes. How can I achieve this? Can anyone please advice.Thanks
As you noted, the zuul.prefix property affects all mappings and can only be defined once. So, drop the zuul.prefix property and add the corresponding prefix to each zuul.routes.*.path properties:
zuul.routes.user.path=/secure/api/user/**
zuul.routes.user.service-id=user
zuul.routes.user.path=/nonsecure/api/user/**
zuul.routes.user.service-id=user
Note that, according to the documentation:
zuul.stripPrefix only applies to the prefix set in zuul.prefix. It does not have any effect on prefixes defined within a given route’s path.

See parameters that are overridden from TeamCity template

Is there a way to see TeamCity configurations that override parameter defined in template?
I don't think so. What's worked for me in the past was to search through the project files on the filesystem. If you have many build configs, this will be faster than opening each of them in the GUI.
Search for something like this:
<param name="myParamInheritedFromTemplate" value="myOverrideValue" />
in <TeamCity data directory>/config/projects/**/*.xml. If it's absent in an XML file, that build config just inherits the value. If it's present, it overrides it.
It's hacky but it's quick.
There is a feature request https://youtrack.jetbrains.com/issue/TW-21212, please vote. Current workaround are to either search the raw XML files with the settings stored under TeamCity Data Directory on the server as #sferencik suggested, or use REST API to get settings of all the build configurations and search for the parameter there. Let me know if you need help on any of these.

Apigee - modify target path when using targetserver

I have an API proxy that needs to be able to modify the path component of the eventual Target URL. This appears fairly straightforward in cases where there's a defined Target Endpoint URL for the entire proxy but we are using TargetServers and VirtualHosts which apparently are assigned after the TargetEndpoint PreFlow
I have a JS function in the Target Endpoint PreFlow and get unspecified JS errors when I attempt to modify context.targetRequest.path. Attempts to modify the path part of the incoming proxy during Proxy PreFlow also failed.
Dumping the values of targetRequest gives:
host=empty
path=/v2/cat1/cat2/?param=......
url=Identical to path!
The only variable that I've been able to "successfully" modify is targetRequest.url to achieve my aim but to do that I must assign the whole thing, including the protocol and host which aren't known to me!
Anyone know how to do this? I essentially want to modify the path replacing "/?" with just "?"
Thanks
You can also set it up at the target endpoint by leveraging the Path element along with TargetServer:
<TargetEndpoint>
...
<HTTPTargetConnection>
<LoadBalancer>
<Server name="TargetServerABC"/>
</LoadBalancer>
<Path>/v1/YourPathHere/json.ws?{flow.company.queryparams}</Path>
</HTTPTargetConnection>
</TargetEndpoint>
Note TargetServerABC needs to be a TargetServer created using the following these steps.
There seems to be an issue with manipulating target.path (there is a bug report open in Apigee for this).
The current workaround is to rewrite the entire URI either in the AssignMessage policy using the AssignVariable block:
<AssignVariable>
<Name>target.url</Name>
<Value>http://example.com/mypath?param=value&variable={apigee.variable}</Value>
<Ref/>
</AssignVariable>
or you can do it in Javascript with the context.setVariable function:
context.setVariable("target.url", mycompleteurl);

Can one encapsulate Xml Rpc call within an winhttp object?

Is it possible to encapsulate an Xml Rpc call within an Winhttp 5.1 object ?
The reason I am asking this is because as far as I know Winhttp automatically resolves any proxy settings which I do not know beforehand for each user. I also don't want to set the proxy for each xml rpc call I make by hand since my users are all over the country.
Thx for any suggestions.
This helped me :
var url = new Uri("http://www.example.com/");
string ProxyUrl = WebRequest.DefaultWebProxy.GetProxy(url).ToString();

How to use proxy with TwitterConsumer class from DotNetOpenAuth.ApplicationBlock

I am currently implementing SSO with DotNetOpenAuth. However, when working locally, I need to send requests via a proxy. I am happy to do this programatically or via config setting but I am struggling to find where to add it to the TwitterConsumer class supplied in the application block.
Any help much appreciated
So the easiest way is probably to set the proxy in your .config file or programmatically using WebRequest.DefaultWebProxy.
Alternatively, just set the proxy properties on the HttpWebRequest objects like any other .NET request. For those request objects you don't see because DotNetOpenAuth creates and issues them automatically, you can implement IDirectWebRequestHandler and pass that into DNOA so you get to intercept each outgoing HttpWebRequest, but that is considerably harder and probably not necessary considering your other options.

Resources