JAX-WS: define server side handler chain in code and not in external xml - http

i want to enable http compression for my jax-ws webservice. i found out that i have to do it with a custom handlerchain that can modify the http-headers.
all tutorials i found refer to the annotation #HandlerChain that points to a handler chain configuration xml-file but my problem is that my webservice has to be as lightweight as possible therefore i cant define my handler chain in an external xml file.
i tried the following but did not succeed:
final Endpoint ep = Endpoint.publish("http://localhost:8878/mywebservice",
new WebserviceImpl() );
final Binding binding = ep.getBinding();
final List<Handler> handlerChain = binding.getHandlerChain();
handlerChain.add(new MySuperbSOAPHandler());
binding.setHandlerChain(handlerChain);
does anyone know how to do this? is it even possible?

It doesn't appear that you can change the handler chain when the service has already been published.
If your actual use case is as above, it's easy to fix by simply create()ing and then publish()ing.
final Endpoint ep = Endpoint.create(new WebserviceImpl() );
final Binding binding = ep.getBinding();
final List<Handler> handlerChain = binding.getHandlerChain();
handlerChain.add(new MySuperbSOAPHandler());
binding.setHandlerChain(handlerChain);
ep.publish("http://localhost:8878/mywebservice");

Related

Set Apects via REST API Call in Alfresco

What is the JSON Format to set aspects to some folder or documents in alfresco via REST API.
You need to send POST request by the following url (Alfresco 4.1.5):
your_host/alfresco/s/slingshot/doclib/action/aspects/node/workspace/SpacesStore/{nodeUUID}
for Alfresco 5:
your_host/alfresco/s/slingshot/doclib/action/aspects/node/workspace/SpacesStore/{nodeUUID}
with the following body:
{
"added":["abc:doc"],
"removed":[]
}
The preferred approach is to use CMIS rather than the internal slingshot web script. Using CMIS you can add an aspect in a standard way, and you can do it via the browser binding (JSON), the Atom Pub binding (XML), or Web Services.
You can use a CMIS client, such as one of the ones available from http://chemistry.apache.org, or you can do it using the raw binding directly over HTTP.
In CMIS 1.1 you add an aspect by adding its ID to the multi-value property named cmis:secondaryObjectTypeIds.
Here's a gist that shows what this looks like in Java: https://gist.github.com/jpotts/7242070
You need to make one custom webscript.The code of webscript will be like below.In case of webscript you can use below link for learning purpose.
https://wiki.alfresco.com/wiki/Web_Scripts
var props = new Array(1);
props["cm:template"] = document.nodeRef;
document.addAspect("cm:templatable", props);
props = new Array(1);
props["cm:lockIsDeep"] = true;
document.addAspect("cm:lockable", props);
props = new Array(1);
props["cm:hits"] = 1;
document.addAspect("cm:countable", props);

How to create database for a Semantic Logging Application Block with SqlDatabaseSink

How to set up the SQL Server database for Semantic logging.
Does the table for logging information needs to be created earlier?
If yes, what is the schema to be used.
I have the following code :
var listener = new ObservableEventListener();
string connectionString = #"Data Source=nibc2025;Initial Catalog=TreeDataBase;Integrated Security=True;User Id=sa;Password=nous#123";
listener.EnableEvents(AuditingEventSource.Log, EventLevel.LogAlways, Keywords.All);
databaseSubscription = listener.LogToSqlDatabase
(
"Test",
connectionString,
"Traces",
Buffering.DefaultBufferingInterval,
1,
Timeout.InfiniteTimeSpan, 500
);
// The following one line of code is not part of this function.
// It is just added here to show this is how I log my information.
// Inside LogInformation method I call the 'Write' method
AuditingEventSource.Log.LogInformation("sgsgg", "sgsg");
databaseSubscription.Sink.FlushAsync().Wait();
Well, Since this thread gets the most hits on Google regarding Semantic Logging onto SQL DB or even SLAB ...
The scripts to create the DB lies here
\packages\EnterpriseLibrary.SemanticLogging.Database.1.0.1304.0\scripts
And to create the EventSource and Fire the Blocks, information are given here, for a shortcut and quick fix solution
http://entlib.codeplex.com/discussions/540723
Regards,
OK. I got it. the script was in the packages folder. I had overlooked that.

How to remove HTTPService from log target

I'm using HTTPService in my app and I added a logging target and now I'm getting logging info from the HTTPService.
For example, I'm getting this message, "Processing HTTPService response message" and "Decoding HTTPService response".
Is there a way to turn this off or on (when I'm not using TraceTarget) or filter these calls out?
Hi I not sure if you done this already but you can play with the filters and levels of log you want to manage.
var logTarget:TraceTarget = new TraceTarget();
logTarget.filters=["mx.rpc.*","mx.messaging.*"];
logTarget.level = LogEventLevel.ALL;
Log.addTarget(logTarget);

Returning ItemStats from Tridion UGC

I was wondering if anyone can offer any pointers on this one. I'm trying to return ItemStats from the Tridion UGC web service but I'm getting the following error when trying to bind the results:-
The closed type TridionWebUGC.CDS.ItemStat does not have a corresponding LastRatedDate settable property.
An example of code is:-
WebServiceClient ugcCall2 = new WebServiceClient();
Uri uri = new Uri("http://new.ugc.service/odata.svc");
CDS.ContentDeliveryService cds = new CDS.ContentDeliveryService(uri);
var myItemStats = cds.ItemStats.Where(p => p.PublicationId == 68 && p.Id == 17792 && p.Type==16);
I can get comments and ratings with no problem. E.g.
var myComments = cds.Comments.Where(p => p.ItemId == 17805).OrderBy(p => p.CreationDate);
It's just ItemStats that are giving me an issue. Anybody any ideas?
Thanks
John
Unfortunately, the metadata of the UGC WebService is not correct in regards to the ItemsStats. For you it means that the webservice metadata does not expose the fact that the ItemStat entity contains the LastRatedDate property. This makes your .NET proxies not to be aware of this property and makes your query fail.
To work-around this defect you have two option:
Add to your service the following property: cds.IgnoreMissingProperties = true;. Advantage of this approach is that you're done with it in 2 sec. Disadvantage is that you will not be able to access that property (in case you actually use it);
Modify the proxies generated by Visual Studio and manually add that property to the ItemStat class. Advantage of this approach is that you will be able to access the property from your project. Disadvantage is that it's totally not manageable from the coding point of view, you need to be careful when you upgrade or regenerate the proxies and it's easy to make a mistake while manually adding the property.
Note 1: to access the metadata of your webServer from the browser your can go to /odata.svc/$metadata.
Note 2: on a closer look there are 2 properties missing from the webService metadata: LastRatedDate and LastCommentedDate.
Hope this helps.

smartgwt servlet use

Hi I have a listgrid in smartgwt and I need to have a button to upload a file to the server, I created an ordinary servlet and have declared in the web.xml of my project but I can not make it work, make me 404 error to deploy . You can use regular servlets (with its post and get methods) with gwt?
Thanks in advance.
GWT transfers data between server side code (running on servlet container like tomcat or jetty) & client side code (GWT compiled client side JS files) in a special way called GWT-RPC.
Client required to know format of data that will send or receives to/from server & server also must knows about format of data that client can parse(we have serious limitation in serialization & deserialization of data because one side we have only javascript!). This is why you need to declare an interface for your remote servlet & GWT makes another async interface using it & restricts your service calls to that interface. & this is why you can't use any standard servlet with GWT.
HttpServlet can be used with smartgwt. You need to have DynamicForm and set .setCanSubmit(true);
Sample Code:
final String DEFAULT_FILE_UPLOAD_SERVICE_PATH = "upload";
final String TARGET = "uploadTarget";
VLayout body = new VLayout();
uploadForm = new DynamicForm();
// initialise the hidden frame
NamedFrame frame = new NamedFrame(TARGET);
frame.setWidth("1px");
frame.setHeight("1px");
frame.setVisible(false);
uploadForm.setEncoding(Encoding.MULTIPART);
uploadForm.setMethod(FormMethod.POST);
// set the (hidden) form target
uploadForm.setTarget(TARGET);
uploadForm.setAction(DEFAULT_FILE_UPLOAD_SERVICE_PATH);
// initialise the File name field
uploadItem = new UploadItem("filename");
uploadItem.setName("filename");
uploadItem.setTitle("File name");
// set the fields into the form
uploadForm.setFields(uploadItem);
// add the Upload Form and the (hidden) Frame to the main layout container
body.addMember(uploadForm);
body.addMember(frame);

Resources