aspose file tools
The moose likes Web Services and the fly likes invoking a web service from a jsp ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "invoking a web service from a jsp ?" Watch "invoking a web service from a jsp ?" New topic
Author

invoking a web service from a jsp ?

mohamed sellami
Greenhorn

Joined: Jul 22, 2005
Posts: 9
hello

i'm trying to invoke a WS from a jsp page, working on tomcat + jwsdp

the ws i'd created and deployed on the server is named TestCNRPS, it contains the method: int exist(int ..)

i wrote this jsp page for testing :

--------------------------
1<%@ page contentType="text/html;charset=windows-1252" import="cnrps.*" %>
2<HTML>
3<HEAD>
4<TITLE>Appel service Web</TITLE>
5</HEAD>
6
7<BODY>
8<%
9int num_cin=45475645;
10
11TestCNRPSIF_Stub stub = (TestCNRPSIF_Stub)(new TestCNRPSService_Impl().getTestCNRPSIFPort());
12stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,System.getProperty("endpoint"));
13out.println(stub.exist(num_cin));

%>
</BODY>
</HTML>
----------------------------------

but i received this exception:

java.rmi.RemoteException: Erreur de transport HTTP : java.lang.NullPointerException; nested exception is:
Erreur de transport HTTP : java.lang.NullPointerException
cnrps.TestCNRPSIF_Stub.exist(TestCNRPSIF_Stub.java:87)
org.apache.jsp.invoqueWS_jsp._jspService(invoqueWS_jsp.java:58)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:268)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:258)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:205)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


Has someone an idea ??

thx
[ September 07, 2005: Message edited by: mohamed sellami ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32767
We'd need to know what's happening here:
cnrps.TestCNRPSIF_Stub.exist(TestCNRPSIF_Stub.java:87)


Android appsImageJ pluginsJava web charts
mohamed sellami
Greenhorn

Joined: Jul 22, 2005
Posts: 9
the method exist get the identier of a pesron, connect to a database and verify if he exists.

but i think th problem is not there, cause i tried the exempl on a dos prompt with a client class having the same code and it worked fine.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32767
I think the problem is there, because that's where the exception is thrown Check that none of the objects used or referenced in that line are null. If any are, let us know which ones those are, and how they are created; that might help discover the problem.
[ September 06, 2005: Message edited by: Ulf Dittmer ]
mohamed sellami
Greenhorn

Joined: Jul 22, 2005
Posts: 9
that's line 87 on TestCNRPSIF_Stub.java

86 } catch (JAXRPCException e) {
87 throw new RemoteException(e.getMessage(), e);
88 }

??

[ September 06, 2005: Message edited by: mohamed sellami ]
[ September 07, 2005: Message edited by: mohamed sellami ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32767
That's not the class that's throwing the exception - TestCNRPSIF_Stub throws it. You need to analyze what's happening with null objects in line 87 of that class.
mohamed sellami
Greenhorn

Joined: Jul 22, 2005
Posts: 9
yes the exception is thrown by the TestCNRPSIF_Stub class!!!

it was a typing error, i edited the message, thx
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32767
In that case you need to figure out where the JAXRPCException is thrown, which is caught by the catch clause.
mohamed sellami
Greenhorn

Joined: Jul 22, 2005
Posts: 9
yeah that's right but the code inside the "TestCNRPSIF_Stub" class is very complex

but what makes me crazy is that it works using a simple class but not with a jsp page??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32767
If the JSP page is on a different machine it could be a network issue. If it's on the same machine as your other client class, maybe it's missing libraries in the classpath.
But why speculate? The exception has a stack trace which will tell you which line causes the problem. That should be your first line of inquiry.
mohamed sellami
Greenhorn

Joined: Jul 22, 2005
Posts: 9
Hi Ulf

i found the fault it was in line 12 of the jsp:

i replaced System.getProperty("endpoint") with "http://localhost:8080/jaxrpc-TestCNRPS/TestCNRPS"

System.getProperty("endpoint") returned null but in the java class i maked for the test it returned "http://localhost:8080/jaxrpc-TestCNRPS/TestCNRPS"

anyway it's working fine now

thank you Ulf
[ September 07, 2005: Message edited by: mohamed sellami ]
 
IntelliJ Java IDE
 
subject: invoking a web service from a jsp ?
 
Threads others viewed
How to return ResultSet from Bean to JSP?
Try to open JSF page in MyEclipse/JBoss
Mails thru JSP
Argument Error: One or more parameters are null.
Calling controller servlet form a jsp page through an anchor tag
developer file tools