{"id":442,"date":"2012-05-25T15:21:40","date_gmt":"2012-05-25T13:21:40","guid":{"rendered":"http:\/\/www.bestcoder.net\/?p=442"},"modified":"2012-10-14T13:28:41","modified_gmt":"2012-10-14T13:28:41","slug":"call-webservice-from-java-ssjs-xpages-xsnippets","status":"publish","type":"post","link":"http:\/\/www.bestcoder.net\/?p=442","title":{"rendered":"Call WebService from Java (SSJS &#8211; XPages) (XSnippets)"},"content":{"rendered":"<p><a href=\"http:\/\/openntf.org\/XSnippets.nsf\" target=\"_blank\"><img decoding=\"async\" style=\"background-color: black; vertical-align: middle; margin-right: 5px; margin-top: 5px; margin-bottom: 5px;\" src=\"http:\/\/openntf.org\/XSnippets.nsf\/OpenNTFLogo.png\" alt=\"\" width=\"140px\" height=\"20px\" \/><\/a><\/p>\n<p><a title=\"Open XSnippet - OpenNTF\" href=\"http:\/\/openntf.org\/XSnippets.nsf\/snippet.xsp?id=call-webservice-from-java-ssjs-xpages\" target=\"_blank\">Open XSnippet &#8211; OpenNTF<\/a><\/p>\n<p><strong>Development GUIDE<\/strong><\/p>\n<p>1. Create WSDL Stub Files using wsimport<\/p>\n<p>1.1. Open Command Prompt (Run &gt; cmd)<\/p>\n<p>&#8230;<\/p>\n<p><!--:--><!--more--><!--:en--><\/p>\n<p>1.2. write &#8220;wsimport -d C:\\FakeWSFiles -keep http:\/\/www.bestcoder.net:80\/samples\/FakeWS?wsdl&#8221;<\/p>\n<p>&#8220;C:\\FakeWSFiles -&gt; Stub Files will be stored in this folder&#8221;<\/p>\n<p>1.4. If everything is fine, you will see these messages on cmd.<\/p>\n<p>parsing WSDL&#8230;<br \/>\ngenerating code&#8230;<br \/>\ncompiling code&#8230;<\/p>\n<p>2. Open Domino Designer, goto XPages Perspective, Open Your XPages Application and goto Package Explorer<\/p>\n<p>2.1. Create src folder under WebContent\\WEB-INF<\/p>\n<p>2.2. Right click on src and click on Build Path &gt; Use as Source Folder menu.<\/p>\n<p>2.3. Goto C:\\FakeWSFiles folder and open *.java file in notepad and copy package name.<\/p>\n<p>2.4. Right click on WebContent\\WEB-INF\\src folder and New &gt; Other &gt; Java (Package)<\/p>\n<p>2.5. Paste package name on next screen (Name field)<\/p>\n<p>2.6. Click on Finish.<\/p>\n<p>2.7. Goto C:\\FakeWSFiles folder and copy all *.java files. (Select All *.Java Files and CTRL + C)<\/p>\n<p>2.8. Select your Package under WebContent\\WEB-INF\\src and click CTRL + V<\/p>\n<p>3. Now, all Java files is copied under your package.<\/p>\n<p>4. Create another Class and write your own code inspired by this sample code.<\/p>\n<p>Finally,<\/p>\n<p>5. Add grant for related class at Domino JVM Security file<\/p>\n<p>Open java.policy file from &#8230;\\IBM\\Lotus\\Domino\\jvm\\lib\\security<br \/>\nAppend grant string after \u201c\/\/ Notes java code gets all permissions\u201d<br \/>\ngrant {<br \/>\npermission java.lang.RuntimePermission &#8220;setContextClassLoader&#8221;;<br \/>\npermission java.lang.reflect.ReflectPermission &#8220;suppressAccessChecks&#8221;;<br \/>\n};<br \/>\nOr<br \/>\ngrant {<br \/>\npermission java.security.AllPermission;<br \/>\n};<br \/>\ntell http q<br \/>\nload http<\/p>\n<p>\/\/ *******************<br \/>\nUSAGE in SSJS under Button (Server Options : Full Update) : com.domino.openntf.WSFake.Exec()<br \/>\n\/\/ *******************<!--:--><!--:tr--><\/p>\n<p>1.2. write &#8220;wsimport -d C:\\FakeWSFiles -keep http:\/\/www.bestcoder.net:80\/samples\/FakeWS?wsdl&#8221;<\/p>\n<p>&#8220;C:\\FakeWSFiles -&gt; Stub Files will be stored in this folder&#8221;<\/p>\n<p>1.4. If everything is fine, you will see these messages on cmd.<\/p>\n<p>parsing WSDL&#8230;<\/p>\n<p>generating code&#8230;<\/p>\n<p>compiling code&#8230;<\/p>\n<p>2. Open Domino Designer, goto XPages Perspective, Open Your XPages Application and goto Package Explorer<\/p>\n<p>2.1. Create src folder under WebContent\\WEB-INF<\/p>\n<p>2.2. Right click on src and click on Build Path &gt; Use as Source Folder menu.<\/p>\n<p>2.3. Goto C:\\FakeWSFiles folder and open *.java file in notepad and copy package name.<\/p>\n<p>2.4. Right click on WebContent\\WEB-INF\\src folder and New &gt; Other &gt; Java (Package)<\/p>\n<p>2.5. Paste package name on next screen (Name field)<\/p>\n<p>2.6. Click on Finish.<\/p>\n<p>2.7. Goto C:\\FakeWSFiles folder and copy all *.java files. (Select All *.Java Files and CTRL + C)<\/p>\n<p>2.8. Select your Package under WebContent\\WEB-INF\\src and click CTRL + V<\/p>\n<p>3. Now, all Java files is copied under your package.<\/p>\n<p>4. Create another Class and write your own code inspired by this sample code.<\/p>\n<p>Finally,<\/p>\n<p>5. Add grant for related class at Domino JVM Security file<\/p>\n<p>Open java.policy file from &#8230;\\IBM\\Lotus\\Domino\\jvm\\lib\\security<\/p>\n<p>Append grant string after \u201c\/\/ Notes java code gets all permissions\u201d<\/p>\n<p>grant {<\/p>\n<p>permission java.lang.RuntimePermission &#8220;setContextClassLoader&#8221;;<\/p>\n<p>permission java.lang.reflect.ReflectPermission &#8220;suppressAccessChecks&#8221;;<\/p>\n<p>};<\/p>\n<p>Or<\/p>\n<p>grant {<\/p>\n<p>permission java.security.AllPermission;<\/p>\n<p>};<\/p>\n<p>tell http q<\/p>\n<p>load http<\/p>\n<p>\/\/ *******************<\/p>\n<p>USAGE in SSJS under Button (Server Options : Full Update) : com.domino.openntf.WSFake.Exec()<\/p>\n<p>\/\/ *******************<!--:--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Open XSnippet &#8211; OpenNTF Development GUIDE 1. Create WSDL Stub Files using wsimport 1.1. Open Command Prompt (Run &gt; cmd) &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,22,36,28],"tags":[44,30,42],"class_list":["post-442","post","type-post","status-publish","format-standard","hentry","category-development","category-lotus-notes","category-openntf","category-xpages","tag-webservices","tag-xpages-2","tag-xsnippets","entry","has-more-link"],"_links":{"self":[{"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/posts\/442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=442"}],"version-history":[{"count":10,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/posts\/442\/revisions"}],"predecessor-version":[{"id":566,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/posts\/442\/revisions\/566"}],"wp:attachment":[{"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=442"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}