I have just started with Spring Web Flow. I have a basic doubt. In case of Spring MVC, the #RequestMapping contains the URL mapping, say for eg, #RequestMapping("/home"), this means, when the URL nodeContent is /home, the Contorller with #RequestMapping("/home") will be delegated by the dispatcher servlet. In case of Spring Web Flow, how is this mapping done? I mean, how do we even identify the request URL? is it the flow-location id in flow-registry? Basically, I want to know how to identify that when a Spring web flow is invoked based on what kind of URL request? eq- "https://stackoverflow.com/questions/ask", if this URL has to invoke a flow, how is the mapping done with the URL /ask.
Please can anyone answer this?
The main thinks is, there are two beans which is complete the mapping.
First of all,
FlowHandlerMapping : in general, DispatcherServlet know the request mapping by handler mapping, but in WebFlow, FlowHandlerMapping helps DispathcerServlet to know the mapping. Basically it's "flow-registry". When hit the url, then it's get the url with the id. now it's ready to execute the flow.
FlowHandlerAdapter : When the executable flow url is ready then it's try to load the flow file with id like
configure-flow.xml
Once you successfully get the path then flow will start. The flow will continue until view-state to end-state.
Maintain the order of your view page, because next flow will come in order.
If you have any question, leave in comment section.
Related
I have a spring webflow application which is siteminder protected. The url typically has some params which the app uses to execute it's functionality. The implementation details are as follows -
When the url is invoked, i have an initial flow called authorize which takes the request params and validates them, If everything is good i have all the params in a javabean and this bean is stored in 'flowscope'
The above bean is passed to the next flows for various actions
This works fine when the url is invoked from the browser, but when the url is invoked from a word document we get the authentication dialog twice but the url params are not passed over to the browser.
Any one faced similar issue - please let me know
Thanks in advance.
Regards,
Kiran C Sagi.
I'm trying to understand Spring MVC annotations. I've looked at various tutorials, and I just want to make sure I understand. In this example,
#RequestMapping("/welcome")
am I correct in understanding that welcome is the page making the request to the controller, and not the page the controller sends the response to?
If I understand your phrasing correctly, you are right. The #RequestMapping annotation specifies a URL for which the controller will be invoked to generate page content. #RequestMapping("/welcome") means that when a browser requests http://yoursite.com/welcome this controller will be invoked. The annotation does not specify the name of the view you use to render the page output, so you're free to make the controller construct its response using home.jsp or index.jsp or any other page you want; you do not need to have a view named "welcome." I'm not sure it really makes sense to say that the controller "sends the response to a page," though, because in HTTP the response to a request is a page; the basic idea of a controller is that given a request, it generates a web page to send back to the client as a response.
Is there a way to get the server url (ex: http://www.myapp.com:8080/applicationFolder) without having access to a Request object ?
I need the url at aplication_start and in some classes where the Request object with all the goodies is not available.
note: I know that getting the application folder can be done using
VirtualPathUtility.ToAbsolute("~/");
HttpContext.Current.Request is a static property that always returns the Request object currently executing for the session.
I think all you need a custom solution to know when first request is made after application starts, and then you can send any email you want.. this is the similar problem with solution here http://weblogs.asp.net/reganschroder/archive/2008/07/25/iis7-integrated-mode-request-is-not-available-in-this-context-exception-in-application-start.aspx this do first initialization check in BeginRequest event.
There can be many different addresses all pointing to the same ASP.NET website, like using IP address or name. There might be more than 1 DNS name pointing to the same ASP.NET application. Therefore, HttpApplication, the parent class of Global, does not know which URL a visitor will use. Even IIS doesn't know. Therefore, you have to wait for the first request and then check in the request what URL the visitor uses to access your site. Something like this:
string baseUrl = Context.Request.Url.GetLeftPart(UriPartial.Authority);
One has to use Context to get access to the Request during Global.Application_Start, because Global.Request is not initialised yet.
My back-end server is built using the Microsoft WCF REST Starter Kit Preview 2. I want to add some request processing to all requests, except for those methods I explicitly disable by marking them with an attribute. I have over a hundred service methods and there are only a few I want to exclude from this extra processing. I'll tag them all if I have to, but I'm trying to avoid disrupting what's already written.
I haven't seen anything I can add to WebInvoke, and adding an interceptor won't let me examine the method that the request is routed to.
I am asking for an explanation of how to register HttpOperationHandler object(s) so I can do my extra request processing (i.e. authorization based on information in the request headers) before it is handed off to the method it was routed to. Can someone please explain how to do this, without rewriting my existing codebase to use Web API?
You can't use an HttpOperationHandler with WCF REST Starter Kit. However the Web API is very compatible with ServiceContracts that were created for WCF REST Starter kit. You should be able to re-host them in a Web API host relatively easily. You may have to change places where you access WebOperationContext, but it should not be a huge change.
I solved my problem by adopting another method. It authenticates all requests. I can't control which method it applies to, but I was able to work around that.
I created a custom ServiceAuthorizationManager class to process the Authorization header. The CheckAccess() method returns true to allow the request through or false if the user is not authenticated or not authorized to perform the service. I hooked it up to the ServiceHost for my services by creating a custom WebServiceHostFactory class and assigning an instance to the Authorization.ServiceAuthorizationManager in its CreateServiceHost() methods.
Although I can't directly check method attributes for the service being executed, the Message.Headers member of the object passed to CheckAccess() has a To property that contains the URI of the service being called. If necessary, I could examine it to determine what method the request would be routed to.
The ServiceAuthorizationManager applies to all requests, so no web methods or classes must be marked with any special attributes to enable it.
I'm wondering if it is possibile to customize routing in a way that all requests are evaluated by a piece of code, redirected to the relevant controller if a match is found or passed to next rout in list if not found.
sample request:
/my coolpage/another one
the code searches and determine that the right controller for this is
Page, action is "list" and id is "123" and so redirects
another request:
/products/list/5
code finds no match al passes it back to next route that knows how to handle it...
any idea on how to do this?
Custom Route class
If you really need this kind of request mangling and you can't do it with IIS URL Rewriting module, then writing your own Route class is your best bet. You will probably have to write some other parts as well, but a custom Route class will be your starting point.