- This topic has 3 replies, 2 voices, and was last updated 17 years, 8 months ago by lovevhvlove.
-
AuthorPosts
-
lovevhvloveMemberI did example http://myeclipseide.com/enterpriseworkbench/help/index.jsp?topic=/com.genuitec.myeclipse.doc/html/quickstarts/webservices/index.html ( create the first web service). It worked fine. I also modified argument. It works as well. However, I don’t know how to let JSP invoke web service. Can you provide me a JSP code to invoke and retrieve “Hello World” from the example Web Service link above. I tried like code below. It doesn’t work
<%@ page language=”java” pageEncoding=”ISO-8859-1″%>
<%@ taglib uri=”http://struts.apache.org/tags-bean” prefix=”bean” %>
<%@ taglib uri=”http://struts.apache.org/tags-html” prefix=”html” %>
<%@ taglib uri=”http://struts.apache.org/tags-logic” prefix=”logic” %>
<%@ taglib uri=”http://struts.apache.org/tags-tiles” prefix=”tiles” %><%@page import=”org.apache.axis.client.Call,
org.apache.axis.client.Service,org.apache.axis.encoding.XMLType,
javax.xml.rpc.ParameterMode” %>
<% String endpoint =
“http://localhost:8080/HelloWorld/services/HelloWorldService?WSDL”;
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(“example”);
//call.setProperty(Call.NAMESPACE, “http://DefaultNamespace”);
call.addParameter(“in0”, XMLType.XSD_STRING, ParameterMode.IN);
// call.PARAM_MODE_IN);
call.setReturnType( XMLType.XSD_STRING );%><%=call.invoke(new Object[] {“Hello!”})%>
This is error return:
HTTP Status 500 –
——————————————————————————–
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
Riyad KallaMemberMoving OT > Soft Dev
lovevhvloveMemberHIc… Does anyone help me ? Thank very much
lovevhvloveMemberI created a Web Service Client as New/Other/MyEclipse/Web Service/Web Service Client. Then I create a JSP as below. It doesn’t work . Can anyone help me? Plz.
<%@ page import=”javax.xml.rpc.Stub,javax.xml.rpc.*,javax.naming.*,javax.jws.*,org.codehaus.xfire.service.*,defaultnamespace.*”%>
<html>
<head>
<title>Hello</title>
</head>
<body bgcolor=”#ffcccc”>
<h2>
Welcome to the Math Web Service
</h2>
<form method=”get”>
<input type=”text” name=”num1″ size=”25″>
<p></p>
<input type=”text” name=”num2″ size=”25″ value=”5″>
<p></p>
<input type=”submit” value=”AddNumbers”>
<input type=”reset” value=”Reset”>
</form><%
String str1 = request.getParameter(“num1”);
String str2 = request.getParameter(“num2″);
if ( str1 != null && str2 != null ) {
%>
<%
String result=””;
try {
// Create a stub object
Stub stub = (Stub)(new HelloVanServiceClient().getHelloVanServiceHttpPort());// Set the endpoint address the stub uses to access the service
stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
“http://localhost:8080/HelloVan/services/HelloVanService?WSDL”);
// Cast the stub to MathFace
HelloVanServicePortType action= (HelloVanServicePortType)stub;
// HelloVanServiceHttp action = (HelloVanServiceHttp)stub;
// Retrieve and parse the parameters from the request message
// Invoke the method
result = action.example(str1);} catch (Exception ex) {
}}
%></body>
</html> -
AuthorPosts