Hi all, can anyone give me an example how to call an external web service from Velocity code and evaluate the result? The question may be stupid, but I'm new to XWiki, Velocity, and WEb programming... Many thanks in advance, Ute -- View this message in context: http://www.nabble.com/Calling-a-web-service-from-Velocity-tf3915895.html#a11... Sent from the XWiki- Users mailing list archive at Nabble.com.
Sorry for posting this again, but I had the bad feeling that my first post didn't make it into the mailing list. Unfortunately I'm still struggling with making a call to a Web service... Cheers, Ute Ute wrote:
Hi all,
can anyone give me an example how to call an external web service from Velocity code and evaluate the result? The question may be stupid, but I'm new to XWiki, Velocity, and WEb programming...
Many thanks in advance, Ute
-- View this message in context: http://www.nabble.com/Calling-a-web-service-from-Velocity-tf3915895.html#a11... Sent from the XWiki- Users mailing list archive at Nabble.com.
I've used a bare-bones XWiki plugin to instantiate a webservice client using axis, then call that from velocity. XWiki is bundled with axis.jar, so there might be a more "native" way, but I've never seen it documented if there is. I think there might be a way to Just Make It Happen in Groovy just by passing in the web service URL, but I haven't investigated that. Has any one tried it? http://docs.codehaus.org/display/GROOVY/Groovy+SOAP The steps I did went something like this: 1) Use Axis's WSDL2Java to create the client. Something like: java org.apache.axis.wsdl.WSDL2Java --helperGen --output src http://theurl/to/the/service?WSDL That command will place the java classes under a directory called "src". 2) The create your plugin using the online example, and add a method to create a connection to your webservice. This is the method I have, except the class name is changed. Axis created all the needed classes in the previous step. Just import them. public YourWebService getWebService() throws ServiceException { YourWebService ServiceLocator imlocator = new YourWebService ServiceLocator(); YourWebService ims = null; try { //Actually get a service ims = imlocator.getYourWebService(); //cast it as the stub to set the password //YourWebService Stub stub = (YourWebService Stub)ims; //TODO: Set username and password //stub._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, username); //stub._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, password); } catch (ServiceException se) { mLogger.debug("Big fat error in plugin: " + se.getMessage()); throw se; } return ims; } 3) Build and copy the needed jar files to lib. 4) #set($webservice = $xwiki.yourplugin.getWebService()) $webservice.method1() $webservice.method2("blah") $webservice.method3() -Tom -- Tom Kliethermes eSupport Initiatives IBM Information Management (913) 599-7240 Fax: (913) 599-8590 http://www.ibm.com/software/data Ute <ute_gerlach@arcor.de> 06/15/2007 01:33 PM Please respond to xwiki-users@objectweb.org To xwiki-users@objectweb.org cc Subject Re: [xwiki-users] Calling a web service from Velocity Sorry for posting this again, but I had the bad feeling that my first post didn't make it into the mailing list. Unfortunately I'm still struggling with making a call to a Web service... Cheers, Ute Ute wrote:
Hi all,
can anyone give me an example how to call an external web service from Velocity code and evaluate the result? The question may be stupid, but I'm new to XWiki, Velocity, and WEb programming...
Many thanks in advance, Ute
-- View this message in context: http://www.nabble.com/Calling-a-web-service-from-Velocity-tf3915895.html#a11... Sent from the XWiki- Users mailing list archive at Nabble.com. -- You receive this message as a subscriber of the xwiki-users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
participants (2)
-
Thomas Kliethermes -
Ute