<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7261744746504206620</id><updated>2012-02-17T06:32:01.779-08:00</updated><category term='C#'/><category term='Transformer'/><category term='445'/><category term='SMB'/><category term='Leak'/><category term='HTML Files'/><category term='High'/><category term='.Net'/><category term='Memory'/><category term='Disable'/><category term='Alfresco'/><category term='netBeans'/><category term='Search'/><category term='CIFS'/><category term='Tags'/><category term='Repository Web Service'/><category term='64 bit'/><category term='Windows 7'/><category term='Port'/><title type='text'>Sangosthi</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sangosthi.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sangosthi.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anil</name><uri>http://www.blogger.com/profile/09580098741890536509</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7261744746504206620.post-253707600715279401</id><published>2011-03-20T07:37:00.000-07:00</published><updated>2011-03-20T08:14:25.968-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Port'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows 7'/><category scheme='http://www.blogger.com/atom/ns#' term='SMB'/><category scheme='http://www.blogger.com/atom/ns#' term='64 bit'/><category scheme='http://www.blogger.com/atom/ns#' term='Disable'/><category scheme='http://www.blogger.com/atom/ns#' term='CIFS'/><category scheme='http://www.blogger.com/atom/ns#' term='445'/><title type='text'>How to disable CIFS/SMB port 445 on Windows 7 64 bit</title><content type='html'>So, I had a requirement of disabling the port 445 on a Win 7 64 bit machine. The first thing which we do is to 'google' to find out a solution and I did the same. I found some results and they looked convincing. I tried the first method which was something like:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Open registry editor&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Go to 'HKLM\System\CurrentControlSet\ Services\NetBT\Parameters' key&lt;/li&gt;&lt;li&gt;Go to option called TransportBindName (on the right hand side)&lt;/li&gt;&lt;li&gt;Empty the value so that Data (value) of 'TransportBindName' is empty. Close Registry Editor.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Reboot the PC&lt;/li&gt;&lt;li&gt;And you are done&lt;/li&gt;&lt;/ul&gt;Aah, it was so simple I thought and followed the procedure. To my irritation, this didn't work. no problem, there was another method on some other website:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;As again, this requires opening the registry editor&lt;/li&gt;&lt;li&gt;Go to 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters' key&lt;/li&gt;&lt;li&gt;Create a 'REG_DWORD' Entry with the name SMBDeviceEnabled and give it's value 0&lt;/li&gt;&lt;li&gt;Close Registry Editor&lt;/li&gt;&lt;li&gt;Reboot the PC&lt;/li&gt;&lt;/ul&gt;Waah, it also seemed simple. I followed the procedures and waited till the PC rebooted. And again to my greater irritation, it didn't work.&lt;br /&gt;&lt;br /&gt;I went on googling and almost experimented all the things I found  - none of them worked for me. It took almost one full day :(&lt;br /&gt;&lt;br /&gt;Then I started experimenting on my own, and luckily to my great satisfaction, I found it. Here is what worked for me:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Open Services by typing services.msc in Run dialog box.&lt;/li&gt;&lt;li&gt;Locate the service named 'Server'. The description field for this should be saying something like 'Supports file, print, and named-pipe sharing over the network for this computer. If this service is stopped, these functions will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start. '&lt;/li&gt;&lt;li&gt;Double click on that service&lt;/li&gt;&lt;li&gt;Click on the button 'Stop' to stop it.&lt;/li&gt;&lt;li&gt;In the Startup Type combo choose 'Disabled' so that on the next boot, this service will not start running. Apply your changes by clicking on Ok.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now locate another service named 'TCP/IP NetBIOS Helper'. The description should read something like 'Enables support for NetBIOS over TCP/IP (NetBT) service and NetBIOS name resolution.'.&lt;/li&gt;&lt;li&gt;Do the same with this service - stop it and disable it.&lt;/li&gt;&lt;li&gt;Restart the computer&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;There can be slight variation in names/description as while writing this blog post, I was on a XP machine.&lt;br /&gt;&lt;br /&gt;Disclaimer: By reading the descriptions of the services you disabled, you should have a hint that your file sharing and other things will not work on the next reboot.&lt;br /&gt;&lt;br /&gt;You can always go to Services again and set the services as 'Automatic' to enable them on the next reboot.&lt;br /&gt;&lt;br /&gt;if it also works for you, kindly come back and leave a note of appreciation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261744746504206620-253707600715279401?l=sangosthi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sangosthi.blogspot.com/feeds/253707600715279401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sangosthi.blogspot.com/2011/03/how-to-disable-cifssmb-port-445-on.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/253707600715279401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/253707600715279401'/><link rel='alternate' type='text/html' href='http://sangosthi.blogspot.com/2011/03/how-to-disable-cifssmb-port-445-on.html' title='How to disable CIFS/SMB port 445 on Windows 7 64 bit'/><author><name>Anil</name><uri>http://www.blogger.com/profile/09580098741890536509</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7261744746504206620.post-4939907078182549002</id><published>2010-02-09T06:33:00.000-08:00</published><updated>2010-02-09T06:54:27.864-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Search'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML Files'/><category scheme='http://www.blogger.com/atom/ns#' term='Tags'/><category scheme='http://www.blogger.com/atom/ns#' term='Transformer'/><category scheme='http://www.blogger.com/atom/ns#' term='Alfresco'/><title type='text'>Search HTML Files in Alfresco: Search only WYSIWYG text, and not HTML tags, style declrations, etc.</title><content type='html'>&lt;span style=";font-family:arial;font-size:100%;"  &gt;By default, If we add any HTML file to Alfresco, it treats it as a text file and indexes everything. That means, all tags, content inside tags, style declarations, etc get indexed.&lt;br /&gt;For example, If the content of HTML file is:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;div&amp;gt;&lt;br /&gt;&amp;lt;table class="AlternateCyanColorGrid" cellspacing="0px" width="100%"&amp;gt;&lt;br /&gt;   &amp;lt;col style="width: 33.333%;" /&amp;gt;&lt;br /&gt;   &amp;lt;col style="width: 33.333%;" /&amp;gt;&lt;br /&gt;   &amp;lt;col style="width: 33.333%;" /&amp;gt;&lt;br /&gt;   &amp;lt;tr class="t1Row"&amp;gt;&lt;br /&gt;       &amp;lt;td&amp;gt;heading1&amp;lt;/td&amp;gt;&lt;br /&gt;       &amp;lt;td&amp;gt;chkheading&amp;lt;/td&amp;gt;&lt;br /&gt;       &amp;lt;td&amp;gt;newest&amp;lt;/td&amp;gt;&lt;br /&gt;   &amp;lt;/tr&amp;gt;&lt;br /&gt;   &amp;lt;tr class="t2Row"&amp;gt;&lt;br /&gt;       &amp;lt;td&amp;gt;search&amp;lt;/td&amp;gt;&lt;br /&gt;       &amp;lt;td&amp;gt;results&amp;lt;/td&amp;gt;&lt;br /&gt;       &amp;lt;td&amp;gt;logged&amp;lt;/td&amp;gt;&lt;br /&gt;   &amp;lt;/tr&amp;gt;&lt;br /&gt;   &amp;lt;tr class="t1Row"&amp;gt;&lt;br /&gt;       &amp;lt;td&amp;gt;cruel&amp;lt;/td&amp;gt;&lt;br /&gt;       &amp;lt;td&amp;gt;verify&amp;lt;/td&amp;gt;&lt;br /&gt;       &amp;lt;td&amp;gt;broom&amp;lt;/td&amp;gt;&lt;br /&gt;   &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;Now, if we search for table, body, style, etc, the file will be included in search results.&lt;br /&gt;Sometimes, requirements may be to search for WYSIWYG text of Html files only, and not the extra meta stuff.&lt;br /&gt;&lt;br /&gt;What we need to do, is to provide Alfresco, the WYSIWYG text of HTML files, and not the raw text. Alfresco provides transformers for this purpose. We will use a transformer which is present in Alfresco.&lt;br /&gt;&lt;br /&gt;To achieve our purpose,  create a custom extension file custom-content-services-context.xml in extension folder [For Alfresco deployed inside JBoss, the extension folder is server\&lt;type&gt;\conf\alfresco\extension, for standalone Alfresco, it is tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension] with the following content:&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'&amp;gt;&lt;br /&gt;&amp;lt;beans&amp;gt;&lt;br /&gt;  &amp;lt;bean id="transformer.HtmlParser"&lt;br /&gt;        class="org.alfresco.repo.content.transform.HtmlParserContentTransformer"&lt;br /&gt;        parent="baseContentTransformer" &amp;gt;&lt;br /&gt;     &amp;lt;property name="explicitTransformations"&amp;gt;&lt;br /&gt;        &amp;lt;list&amp;gt;&lt;br /&gt;           &amp;lt;bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" &amp;gt;&lt;br /&gt;               &amp;lt;property name="sourceMimetype"&amp;gt;&amp;lt;value&amp;gt;text/html&amp;lt;/value&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;               &amp;lt;property name="targetMimetype"&amp;gt;&amp;lt;value&amp;gt;text/plain&amp;lt;/value&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;           &amp;lt;/bean&amp;gt;&lt;br /&gt;        &amp;lt;/list&amp;gt;&lt;br /&gt;     &amp;lt;/property&amp;gt;&lt;br /&gt;  &amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;&lt;br /&gt;Now, if you add the same Html file, terms like body, table etc should not get indexed.&lt;br /&gt;&lt;br /&gt;&lt;/type&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261744746504206620-4939907078182549002?l=sangosthi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sangosthi.blogspot.com/feeds/4939907078182549002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sangosthi.blogspot.com/2010/02/search-html-files-in-alfresco-search.html#comment-form' title='35 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/4939907078182549002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/4939907078182549002'/><link rel='alternate' type='text/html' href='http://sangosthi.blogspot.com/2010/02/search-html-files-in-alfresco-search.html' title='Search HTML Files in Alfresco: Search only WYSIWYG text, and not HTML tags, style declrations, etc.'/><author><name>Anil</name><uri>http://www.blogger.com/profile/09580098741890536509</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>35</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7261744746504206620.post-6874957799883141830</id><published>2010-01-28T09:29:00.000-08:00</published><updated>2010-01-28T21:33:42.931-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='High'/><category scheme='http://www.blogger.com/atom/ns#' term='Memory'/><category scheme='http://www.blogger.com/atom/ns#' term='Alfresco'/><category scheme='http://www.blogger.com/atom/ns#' term='netBeans'/><category scheme='http://www.blogger.com/atom/ns#' term='Leak'/><title type='text'>Alfresco is taking too much memory : Memory Leak</title><content type='html'>I was hit hard by a probable memory leak in Alfresco. This post is about how I found the issue and got the solution. Sometimes we need to go extra mile to achieve the much desired success.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;I was working on a wrapper above Alfresco 3.1 Stable Edition. We wrote a plug-in (webscript) for Alfresco. Ours is a J2EE App which talks to Alfresco using this plug-in. Our app and Alfresco war both are deployed in JBoss 4.2. I had been hit by a High Memory usage, which possibly could be a memory leak/issue in Alfresco.&lt;br /&gt;&lt;br /&gt;Our app extends the folder type to include some (~20) additional meta props. ‘file’ (content) type has also been extended to include ~20 meta properties.&lt;br /&gt;&lt;br /&gt;So, we have defined our custom folder and files.&lt;br /&gt;&lt;br /&gt;My System Configuration was:&lt;br /&gt;64 bit JVM 1.6 running on Windows Server 2008 R2, core 2 machine with 6 GB of physical RAM. SQL Server 2008 is the DB. I was using JMeter to talk to our app, which eventually talks to our Alfresco plug-in using webscripts. As recommended by Alfresco, I had provided 2GB of Heap to Alfresco.&lt;br /&gt;&lt;br /&gt;In the following discussion, memory will mean old gen memory only.&lt;br /&gt;&lt;br /&gt;I attached JConsole to the JVM running JBoss. Initial memory consumption was 160m. I added 1000 custom folders and a single xml file in each folder. Files differ (content and name wise) by some strings only and are very small (0.6 KB). Memory consumption started to increase, went up to 1.5 Gb and settled down at around 500m. Settled down means I did GC manually quite a times using JConsole. I added 1000 more folders and similar 1 file in each folder and the memory settled at 800mb. Added the same amount of data more, and it settled at 1GB. More same data and it settled at 1.16 GB. As I have told earlier, all files added so far differ by some strings (content and name wise) only.&lt;br /&gt;&lt;br /&gt;I took the heap dump and analyzed with ‘jhat’ (show instance of all classes excluding platform). There were so many objects of different classes, but what took my attention was many objects of classes related to Lucene Indexing. Should they be there? Objects of classes lucene.index.FieldInfo, lucene.index.Term , luene.index.TermInfo , lucene.index.TermBuffer, lucene.store.RAMFile, lucene.store.RAMDirectory,lucene.index.CompoundFileReader$CSIndexInput, lucene.store.RAMInputStream, etc . Count for some of these instances reaching up to 200000. Is Lucene eating up the memory? Other user as also reported similar problem: &lt;a href="http://forums.alfresco.com/en/viewtopic.php?f=9&amp;amp;t=18791&amp;amp;p=61675&amp;amp;hilit=leak#p61675"&gt;http://forums.alfresco.com/en/viewtopic.php?f=9&amp;amp;t=18791&amp;amp;p=61675&amp;amp;hilit=leak#p61675&lt;/a&gt;. Wiki has a page for similar problem: &lt;a href="http://wiki.alfresco.com/wiki/Lucene_Extensions_and_Issues"&gt;http://wiki.alfresco.com/wiki/Lucene_Extensions_and_Issues&lt;/a&gt; but there is no update on it (whether the issues has been fixed in 3.1). I have scanned my app's code thoroughly and can assume that there is no memory leak from there. Issue seems to be on Alfresco side.&lt;br /&gt;&lt;br /&gt;I again conducted my test case. This time I added around 3000 folders and one file in each folder. JVM started with around 200m of memory, and after I was done adding content, it settled at 1050m. ‘jhat’ heap dump (instance count of all classes excluding platform) showed more than 1000000 (1 million) objects from Lucene only, here is the breakup :&lt;br /&gt;&lt;br /&gt;277571 instances of class org.apache.lucene.index.FieldInfo&lt;br /&gt;237693 instances of class org.apache.lucene.index.CompoundFileReader$CSIndexInput&lt;br /&gt;174082 instances of class org.apache.lucene.index.SegmentReader$Norm&lt;br /&gt;102453 instances of class org.apache.lucene.index.TermBuffer&lt;br /&gt;77363 instances of class org.apache.lucene.index.Term&lt;br /&gt;55351 instances of class org.apache.lucene.index.TermInfo&lt;br /&gt;42776 instances of class org.apache.lucene.index.CompoundFileReader$FileEntry&lt;br /&gt;35981 instances of class org.apache.lucene.index.SegmentTermEnum&lt;br /&gt;15373 instances of class org.apache.lucene.store.RAMFile&lt;br /&gt;9813 instances of class org.alfresco.repo.search.impl.lucene.index.ReferenceCountingReadOnlyIndexReaderFactory$ReferenceCountingReadOnlyIndexReader$MultipleValueFieldAccessor&lt;br /&gt;9102 instances of class org.apache.lucene.index.FieldsReader$FieldForMerge&lt;br /&gt;6542 instances of class org.alfresco.repo.search.impl.lucene.index.ReferenceCountingReadOnlyIndexReaderFactory$ReferenceCountingReadOnlyIndexReader$SingleValueFieldAccessor&lt;br /&gt;5828 instances of class org.apache.lucene.store.RAMInputStream&lt;br /&gt;5789 instances of class org.apache.lucene.index.FieldInfos&lt;br /&gt;5380 instances of class org.apache.lucene.index.SegmentInfo&lt;br /&gt;5376 instances of class org.apache.lucene.index.FieldsReader&lt;br /&gt;5376 instances of class org.apache.lucene.index.SegmentReader&lt;br /&gt;5376 instances of class org.apache.lucene.index.TermInfosReader&lt;br /&gt;5375 instances of class org.apache.lucene.index.CompoundFileReader&lt;br /&gt;5359 instances of class [Lorg.apache.lucene.index.Term;&lt;br /&gt;5359 instances of class [Lorg.apache.lucene.index.TermInfo;&lt;br /&gt;3698 instances of class org.apache.lucene.store.RAMDirectory&lt;br /&gt;3698 instances of class org.apache.lucene.store.SingleInstanceLockFactory&lt;br /&gt;3610 instances of class org.apache.lucene.index.SegmentInfos&lt;br /&gt;3271 instances of class org.alfresco.repo.search.impl.lucene.index.ReferenceCountingReadOnlyIndexReaderFactory$ReferenceCountingReadOnlyIndexReader&lt;br /&gt;3271 instances of class org.alfresco.repo.search.impl.lucene.index.ReferenceCountingReadOnlyIndexReaderFactory$ReferenceCountingReadOnlyIndexReader$ListFieldAccessor&lt;br /&gt;3089 instances of class org.apache.lucene.store.FSDirectory&lt;br /&gt;2529 instances of class [Lorg.apache.lucene.index.IndexReader;&lt;br /&gt;2528 instances of class org.apache.lucene.index.MultiReader&lt;br /&gt;2356 instances of class org.apache.lucene.util.BitVector&lt;br /&gt;2132 instances of class org.apache.lucene.document.Field&lt;br /&gt;691 instances of class org.apache.lucene.document.Document&lt;br /&gt;...........&lt;br /&gt;&lt;br /&gt;I was even not sure whether it is leak or just that the memory consumption is high. If it is not a leak, then the old gen memory should stabilize somewhere. I kept on adding the folders and files and memory usage went on increasing till the point where the JVM seized to respond, as it was only busy doing FULL GC only, old gen max being full. I didn't know even then whether it is leak, as I did not test it with 4GB or 8 GB of heap memory assigned to JVM (as I did not have the resources for that too). So, for me, for 2 GB heap, it was a leak.&lt;br /&gt;&lt;br /&gt;The next step which I did was an experiment. I fresh installed Alfresco on a separate machine, and wrote a Java program to add 100 (normal) folders and 1000 (normal) files in each folder, thus total of 100000 files (1/10th of a million) to be added that to on a JVM on which I allocated only 1 GB of RAM. I did not deploy my app on that JVM. Again, each file was an xml file, and two files contents differ by a guid only. The Java program used Webservice interface to call the Alfresco APIs for adding files and folders. When I started the JVM, the old gen memory was 90 MB. I ran the program and it successfully completed. The old gen memory reached up to 600m but it settled at 240m. What did it mean???? It meant to me that something is wrong, what it is - I did not know and I had no clue at all. Alfresco seems to be definitely working fine, as I was able to add 100000 files easily, and in my app case for 4000 files, it was taking up too much memory. The difference between the two cases were a&gt; in my app case, I was also creating one folder per file b&gt; in my app case, I was communicating to Alfresco using plug-in (webscript), and in the experiment scenario, I was using WebService c&gt; in my app case, I was doing everything in transaction (inside our plug-in, each request was catered inside transaction) d&gt; in my app case, we have additional metadata, and aspects for files and folders.&lt;br /&gt;&lt;br /&gt;I analyzed the dump of experimental JVM and I found the instance count of Lucene objects as below:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4279 instances of class org.apache.lucene.index.Term&lt;br /&gt;4171 instances of class org.apache.lucene.index.TermInfo&lt;br /&gt;1723 instances of class org.apache.lucene.index.FieldInfo&lt;br /&gt;533 instances of class org.apache.lucene.index.CompoundFileReader$CSIndexInput&lt;br /&gt;373 instances of class org.apache.lucene.index.TermBuffer&lt;br /&gt;302 instances of class org.apache.lucene.index.SegmentReader$Norm&lt;br /&gt;234 instances of class org.apache.lucene.store.RAMFile&lt;br /&gt;85 instances of class org.apache.lucene.store.RAMDirectory&lt;br /&gt;63 instances of class org.apache.lucene.index.FieldInfos&lt;br /&gt;...........&lt;br /&gt;&lt;br /&gt;Don't know, why is this difference, but one thing was sure to me : it is something related to indexing/Lucene&lt;br /&gt;&lt;br /&gt;I now used netBeans profiler. It took me much time to get it work with my JVM.&lt;br /&gt;Here is the initial snapshot:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_8q4pCVHWDQw/S2HQ5-7kavI/AAAAAAAAAAM/j4JGMw9K-yg/s1600-h/started.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5431852320149498610" style="FLOAT: left; MARGIN: 0pt 10px 10px 0pt; CURSOR: pointer" alt="" src="http://3.bp.blogspot.com/_8q4pCVHWDQw/S2HQ5-7kavI/AAAAAAAAAAM/j4JGMw9K-yg/s320/started.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This time I added just 10 custom folders and files. netBeans showed that after the folders and files have been added, some amount of memory was retained (after doing GC for some times ). Much of this retained memory was attributed to byte[].&lt;br /&gt;Here is how, it looked like:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_8q4pCVHWDQw/S2HSjJQIs2I/AAAAAAAAAAU/Yd4Y9ptppWA/s1600-h/after.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5431854126806381410" style="WIDTH: 320px; CURSOR: pointer; HEIGHT: 222px" alt="" src="http://4.bp.blogspot.com/_8q4pCVHWDQw/S2HSjJQIs2I/AAAAAAAAAAU/Yd4Y9ptppWA/s320/after.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I looked the stack trace of byte[]:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_8q4pCVHWDQw/S2HSz7bk5PI/AAAAAAAAAAc/nLDROskkIno/s1600-h/byte.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5431854415154046194" style="WIDTH: 400px; CURSOR: pointer; HEIGHT: 187px" alt="" src="http://3.bp.blogspot.com/_8q4pCVHWDQw/S2HSz7bk5PI/AAAAAAAAAAc/nLDROskkIno/s400/byte.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So, it looked like to me that mergeIndexes() should be investigated further. This was inside Alfresco. I opened the source code of Alfresco and traversed (statically) the stack chain upwards till buildReferenceCountingIndexReader function. Inside the function, what was causing new RAMDirectory to be created was the check size &gt; config.getMaxDocsForInMemoryMerge() to return false, that is getMaxDocsForInMemoryMerge should be returning higher value. I searched for "maxDocsForInMemoryMerge" string in the Alfresco source code, and actually found a variable of the same name which was default initialized to 10000. Now i wanted to set it to some small value (around 100) but I did not find any documentation in Lucene Configuration section (http://wiki.alfresco.com/wiki/Full-Text_Search_Configuration), so I thought to build the class with initializer setting it to 100 rather than 10000. My source code was not getting built, there were many errors. I just thought of googling the string "maxDocsForInMemoryMerge" and I actually found what I was looking for : &lt;a href="http://issues.alfresco.com/jira/browse/ETHREEOH-1147"&gt;http://issues.alfresco.com/jira/browse/ETHREEOH-1147&lt;/a&gt;&lt;br /&gt;There is a memory issue in Alfresco and the link gives the workaround.&lt;br /&gt;&lt;br /&gt;So here is the workaround:&lt;br /&gt;&lt;br /&gt;For default Alfresco installation add lucene.indexer.maxDocsForInMemoryMerge=0 in the file tomcat/webapps/alfresco/WEB-INF/classes/alfresco/repository.properties. For JBoss installation, add the string to conf/alfresco/extension/repository.properties file.&lt;br /&gt;&lt;br /&gt;Also create a file named custom-lucene-indexer-context.xml in the same directory as above with the following content:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- Core and miscellaneous bean definitions --&amp;gt;&lt;br /&gt;&amp;lt;beans&amp;gt;&lt;br /&gt;&amp;lt;bean id="admLuceneIndexerAndSearcherFactory"&lt;br /&gt;class="org.alfresco.repo.search.impl.lucene.ADMLuceneIndexerAndSearcherFactory"&amp;gt;&lt;br /&gt;&amp;lt;property name="nodeService"&amp;gt;&lt;br /&gt;&amp;lt;ref bean="mlAwareNodeService" /&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="tenantService"&amp;gt;&lt;br /&gt;&amp;lt;ref bean="tenantService"/&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="dictionaryService"&amp;gt;&lt;br /&gt;&amp;lt;ref bean="dictionaryService" /&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="nameSpaceService"&amp;gt;&lt;br /&gt;&amp;lt;ref bean="namespaceService" /&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="indexRootLocation"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;${dir.indexes}&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="contentService"&amp;gt;&lt;br /&gt;&amp;lt;ref bean="contentService" /&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="queryRegister"&amp;gt;&lt;br /&gt;&amp;lt;ref bean="queryRegisterComponent" /&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="maxAtomicTransformationTime"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;${lucene.maxAtomicTransformationTime}&amp;lt;/value&amp;gt; &amp;lt;!-- milliseconds allowed for inline text transformation --&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="queryMaxClauses"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;${lucene.query.maxClauses}&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="indexerBatchSize"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;${lucene.indexer.batchSize}&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="lockDirectory"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;${dir.indexes.lock}&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="indexerMaxFieldLength"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;${lucene.indexer.maxFieldLength}&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="writeLockTimeout"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;${lucene.write.lock.timeout}&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="commitLockTimeout"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;${lucene.commit.lock.timeout}&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="lockPollInterval"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;${lucene.lock.poll.interval}&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="defaultMLIndexAnalysisMode"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;EXACT_LANGUAGE_AND_ALL&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="defaultMLSearchAnalysisMode"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;EXACT_LANGUAGE_AND_ALL&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="threadPoolExecutor"&amp;gt;&lt;br /&gt;&amp;lt;ref bean="indexThreadPoolExecutor"&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="bulkLoader"&amp;gt;&lt;br /&gt;&amp;lt;ref bean="hibernateL1CacheBulkLoader"&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="maxDocsForInMemoryMerge"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;beans&gt;&lt;bean class="org.alfresco.repo.search.impl.lucene.ADMLuceneIndexerAndSearcherFactory" id="admLuceneIndexerAndSearcherFactory"&gt;&lt;property name="nodeService"&gt;&lt;property name="tenantService"&gt;&lt;property name="dictionaryService"&gt;&lt;property name="nameSpaceService"&gt;&lt;property name="contentService"&gt;&lt;property name="queryRegister"&gt;&lt;/property&gt;&lt;beans&gt;&lt;bean class="org.alfresco.repo.search.impl.lucene.ADMLuceneIndexerAndSearcherFactory" id="admLuceneIndexerAndSearcherFactory"&gt;&lt;property name="nodeService"&gt;&lt;property name="tenantService"&gt;&lt;property name="dictionaryService"&gt;&lt;property name="nameSpaceService"&gt;&lt;/property&gt;&lt;br /&gt;This should fix your memory leak problem (if you are also suffering from the same problem)&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;I hope this fix doesn't break anything else.&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Now if someone can figure out why this issue doesn't arise when someone load tests Alfresco with over 1mn documents.&lt;br /&gt;To me, following can be the key differences between the test case and my case (if someone can get a clue from it):&lt;br /&gt;- we have derived file and folder types to define our own types&lt;br /&gt;- we are using good amount of metadata (15-20 additional properties on each file/folder node)&lt;br /&gt;- we are calling Alfresco APIs using our webscript plug-in to Alfresco.&lt;br /&gt;- inside webscript plug-in, we wrap each call within transaction&lt;br /&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/bean&gt;&lt;/beans&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/property&gt;&lt;/bean&gt;&lt;/beans&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261744746504206620-6874957799883141830?l=sangosthi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sangosthi.blogspot.com/feeds/6874957799883141830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sangosthi.blogspot.com/2010/01/alfresco-is-taking-too-much-memory.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/6874957799883141830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/6874957799883141830'/><link rel='alternate' type='text/html' href='http://sangosthi.blogspot.com/2010/01/alfresco-is-taking-too-much-memory.html' title='Alfresco is taking too much memory : Memory Leak'/><author><name>Anil</name><uri>http://www.blogger.com/profile/09580098741890536509</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_8q4pCVHWDQw/S2HQ5-7kavI/AAAAAAAAAAM/j4JGMw9K-yg/s72-c/started.JPG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7261744746504206620.post-62195709691220692</id><published>2009-04-18T23:09:00.000-07:00</published><updated>2009-04-18T23:42:56.241-07:00</updated><title type='text'>Calling Web Services from C++</title><content type='html'>&lt;span style="font-family:arial;"&gt;Hi,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;This post is about calling Web Services from C++. I faced this requirement when I had to access Alfresco from C++. So, I am writing it in the context of Alfresco.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;I have been working on MS Visual C++ for long, never worked on Java and JavaScript. I had to use Alfresco as back-end and I had to provide client interface UI from my app (and not from browser) which is written in C++. Common tasks, which I required, include:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;ul&gt;&lt;li&gt;Authentication, if possible secure&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Listing all the folders and files on Alfresco Server&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Getting properties of files ( like Last Modified time )&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Creating/deleting/moving/updating files and folders &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Checkin/Checkout/Get Current Version/Revert to old version&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Getting all the versions of a node&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Able to get a particular version (other than the current one ) of a node on my client machine ( very important )&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;etc&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:arial;"&gt;I explored/googled and found that some of the tasks listed above can be done via WebDAV and Alfresco supports WebDAV interface. I had a WebDAV libraray, using which can do things like create (put) a file on the server. But my library doesn't support versioning and I doubt that Alfresco supports versioning using WebDAV ( Delta V Extension to be precise ).&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Now, in order to accomplish all the tasks, what can I do ? As I have already stated, I had to stick to C++, can't switch to Java. I found that Alfresco also supports much of it's functionality via Web Services. I had never used Web Services before and had a very basic idea. I had so many questions. &lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Does all the requirements listed above can be achieved via Web Services ?  &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;If yes, from where to start ?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;what are all the Web methods exposed by Alfresco ?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;how to create (put) a file on server using Web Service ? &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Does Alfresco provides support to get a particular version (other than the current one ) of a node on client machine ?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Are there other means of accessing Alfresco ?&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;I came to know that Alfresco also supports FTP interface, and that it also supports Web Scripts. So, if I have HTTP Client available, I could call some methods using Web Scripts. I didn't explore that option, as I was more interested in calling Alfresco Web Services.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Arial;"&gt;I did extensive googling and found that till Visual Studio 2005, there was an option of adding a Web reference to VC++ project. By doing so, Visual Studio automatically generates stubs for a web service given it's .wsdl file. This functionality is now discontinued ( for VC++ projects ) in VS 2008, which was installed on my system. On another system I had VS 2005 installed, and I tried my luck there with the .wsdl files supplied with Alfresco ( VersioningService.wsdl to be specific ), but it was not able to parse the file and was unable to generate stubcode. Googling revealed that stub code for C++ is generated using SPROXY.EXE, and this tool is very outdated, not conforming to newer standards. Microsoft do not recommend calling Web Service from native C++ any more, rather they suggest using WSDL.EXE to generate code in .Net compatible languages ( like managed C++, VB .Net , C# etc ). WSDL.EXE seems updated and was able to parse the alfresco .wsdl file without error. MS has made source code of SPROXY public. As I was interested in getting stub code for native C++, I downloaded the source code for SPROXY, compiled it and tried my luck, but all in vain ( I didn't have that much time to understand the source code, wsdl syntax,SOAP syntax and a lot to modify the source code ).Further googling helped in finding a toolkit gSOAP, which does the same thing as SPROXY.EXE does. I downloaded the same, compiled it ( needed to install flex and bison, faced so many issues, and it took time! ) to get the executables. I then gave gSOAP the input VersioningService.wsdl and it returned the code. The generated code looks too obscure to me, any ways I tried (just playing) to call checkOut function with input parameters. The error code which I got returned was saying Server Internal error. I couldn't get much info about the error. Also, I had no idea, how to specify parameters for the function checkOut, namely repositoryId and documentId, no idea whatsoever, how can I get the input values to supply. I then turned to C#. I added the web reference to VersioningService.wsdl and it generated C# code for the stub. I called the method checkOut() with empty input parameters and it threw an exception. I Examined the exception, the text was something like target service is null, and there was a big stack trace of server java code ( seemed like some settings need to done, don't know how and where) . The call to web service generated following message. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;POST /alfresco/api HTTP/ 1.1&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;User-Agent:  Mozilla/4.0 (compatible; MSIE 6 .0; MS Web Services Client Proto col 2.0.50727.83 2)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;VsDebuggerCausalityData: [some lengthy string]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;Content-Type: text/xml; charset=utf-8&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;SOAPAction : ""&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;Host: server-pc:8080&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;Content-Length: 363&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;Expect: 100-continue&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;Connection: Keep-Alive&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;?xml version=" 1.0" encoding="utf-8"?&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;soap:envelope soap ="http://schemas.xmlsoap.org/soap/envelope/" xsi="http://www.w3.org/2001/XMLSchema-instance" xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;soap:body&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;checkout xmlns="http://www.cmis.org/ 2008/05"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;repositoryid&gt;xyz&lt;/repositoryid&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;documentid&gt;abc&lt;/documentid&gt;&lt;/checkout&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/soap:Body&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/soap:Envelope&gt;             &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;I had no idea whether the generated Soap was correct. I had so many doubts.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;I kept on exploring the things and found some answers.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;First thing is that the Alfresco APIs are exposed at &lt;/span&gt;&lt;a class="postlink" href="http://server-pc:8080/alfresco/api/"&gt;&lt;span style="font-family:arial;"&gt;http://server-pc:8080/alfresco/api/&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:arial;"&gt;&lt;webservicename&gt;, for example &lt;/span&gt;&lt;a class="postlink" href="http://server-pc:8080/alfresco/api/AuthenticationService"&gt;&lt;span style="font-family:arial;"&gt;http://server-pc:8080/alfresco/api/AuthenticationService&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:arial;"&gt; ( name of the service can be found in.wsdl file ). I figured this out and tried with &lt;/span&gt;&lt;a class="postlink" href="http://server-pc:8080/alfresco/api/VersioningService"&gt;&lt;span style="font-family:arial;"&gt;http://server-pc:8080/alfresco/api/VersioningService&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:arial;"&gt;, only to find out that this service was not exposed. I think not all of .wsdl files have their corresponding services exposed. For repositryID and documentID thing, I would suggest not use VersioningService at all. Rather use AuthoringService for CheckOut and similar sort of things. You need to use AuthenticationService first to start a session.There is one more thing needs mention. All Web Services exposed by Alfresco seems secure, menas they will require security token in the SOAP header ( obtained from AuthenticationService ). &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;The moral of the story is, In C++, without proper support of any library, it can be a great pain working with Web Services.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;If I get time, I will try to write a library in C++ to provide support for Web Services. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Arial;"&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261744746504206620-62195709691220692?l=sangosthi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sangosthi.blogspot.com/feeds/62195709691220692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sangosthi.blogspot.com/2009/04/calling-web-services-from-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/62195709691220692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/62195709691220692'/><link rel='alternate' type='text/html' href='http://sangosthi.blogspot.com/2009/04/calling-web-services-from-c.html' title='Calling Web Services from C++'/><author><name>Anil</name><uri>http://www.blogger.com/profile/09580098741890536509</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7261744746504206620.post-8013401759739182116</id><published>2009-04-16T11:50:00.000-07:00</published><updated>2009-04-22T03:33:45.231-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Alfresco'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Repository Web Service'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Calling Alfresco Web Services from C#</title><content type='html'>&lt;span style="font-family:arial;"&gt;Hi,&lt;br /&gt;I am starting this topic to share my experience of calling Alfresco Web Services from .Net, the problems which you may face and the solutions.&lt;br /&gt;I first started with scratch. I created a C# project and added a Web reference to AuthenticationService (authentication-service.wsdl) , and VersioningService (VersioningService.wsdl).&lt;br /&gt;Then I wrote following lines of code&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;WindowsApplication1.AuthenticationService.AuthenticationService asvc = new WindowsApplication1.AuthenticationService.AuthenticationService();&lt;br /&gt;AuthenticationResult ar = asvc.startSession("admin", "admin");&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;It worked fine. Examining ar showed the token returned by Alfresco.&lt;br /&gt;I then wrote the following lines&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;VersioningService vs = new VersioningService();&lt;br /&gt;string repID = ("xyz");&lt;br /&gt;string docID = ("abc");&lt;br /&gt;string docRefId = docID;&lt;br /&gt;bool b = vs.checkOut(repID, ref docRefId);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;I was expecting an exception to be generated for giving invalid parameters, but the exception generated was about target service is null. It seems VersioningService is not exposed at URL/alfresco/api/VersioningService.&lt;br /&gt;I then tried to add reference to RepositoryService (repository-service.wsdl ). Visual Studio reported a problem:&lt;br /&gt;The document was understood, but it could not be processed. The WSDL document contains links that could not be resolved.&lt;br /&gt;The solution was to remove the nillable attributes in cml.xsd files. After doing that, it was able to add the reference. I then wrote the following lines&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;RepositoryService rs = new RepositoryService();&lt;br /&gt;rs.Credentials = asvc.Credentials;&lt;br /&gt;Store[] stores = rs.getStores();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;The exception which got generated was about Unauthorization. It was simple to figure out the cause, I was not passing in the security token, it was hard to figure out how to pass that. I was stuck.&lt;br /&gt;I then googled and found out that there is demo project called dotNet2 for calling Alfresco APIs from .Net. I downloaded the same and tried to build it. It turned out that there was a missing reference to Microsoft.Web.Services3 assembly. Solution was to install MS WSE 3. So well and good.&lt;br /&gt;I tried building the solution and there was a problem:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Error 1 The best overloaded method match for 'WebServiceFactory.addSecurityHeader(Microsoft.Web.Services3.WebServicesClientProtocol)' has some invalid arguments&lt;br /&gt;Error 2 Argument '1': cannot convert from 'Alfresco.RepositoryWebService.RepositoryService' to 'Microsoft.Web.Services3.WebServicesClientProtocol'&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;I tried google to find out the solution for this, and I got one but it didn't work. A close observation revealed that addSecurityHeader was expecting Microsoft.Web.Services3.WebServicesClientProtocol object the service objects which we were passing were derived from SoapHttpClientProtocol class. I found that Microsoft.Web.Services3.WebServicesClientProtocol itself derives from SoapHttpClientProtocol, so I just let the web services class derive from Microsoft.Web.Services3.WebServicesClientProtocol and it worked!!&lt;br /&gt;Then I tried to call getStores() method of RepositoryWebService and I again encountered exception. There was some problem in class instantiation from the returned response. Close observation again revealed the problem. The StoreEnum of RepositoryWebService was defined like this&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public enum StoreEnum {&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;workspace,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;versionStore,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;user,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;search,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;http,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;system,&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;I extended this enum to look like this&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public enum StoreEnum {&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;workspace,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;versionStore,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;user,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;search,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;http,&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;system,&lt;br /&gt;archive,&lt;br /&gt;avm,&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;And after doing this, the call succeeded&lt;br /&gt;Now my task was to test checking out of a selected file and getting a previous version of a selected file. After many hit and trials, I got it working and here is the reference code (I added private AuthoringService authoringService; to Browse class)&lt;br /&gt;This is the code for Checking Out a selected file:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;private void CheckOut_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;ListViewItem item = listViewBrowse.SelectedItems[0];&lt;br /&gt;if (item != null)&lt;br /&gt;{&lt;br /&gt;ResultSetRowNode node = item.Tag as ResultSetRowNode;&lt;br /&gt;if (node != null)&lt;br /&gt;{&lt;br /&gt;if (node.type.Contains("folder") == false)&lt;br /&gt;{&lt;br /&gt;// Create the reference for the node selected&lt;br /&gt;Alfresco.AuthoringWebService.Store spacesStore2 = new Alfresco.AuthoringWebService.Store();&lt;br /&gt;spacesStore2.scheme = Alfresco.AuthoringWebService.StoreEnum.workspace;&lt;br /&gt;spacesStore2.address = "SpacesStore";&lt;br /&gt;Alfresco.AuthoringWebService.Reference reference = new Alfresco.AuthoringWebService.Reference();&lt;br /&gt;reference.store = spacesStore2;&lt;br /&gt;reference.uuid = node.id;&lt;br /&gt;// Lets try to check out&lt;br /&gt;Alfresco.AuthoringWebService.Predicate predicate = new Alfresco.AuthoringWebService.Predicate();&lt;br /&gt;predicate.Items = new Object[] { reference };&lt;br /&gt;Alfresco.AuthoringWebService.ParentReference pr = new Alfresco.AuthoringWebService.ParentReference();&lt;br /&gt;pr.store = spacesStore2; ;&lt;br /&gt;pr.uuid = this.currentReference.uuid;&lt;br /&gt;pr.associationType = Constants.ASSOC_CONTAINS;&lt;br /&gt;pr.childName = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL,item.Text);&lt;br /&gt;this.authoringService.checkout(predicate, pr);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;// show message that a folder has been selected&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;And this is the code for getting the original version of a file&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;private void GetOriginalVersion_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;Alfresco.RepositoryWebService.Store[] stores = this.repoService.getStores();&lt;br /&gt;Alfresco.RepositoryWebService.Store vStore = stores[3]; // from data,I found out that this is for Versioned store&lt;br /&gt;ListViewItem item = listViewBrowse.SelectedItems[0];&lt;br /&gt;if (item != null)&lt;br /&gt;{&lt;br /&gt;ResultSetRowNode node = item.Tag as ResultSetRowNode;&lt;br /&gt;if (node != null)&lt;br /&gt;{&lt;br /&gt;if (node.type.Contains("folder") == false)&lt;br /&gt;{&lt;br /&gt;// Create the reference for the node selected&lt;br /&gt;Alfresco.AuthoringWebService.Store spacesStore2 = new Alfresco.AuthoringWebService.Store();&lt;br /&gt;spacesStore2.scheme = Alfresco.AuthoringWebService.StoreEnum.workspace;&lt;br /&gt;spacesStore2.address = "SpacesStore";&lt;br /&gt;Alfresco.AuthoringWebService.Reference reference = new Alfresco.AuthoringWebService.Reference();&lt;br /&gt;reference.store = spacesStore2;&lt;br /&gt;reference.uuid = node.id;&lt;br /&gt;VersionHistory VH = this.authoringService.getVersionHistory(reference);&lt;br /&gt;int i = 0;&lt;br /&gt;char[] temp = new char[1];&lt;br /&gt;temp[0] = '0';&lt;br /&gt;string versions = new string(temp);&lt;br /&gt;Alfresco.AuthoringWebService.Version first;&lt;br /&gt;foreach (Alfresco.AuthoringWebService.Version version inVH.versions)&lt;br /&gt;{&lt;br /&gt;if (i == 0)&lt;br /&gt;first = version;&lt;br /&gt;versions += version.label + (";") + version.id.uuid +(";");&lt;br /&gt;}&lt;br /&gt;{&lt;br /&gt;// Create the reference for the node selected&lt;br /&gt;Alfresco.ContentWebService.Store spacesStore3 = new Alfresco.ContentWebService.Store();&lt;br /&gt;spacesStore3.scheme = Alfresco.ContentWebService.StoreEnum.versionStore;&lt;br /&gt;spacesStore3.address = vStore.address;&lt;br /&gt;Alfresco.ContentWebService.Reference reference1 = newAlfresco.ContentWebService.Reference();&lt;br /&gt;reference1.store = spacesStore3;&lt;br /&gt;reference1.uuid = VH.versions[VH.versions.GetUpperBound(0)].id.uuid;&lt;br /&gt;// Lets try and get the content&lt;br /&gt;Alfresco.ContentWebService.Predicate predicate = newAlfresco.ContentWebService.Predicate();&lt;br /&gt;predicate.Items = new Object[] { reference1 };&lt;br /&gt;Content[] contents = this.contentService.read(predicate,"{http://www.alfresco.org/model/content/1.0}content");&lt;br /&gt;Content content = contents[0];&lt;br /&gt;if (content.url != null &amp;amp;&amp;amp; content.url.Length != 0)&lt;br /&gt;{&lt;br /&gt;string url = content.url + "?ticket=" + AuthenticationUtils.Ticket;&lt;br /&gt;webBrowser.Url = new Uri(url);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;// show message that a folder has been selected&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;Here is the link for the Holy Grail dotNet2 Demo project&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://forge.alfresco.com/frs/download.php/80/alfresco-dotNet-0.2Beta.zip"&gt;http://forge.alfresco.com/frs/download.php/80/alfresco-dotNet-0.2Beta.zip&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;And here is the the project which will allow you to do a Check Out and Get Latest version. it is an extended version of dotNet2 Demo project. You should be able to head start with it. Change the Alfresco Server location as per your requirement.&lt;/p&gt;&lt;p&gt;&lt;a href="http://cid-f49e53911f11f3b1.skydrive.live.com/self.aspx/.Public/Technical/Alfresco/alfresco-dotNet-0.2Beta-Modified.zip"&gt;http://cid-f49e53911f11f3b1.skydrive.live.com/self.aspx/.Public/Technical/Alfresco/alfresco-dotNet-0.2Beta-Modified.zip&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Thanks,&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261744746504206620-8013401759739182116?l=sangosthi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sangosthi.blogspot.com/feeds/8013401759739182116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sangosthi.blogspot.com/2009/04/calling-alfresco-web-services-from-c.html#comment-form' title='19 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/8013401759739182116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7261744746504206620/posts/default/8013401759739182116'/><link rel='alternate' type='text/html' href='http://sangosthi.blogspot.com/2009/04/calling-alfresco-web-services-from-c.html' title='Calling Alfresco Web Services from C#'/><author><name>Anil</name><uri>http://www.blogger.com/profile/09580098741890536509</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>19</thr:total></entry></feed>
