We have a web service that contains 6 different service endpoints, and thus 6 different WSDLs. We are using spring integration for the underlying infrastructure. This particular project will support multiple versions, which is working correctly.
From what I understand, I can server WSDLs one of three ways:
> - <static-wsdl>
> - <dynamic-wsdl>
> - custom servlet approach
The first two approaches do not scale well, I would have to add a new set of WSDL definitions for each version and since the id specifies the WSDL location, the user would have to access something like service1_v1.wsdl, service1_v2.wsdl, etc. For example, here is what the config would look like for static wsdls for two versions:
<sws:static-wsdl id="service1_v1" location="/WEB-INF/wsdl/v1/service1.wsdl"/>
<sws:static-wsdl id="service2_v1" location="/WEB-INF/wsdl/v2/service2.wsdl"/>
...
<sws:static-wsdl id="service1_v2" location="/WEB-INF/wsdl/v2/service1.wsdl"/>
<sws:static-wsdl id="service2_v2" location="/WEB-INF/wsdl/v2/service2.wsdl"/>
...
<sws:static-wsdl id="service1_v3" location="/WEB-INF/wsdl/v3/service1.wsdl"/>
<sws:static-wsdl id="service2_v3" location="/WEB-INF/wsdl/v3/service2.wsdl"/>
The last approach would involve a servlet that processed any wsdl requests, and using a request parameter determine the version. However, I will not be able to take adavantage of any built in spring functionality, like transformLocations.
Is it possible to generate WSDLs programatically? I could add a maven task to generate the WSDLs and add the spring beans at startup.
What I am trying to avoid is having a lot of config and having to update this config every time that we add a new version or deprecate one. I already have a mechanism in SI to correctly router the messages to the appropriate versioned endpoint, just need to finalize the WSDL mappings.
You should be able to do it programmatically, using the same classes that the MessageDispatcherServlet uses, as documented in the Spring Web Services Reference.
Note, however, the caution there about dynamically creating WSDLs.
Related
I come from Grails background and have recently started a project in Micronaut using GORM.
I tried to find required information in documentation but its not clear how we retrieve post data in controller, validate it similar to Command Objects offered in Grails and save it into database using interface service provided in documentation
PS : I know I can map every field to action argument in controller, and also declare a interface method specifying each argument as property but that does not seems right thing to do as my domain class has so many properties.
Making the action #Transactional or any method would work for saving data as far as I know but I want to know the proper way in Micronaut.
My requirement is simple, save post data in database using GORM in Micronaut.
If I were you I would look back at the documentation, sections 6.4 to 6.11:
https://docs.micronaut.io/snapshot/guide/index.html#binding
https://docs.micronaut.io/snapshot/guide/index.html#datavalidation
http://hibernate.org/validator/
Micronaut is very annotation based, unlike Grails which uses convention over configuration. However in Grails 4, Micronaut will toke over the application context, giving you some of the benefits of Micronaut, but still maintaining the convention over configuration.
We are using ServiceStack in a web hosted API service, and have done so for awhile now. The execution path for any request follows the pattern:
Request comes in:
--> Service (handles request, utilizes IManager injected via constructor)
--> IManager (performs business logic, utilizes IRepository/ies that are injected via constructor)
--> IRepository/ies (SQL Server, NoSQL, utilizes connection factory/ies injected by constructor)
Now that we are entertaining another client, some of these requests need to follow slightly different business logic, and potentially utilize a different repo strategy. However, the API will remain consistent. To this end, I am extracting client specific logic (the concrete IManager and IRepository implementations above) to separate assemblies. I've written a component that inspects the current request context, identifying the client this request is for, which then uses reflection and the Activator to instantiate an instance of the specific implementation I want to execute for any given request.
However, because of this, I can't just register implementations of IManager and IRepository in the container at startup - this needs to be resolved dynamically per request. I'd like to do some type of LazyResolve, but I can't find any solid example of how this is done to get me started here.
Am I thinking crazy here? My API is essentially just that with this - the custom logic that occurs is isolated to client specific assemblies that are called at runtime. This all makes perfect sense to me in theory, but in practice it's proving a challenge. Thoughts? Ideas?
If you only want to resolve adhoc dependencies at runtimes you can just resolve them from the IOC as needed in your Service with:
base.TryResolve<T>();
In any Filter from IRequest with:
req.TryResolve<T>();
Or externally outside ServiceStack with:
HostContext.TryResolve<T>();
I am using Spring core 2.0.2. When I call 'context.createSubContext()' I get a 'not implemented' error. When I look at the Spring Ldap core source for LdapTemplate I see that it isn't implemented.
So how do I create a subContext in Spring Ldap?
DirContextAdapter is intended to simplify working with attribute values, not interacting with the LDAP tree (see reference docs). You should use LdapTemplate instead - more specifically, in this case, the bind operation.
I have a set of Services that I want to use in various ServiceStack projects (okay, two) so I have created a ServiceStack Plugin that registers them.
However I want to allow users to determine their own method of securing access to these services.
Currently I have an IHasRequestFilter in one my projects that can determine which services a user should be able to access. I do not want a reference to this in the Plugin project, so I want to add this dynamically after the fact.
I want to somehow get a reference to the Service Definition in AppHost to add this IHasRequestFilter to the pipeline for a specific set of services.
Ideally I should be able to do something like this:
new CustomPlugin(new CustomPluginParams {
RestrictTo = CustomRestrictions,
RequestFilters = [],
ResponseFilters = []
});
This should use those properties to configure their services without having a previous typed reference.
Edit:
Investigating further it appears that the IHasRequestFilter and IHasResponseFilters are only parsed once, in the ServiceExec<TService> class. I could get round this by creating my Services with a Proxy which adds the attribute I require to the MemberInfo of the operations, however I don't regard that as a clean approach.
Does anyone have recommendation?
In ServiceStack all configuration should happen within AppHost's Configure() method and remain immutable thereafter.
Lifecycle Events
To help with LifeCycle events there are IPreInitPlugin and IPostInitPlugin Plugin Interfaces which your Plugins can implement so they will get called back before and after all plugins are registered.
There's also an IAppHost.AfterInitCallbacks plugins can use to get called back after the entire AppHost has finished initialiazing.
Typed Request/Response Filters
Attributes are typically statically defined on Services, to dynamically add logic that apply to specific Request/Responses you can use a typed Request/Response filter.
The nice thing about ServiceStack Filters is that they share the same API (IRequest, IResponse, object) which makes them easily composable, e.g:
RegisterTypedRequestFilter<CustomRequest>(new RequestAttributeFilter().Execute);
Dynamically adding Attribute filters
As all ServiceStack libraries use ServiceStack.Text's Reflection API's you're able to extend ServiceStack's attribute-based code-first API dynamically by adding attributes to types or properties at runtime, e.g:
typeof(CustomRequest)
.AddAttributes(new RuntimeAttributeRequestFilter());
This can be done for most of ServiceStack's code-first API's inc. Request/Response Filters.
Route attributes and Action Filters
There is sometimes an issue for Services Route attributes and Action filters that already pre-configured and autowired before the AppHost's Configure() is called.
One solution is to add them in the AppHost constructor (or by overriding AppHost.OnBeforeInit) so they're added before the Services are configured. Otherwise you can reset the action filter caches by calling the AppHost's ServiceController.ResetServiceExecCachesIfNeeded().
I need to use Spring Security 3 in my application which is composed by Spring 3 for the server side and GWT 2.1 for the client side.
Client side and server side are totally decoupled, I mean they don't belong to the same project in the eclipse workspace (server side is managed by maven and client side uses prebuilt ant files) and till now they "communicate" each other using Rest/Json.
Googling I found some tutorials and tips about integration with Spring Security but all of them suppose that "client side" knows spring-server-side classes, and so using #Controller #Autowired etc under the gwt.server package. In my case this is not possible (or not clean to do).
Is there a way to use Spring Security and keeping the code "decoupled"? Maybe for every (rest) client request I should use "basic authentication"?
Thanks,
Rand
Here are some links I found and used when implementing GWT/Spring Security:
http://blahti.wordpress.com/2010/02/04/basics-of-gwt-authentication/
http://www.javacodegeeks.com/2010/12/securing-gwt-apps-with-spring-security.html
In summary simply see GWT as static html pages to be served and rest calls just requests for static pages. Only if you want specific information in the client, which comes from spring security, like username, you need to add something to the server side, but this in your case can also be done via a rest call.
I just completed writing an article on how to integrate GWT with Spring security without having the need to use any JSP or static page.
You can check this in here : http://crazygui.wordpress.com/2014/08/29/secure-rest-services-using-spring-security/ I also posted a working example on GitHub.