How to relay request in as3? - apache-flex

I need to pass along an incoming xml post request using as3? Is there a simple way to just pass that request through an as3 application? I don't want to do anything with the request other than send it along to its destination.

I'm not sure what exactly you're asking (some code would be helpful) but in the meantime I think these could be helpful to you:
AS3 - How do you receive parameters in a swf from a GET request?
Passing params to an external swf via loader

Related

What HTTP method should be used to execute a (Java) program through a REST API?

I want to invoke a (Java) program that e.g. executes a batch file. That execute command should be invoked through a REST API. Do I just use POST to transmit a json string with e.g. {"command": "do"}? What HTTP method should I use or what is the best solution to do this?
The simple answer: it is okay to use POST.
Advanced answer: how would you do it with a website? You'd probably have an HTML page with a form in it, where the form would allow you to collect whatever information you happen to need from the operator. When the operator hit the submit button, all that information would be converted into an application/x-www-form-urlencoded byte sequence, and sent off to the server in the HTTP request.
The HTTP method used by the request would be the one specified by the method attribute of the form.
In the HTML world, that means that we're looking at GET or POST.
GET suggests (but does not promise) that the result of running the program on some collection of form data produces a representation that can be cached and re-used the next time that same form data is used.
If that doesn't make sense, if you prefer to run the program again rather than re-using a previous result, if you want the side effects of running the program each time, then you probably want POST.
The fact that your server happens to respond to this request by running a java program (or any kind of program) is an accident of your implementation. HTTP methods are about the semantics of the request - what each request means.
The technical details of how you implement your handler for a particular request are deliberately hidden behind the facade that is the uniform interface.

Check if a webservice exists

Could someone please be kind enough to show me the best way to determine if a webservice (ASP.NET) exists at a given URL?
I assume an approach will be something along the lines of issuing a request using System.Net.Webclient but how could I determine if it is a valid webservice and what sort of request should I issue?
EDIT: To add a bit more context I am determining if a webservice exists because I am attempting to build a generic tool that uses arbitrary webservices.
The only way IMHO to be sure the service is up is to be able to call an innocuous method on the service and verify the response. Retrieving the WSDL is not sufficient.
There is a similar SO question on this here:-
How do I test connectivity to an unknown web service in C#?
I would ask for WSDL document. If you get it back it means that the service exists and you can check to WSDL for implemented methods.
Consider reading about WS-Discovery
http://docs.oasis-open.org/ws-dd/discovery/1.1/wsdd-discovery-1.1-spec.html

Which one to use Http Handler or Http Module

We want to do something like we have to execute some piece of code in each request to the application. We want to use this same code in multiple applications.
What this code will do is, this will check the incoming request and according to some conditions it will decide whether it has to redirect or not.
So while searching i found that we can use either http handler or http module. But i am not sure about which one has to chose in this case? Please give your suggestions.
HttpModule in this case. It sits in the pipeline where you can inspect each and every request.
How To Create an ASP.NET HTTP Module Using Visual C# .NET
http://support.microsoft.com/kb/307996
HttpHandler is altogether different thing. If you implement HttpHandler for existing file types such as .aspx etc, you will have implement what is already implemented by ASP.NET runtime which is beyond the scope of your requirement.

Proper way to abort a web-service request in ASP.NET?

We have various web-services which accept requests, but there are periods in the day for some of the services where we do not want to accept requests. (I won't go into why at the moment but it is a requirement).
In these cases I'd like to abort the request as it is being received and am wondering the best way to do this and where is the most appropriate place in the ASP.NET pipeline.
I am currently returning back a status of ServiceUnavailable in the BeginRequest in the global.aspx.
Is the the correct way to implement this type of functionality or is there a better alternative. (_webState is an internal variable we use for the current state of the service)
if (_webState != WebStates.Runnable)
{
Response.StatusCode = (int)System.Net.HttpStatusCode.ServiceUnavailable;
Response.Write("<p>The Service is not available to accept requests</p>");
Response.End();
}
I think the correct way is to create a custom HTTP module as an extension of ASP.NET request handling pipeline. In this module you will be able to refuse connections according to needed strategy. ServiceUnavailable is a standard way of going, we've done this in same way.
But here is exist one very big "but" =). Going this way you can disable only requests that is targeted to ASP.NET application, if you need to refuse all request made to particular application you need to write your custom tool that will stop corresponding ApplicatonPool.

Flex and CGI Newbie: How do I get them to talk

I am a Flex developer and never used CGI before. I wanted to create a solution whereby A flex would call a CGI script to read a database. Ive been trying to look for examples on how such a solution would work. I was hoping someone on here might be able to shed some light as to how this would work, and what are the various components required.
Thanks
You can do it with the URLLoader class. Load the CGI url using the urlloader class - execute queries using cgi script and return the response - handle the results in the complete event handler of URLLoader. Check this answer for details on using the URLLoader class.
Probably the easiest way is to output XML from your CGI and use Flex's HTTPService to connect to the CGI and get data. Sending updates can be done through sending HTTP Request Parameters via HTTPService.

Resources