I am considering building a web server which routes requests by matching the url to a regex from a list of services that define a regEx property - the first service to match the url handles the request.
I am looking for advice. Has anyone done anything like this? Does using regexs like this sound like a bad idea? If so, what are the possible side effects?
Yes it is a little bad idea. You do not need to reinvent the wheel. For a web server, you will have probably basic requests, /users/all/phones or /items/cool/ascending/top10.. and you will not need advanced regular expressions. Even if you need, a good library Express handles them too. Have a look at ExpressJS Routing, it is already set and probably optimized, so you will not need to hassle with your own routing code.
Related
My C++ program launches Internet Explorer (it works with IE6 up to IE10) to display some web page on the Internet; I have no way to modify the web page. The web page references a JavaScript file (using a <script> tag in the HTML markup) - a copy of the swfobject JavaScript library. I'd like the web page to use a custom copy of this file which I provide.
I came up with two possible ways to tackle this
Write a proxy server which Internet Explorer connects to; the proxy fetches the actual data and then rewrites the HTML so that my own copy of swfobject is referenced. This is unfortunately quite a bit of work, and probably won't work with https. I could live without support for https for now.
Implement a asynchronous protocol plugin for Internet Explorer which intercepts all http requests. I know that the JavaScript file is always retrieved using http, so I could intercept accesses to the swfobject JavaScript file and yield my own file instead. Alas, this seems to be impossible as well, a Microsoft support page explains
Internet Explorer ignores naive attempts to overwrite HKEY_CURRENT_ROOT\PROTOCOLS\Http with a value other than the CLSID for
This sounds like hooking 'http' with a custom protocol handler won't work; in any case, this approach would also be problematic in case there is an existing http protocol handler.
Is there a better way to solve this than either of these two?
Depending on the complexity of your requirements, Fiddler may be a useful alternative to a custom proxy since it can automatically rewrite both requests and responses and can be a quick way of scripting what you want.
It also works well with HTTPS, so that part is "free".
Want to have Fiddler automatically rewrite requests and responses, add or remove headers, or flag/ignore sessions based on rules you specify? Check out the FiddlerScript Cookbook
Here is a link to the cookbook
If you need to embed it, it can also be embedded as FiddlerCore.
As #MSalters points out below, the Fiddler's optional SSL interception is something you should consider the trade-offs of before using it. It's documented here and I've written up a short summary of how it works in this answer.
Just shooting down an idea, it's possible to hook the WinSock send() and recv() function in your own process. This is a kind of man in the middle.. This solution has a high complexity drawback tho.
Easy, just translate the URL. Change the swfobject URL to a file:// URL, pointing at your copy.
(You're not actually launching IExplorer.EXE, are you? That's not how you're supposed to open web pages. You either launch a URL with ShellExecute, leaving the browserchoice to the user, or you embed MSHTML, IE's core, in your own app. Internet Explorer isn't part of Windows and may be absent, eg on Windows N.)
I am new to Enyo and web services. I am looking to build a web page with Enyo that will require use of Echonest. Can anyone help me understand how to connect to the Echonest service from inside Enyo and whether to use SOAP, REST, or something else?
I assume you are talking about the Echo Nest found here: http://the.echonest.com ?
Briefly glancing at their API, you may not have to use SOAP or REST since everything is accessible with simple GET requests through the Web service. It looks like the hardest part of using their API will be generating OAuth signatures for authenticated requests.
As far as the enyo.WebService, http://enyojs.com/api/#enyo.WebService, goes, you should be able to include the kind, set the URL and call the .send() method on it. Then you response handler would get the data back (I recommend json) so you can do what you will with it.
Another option would be to use enyo.Ajax, http://enyojs.com/api/#enyo.Ajax, directly. enyo.WebService wraps that and provides a familiar (to Enyo 1 developers) way to use it.
I'm contemplating using Camel for my project and would like to know if it's feasable or camel is not a good choice.
I need multiple clients running same exact application to exchange information via web services (CXF or AXIS). The exchange will go through a central hub that will do a content based routing from one client to the other and will also log this communication in the database. The hub will also route one client's response to another when the responses come in. There could be a large amount of these exchanges going on from multiple clients.
The webservices are exactly the same so I don't need to integrate different systems.
I just need a routing mechanism and something that would control volume. Also ease of calling/accepting web service calls is important.
We are a Java/JBoss shop.
Is Camel a fitting solution for this problem or is it an overkill or is there anything else that would fit this requirement better?
I would greatly appreciate your help.
Thank you
Nadia
Yeah Camel can sit as this hub and route messages.
It support the EIP patterns
http://camel.apache.org/eip
There is plenty of components related to HTTP and WS
http://camel.apache.org/cxf
http://camel.apache.org/http
http://camel.apache.org/jetty
http://camel.apache.org/cxf
http://camel.apache.org/spring-web-services.html
And here is a little CXF proxy example
http://camel.apache.org/cxf-proxy-example.html
PS: There is a apache-camel tag which most people use for Camel questions
this is only loosely programming related.
I wrote myself a shellscript, that extracts all acronyms from a text and writes them to a file. Now I would like to process that file to add the definitions.
My first google hit suggested using curl and the dict:// url scheme. However I am behind a proxy, which does not seem to allow that.
Does any of you know a service that is similar to the dict:// but is provided via HTTP?
Ideally it would be restful since messing around with SOAP seems somewhat bloated for this task.
There are plenty of Dictionary API services listed on http://www.programmableweb.com
What do you use as a test client for your stateful web services? Is it possible to use SoapUI? Are there best practices in this area?
You can do what's called a "Property Transfer" in SoapUI. For example, all our web services have to first call an authentication web service and obtain an authentication token.
I've set this up in SoapUI so that the returned auth token from the auth service is passed on to subsequent requests. It seems to work pretty well, but unless I'm missing a trick I wouldn't like to set it up for a lot of web services (i.e. you have to have an entry for each call you want to transfer data to / from).
Yeah, building SoapUI tests is slow, repetitive work. We didn't discover it until rewriting the SOAP server, and it makes great unit and system tests, but is s.l.o.w to create them.
Oh, and watch out for the memory leaks. Save very frequently. When you run out of memory, you can't save anymore. That sucks a little.
The property transfer stuff is awesome - you can have different scopes (test, request, global), and you can use GroovyScript to do dynamic stuff (like look up a particular date related to today's date, and so on).
With a properly formatted WSDL file, it will generate template requests for you, but you'll still need to tweak them a fair bit - or at least, I did.
I don't know whether it's practical to do this with SoapUI, but I've done things like this with both iTKO LISA and Parasoft SOATest. It wasn't for testing stateful web services, but simply executing multiple testing steps, storing results that are used in following steps. Both LISA and SOATest have the ability to define steps in the GUI that can store pieces of responses that are used in later requests.