jsp中如何调用web serviceweb service 是用vb.net写的,目前在asp中调用没有问题!) ???

qianguob 2004-07-28 10:00:04
jsp中如何调用web serviceweb service 是用vb.net写的,目前在asp中调用没有问题!) ???

我的环境是tomcat4.1+axis
下面是我JSP的代码:
<%@ page language="java"%>
<%@ page import="java.net.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.rmi.*"%>
<%@ page import="javax.xml.namespace.QName" %>
<%@ page import="org.apache.axis.client.Service" %>
<%@ page import="org.apache.axis.client.Call" %>
<%@ page import="javax.xml.rpc.ParameterMode" %>
<%
String location="http://localhost/goodsservice.asmx?wsdl";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(location);
call.setOperationName("TestAccount");
call.addParameter("SiteID",org.apache.axis.Constants.XSD_STRING,ParameterMode.IN);
call.addParameter("password",org.apache.axis.Constants.XSD_STRING,ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
String number = (String)call.invoke(new Object[] {"123", "123"});
System.out.println(number);
%>


执行以后老是提示下面的错误信息,请各位大哥帮忙!!!

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: System.Web.Services.Protocols.SoapException: 服务器未能识别 HTTP 标头 SOAPAction 的值:。
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at at org.apache.axis.message.SOAPFaultBuilder.endElement
........
.................
..................


--------------------------------------------------------------------------------

Apache Tomcat/4.1.18
...全文
198 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
stonewang 2004-08-19
  • 打赏
  • 举报
回复
15
以java 为客户端的话, 有多种技术可以访问我们的Web Service。以下演示在J2SE 1.4.2 版本下访问Web
Service 的2 种方式。
Axis
需要下载axis, 地址为:http://apache.linuxforum.net/dist/ws/axis/1_1/axis-1_1-src.zip
代码如下:
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
public class t2 {
public static void main(String[] args) {
long time=System.currentTimeMillis();
try {
String endpoint="http://localhost/UserX/biz.asmx";
Service service = new Service();
Call call = (Call)service.createCall();
8848.com Web Service 说明文档
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new
QName("http://localhost/UserX/bizinfo","get_count"));
call.addParameter("ID", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.addParameter("pwd",org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://localhost/UserX/bizinfo/get_count");
String day = (String)call.invoke(new Object[] {"111", "s111"});
System.out.println(day);
} catch (Exception e) {
System.err.println(e.toString());
}
System.out.println("Total time is: "+(System.currentTimeMillis()-time));
}
}
山东大汉 2004-08-19
  • 打赏
  • 举报
回复
java调.net写的webservice要写SOAPAction的,否则就出这个错误
   String sa = webservice的SOAPAction的值
call.setUseSOAPAction(true);
call.setSOAPActionURI(sa);
usabcd 2004-08-10
  • 打赏
  • 举报
回复
call.setUseSOAPAction(false);
qianguob 2004-08-10
  • 打赏
  • 举报
回复
为什么还是没有人回答
朋友别哭 2004-08-10
  • 打赏
  • 举报
回复
up
qianguob 2004-07-28
  • 打赏
  • 举报
回复
自己顶一下。
ecaol 2004-07-28
  • 打赏
  • 举报
回复
UP

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧