Invoking java service from jsp

Hi,

How to invoke a Java service from a jsp? I have a “Test” java service which performs a concatenation. I want to do this from the webbased form. How to call the service??

Thanks in advance,
Padmanaban

In your JSP use this tag to call a wm service:
“<webm:invoke>” - inside the tag write serviceName=“folderName:Test”

Make sure you include the tag lib at the begining of JSP:
taglib uri=“http://webm-taglib.tld” prefix=“webm”
For detail, pls look at documentation.

Hope this helps

Thanks Ashis for the reply.
Where can I find the documentation on this?

And documentation on,

  1. registering a service in an application server
  2. invoking the registered service from a JSP which is deployed in that application server.

Regards,
Padmanaban

We can find in webMethods JavaServer Pages Developers Guide…

Hi,
I was able to successfully invoke a service, which does not take any input from the user.
When I tried to pass a parameter to a service from the JSP, i got struck up. Which tag I shd use? Can anyone suggest a link or document for this? (The documents I referred have not talked abt this)

Thanks,
Padmanaban

Hi, Padmanaban.

I wrote an article for the webMethods Ezine this month that may be helpful for you. The article is titled, “Using HTML to submit data to Flow” and applies to your use case.

You can read about sending variables to a webMethods Flow at http://www.wmusers.com/ezine/2003jun_dgreen_1.shtml.

You can using wM JSP tag webm:scope to set the parameters that used when invoking services, just like <webm:scope> – inside the tage writing options=“param(num1=‘c123’) param(num2=‘easdfasdfadsfasdfasd’)”, then you can invoke the service using the parameters in the scope.
The following is an simple example hope it’s helpful for you.
Flow service Test1:Flow3 needs two parameters, one is num1, the other is num2.

<webm:scope>-- options=“param(num1=‘c123’) param(num2=‘easdfasdfadsfasdfasd’)”
<webm:invoke/> – serviceName=“Test1:Flow3”
Final result: <webm:value>
</webm:scope>

If you want to passing the dynamical parameters, you can using webm:usePipeline to access the variables in IS pipeline before invoking the IS service. The following is a sample code, wish it is helpful for you ! The IS service Test1:Flow3
needs two input parameters, one is num1, the other is num2.

<%@> – page language=“java” contentType=“text/html” import=“com.wm.data.*”
<%@> – taglib uri=“http://webm-taglib.tld” prefix=“webm”

<html>
<%!> – String num1=“111234”;
<%!> – String num2=“aaabbb”;

<webm:scope>
<webm:usepipeline>
<% IDataCursor pipelineCursor_1 = webm_pipe.getCursor();
IDataUtil.put(pipelineCursor_1, “num1”, num1);
IDataUtil.put(pipelineCursor_1, “num2”, num2);
pipelineCursor_1.destroy();
%>
<webm:invoke> – serviceName=“Test1:Flow3”
output
Final result: <webm:value> – variable=“result”
</webm:usepipeline>
</webm:scope>
</html>

I have a hard time using the webm:usePipeline.

My code is:
<webm:scope>
<webm:usepipeline>
<% out.print(webm_pipe.toString());
IDataCursor idc = webm_pipe.getCursor();
%>

</webm:usepipeline>
</webm:scope>

I can print the webm_pipe like it says in the JSPDevGuide.pdf, but when I try to get its cursor I get a NullPointerException (if I comment the line out, the page loads but lacks the input).

What am I doing wrong?

Hello,
This is so long off but I want to respond for someone who may stumble over here. The reason for your null error is that you have to either import the proper classes or use an absolute notation. So it would be:
<%@page>
or
com.wm.data.IDataCursor idc = webm_pipe.getCursor();
Good day.

Yemi Bedu

Hello,
Sorry for not formatting the html. Here we go, remove underscores in your document:
<%@page_import=“com.wm.data.idatacursor”_%>
Good day.

Yemi Bedu