Flex web services and reverse proxy - apache-flex

I have a similar problem to the one described here and I found the answer here to be helpful but I have a few more questions.
I've setup my project using Flash Builder 4 and imported my WSDL using the web service wizard making sure I pointed to the WSDL on the proxy. However simply doing that and enabling the "ProxyPreserveHost" directive did not allow the web services to run from the application being run on the proxy server. They just hang with no error or response.
So in addition to this I added this line of code to the service class that the Flash Builder wizard created:
_serviceControl.endpointURI = "https://site.mycompany.com/MyService/MyService";
This fixed the problem but I'm not sure as to why this is a problem in the first place. The location in the WSDL is specified to be http://site.mycompany.com:80/MyService/MyService and the server should be processing that request and converting it to https.
Anyone have any ideas or examples of how to get a Flex app built in Flash Builder working with a reverse proxy in place?
Thanks!

Related

Fundamentals of web-applications vs http server

I am required to preface this question with a disclaimer:
Im sorry if the question is silly and I am sure this information is on the Internet somewhere, but the reason why I ask here is because, I lack the knowledge to begin my research anywhere useful I don't need to read what an http server is, but rather what it's place in a backend environment is. Somehow, I was not able to find anything useful, which is why I believe that the idea I have of this issue at this moment is completely wrong.
I am fairly new to the ins and outs of how the web works. I believe I have good knowledge on how the http protocol works, frontend development and programming. But I don't seem to be able to connect the pieces.
What happens after the request reaches the http server?
Specifically, I can't seem to understand what exactly the back-end means. For example, if someone were to use Django as their backend framework -> what would be the role the application written in python(django) plays? Does it interpret the server request and if so, what are applications such as apache http server used for in a situation such as this?
I don't understand the link between the http server and the web application.
How would you get a web application to run on a server?
I understand that if you just need a web server to serve static html files than apache server would be enough. But how does it work when user data has to be inserted into the html file, or when the database has to be updated as a result of a http request.
I believe this would be the responsibility of the web application, but how do they interact?
tl;dr:
What is the role of an http-server vs role of a web application?
How do they interact?
To point is an http server software such as apache or nginx necessary?
What is the role of an http-server vs role of a web application?
An HTTP-Server is roughly an application that serves files to clients. Basically those files are of HTML type, thus contains hyperlinks that refers to other files.
A web application is just a set of related HTML files, that the user navigates through.
That is the base; as that model can be extended : files can be generated dynamically, of type different than HTML, etc.
How do they interact?
The server manages the files and send them to the client application (usually a web browser).
To point is an http server software such as apache or nginx necessary?
Sure it is, as it is the core infrastructure of a web application. Your web application is a set of HTML files that are accessed through a web-browser that ask the HTTP-server to obtain them.

Run Angular and ASP.NET Web API on the same port

I am currently using angular to issue API call to an API server running ASP.NET. However, I have a cross-origin issue as for angular development, I am using localhost. While in the production version they will all run under the same domain using IIS.
Is there a way to run the angular app on the same port with ASP.NET?
P.S.: I am also open for other alternatives on solving this issue.
I've encountered the same problem, then I've found this post on medium, hope this works for you.
Edit:
Actually the solution that I've used is from that article.
The idea is that you can't "publish" the API and the Angular app on the same port, but you can use a proxy to connect from the Angular app to the API on the other port.
Update: sorry for not answering this long time ago.
To deal with the cors issue (in this case) you can use a proxy with the ng serve command.
For example, in my case I have used a proxy.conf.json file like this:
{
"/api/*": {
"target": "http://localhost:3000",
"secure": false,
"pathRewrite": {"^/api" : ""}
}
}
This code rewrite the url on every request to /api/* to the http://localhost:3000 where your api is listening.
So, to illustrate, if in angular you make a request like http://localhost:4200/api/users it will be redirected/rewrited to http://localhost:3000/api/users solving the cors issue.
Now, the way you have to run your angular application is different.
ng serve --proxy-config proxy.conf.json
I was able to achieve that with IIS successfully! I know the post is old but hopefully, it will save time for solution seekers :)
First (just a reminder) ensure that you have .NET Core Hosting Bundle installed on IIS machine (link could be found here). Bear in mind that it will require at least WinSrvr2012R2 to run.
Now copy published .net core API solution folder to the server. The same for Angular - next reminder here: execute ng build --prod then copy dist folder to the server.
Then configure IIS - create a new web site that points to the Angular app folder. Your Angular app should run at this point (but obviously there is no API yet).
Go to application pools - you will see the pool created for your application. Open basic settings and change CLR version to 'No managed code'.
And finally, click on your Web Site and 'Add application' under it. Point to dotnet core API folder and name it using some short alias. Now you should have a website structure with the application included.
If your angular app URL is:
https://myiissrvr/
your API is under:
https://myiissrvr/[ALIAS]/
DONE
Final remarks:
Usually, web API using URL structure like
https://myiissrvr/api/[controller]/[action]
So after bundling it together, it will look like:
https://myiissrvr/[ALIAS]/api/[controller]/[action]
With that approach, you should be able to attach multiple web API services under statically served Angular website - each one under its own alias. Potentially it might be useful in many scenarios.

Running ASP.Net server - Must be from visual studio?

I'm pretty new to ASP.Net and I've been having troubles understanding something.
I made a web application project with a web service on my computer.
I made another web application project, who then consumed the WSDL from the web service on the first project and uses a function in it.
I ran each on a different VS2012 Instance and when both projects are running in then there is no problem and it works fine.
When i close the VS Instance with the Web Service project then I get a Coonnection Error which is also logical.
My question:
Is there a way to keep the server running without keeping visual studio open?
There is no ".exe" generated or anything so I don't know what to run in order to keep the "Server" running..
Additional question if you don't mind:
If I want to use this service from another computer on the same Network, will the "localhost:.....?WSDL" service reference still work or do I need another address?
Sorry for my lack of knowledge, I just couldn't find a good guide explaining about how to keep the server running anywhere.
Thank you, Mellor.
Host your web service in localhost
use the computername instead of localhost in WSDL URL when you add services/web reference in cleint applications

Flex app not hitting web service

I have zero knowledge on flex and need help to determine what is preventing my web service from being called.
We have a working application in production and the developer who wrote it has left.
I am trying to build it on my machine and I can see a web service call in fiddler being made with the URL "/Services.asmx/MethodName" (as a GET request).
I have set my break point in the asmx web service and it is not being hit. All I get in the flex front end is a pop up with " The remote server failed to respond and may be offline. http://MachineName/Services.asmx/MethodName"
The web service is in the same application as the web app that hosts the SWF file.
I have the cross domain policy file in place.
What I noticed in fiddler is the URL is "/Services.asmx/MethodName" and not "/WebApp/Services.asmx/MethodName" (not sure if this makes a difference) where WebApp is the IIS virtual directory to the web application that hosts the SWF.
Any ideas?
JD
If you are Web-services and your web-application is same domain then just pass the whole path like "http://..../Services.asmx" for creating web-service api instance in ActionScript 3.0 (for flex). and use this instance name to call your web-service method.
Please read this article from Adobe help for your perfect answer

Cannot access SOAP service when Flex 3 app is compiled

I've got a flex app that hits a remote SOAP service and populates a list with the results.
It works fine when i run it through flex builder, but when i compile the application and move it onto a webserver it can't access the services.
I've tried it from a standalone webserver and on my own machine. I'm assuming that there's a security issue that i've missed as i can't think of any other reason why it's ok in flex builder but not when compiled on the same box.
Thanks all.
Is it a crossdomain.xml issue?
The web server running the SOAP service needs crossdomain.xml file to allow your flash movie to access it. See http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html

Resources