javascript如何调用web service???上网搜了很多,但都是关于.net的!

benjinxing 2007-02-01 08:51:50
我的url是:http://localhost:8084/PriceWebservice/services/CreatePrice?wsdl
用以下java语句可以调用,但是怎么用javascript调用呢
谁做过,帮帮我吧!谢谢了
package testwebserver.generated;

import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import javax.xml.rpc.ServiceException;
import java.net.MalformedURLException;
import java.rmi.RemoteException;

public class Bean1 {

public Bean1() {
}

public static void main(String[] args) throws ServiceException,
MalformedURLException, RemoteException {
Bean1 bean1 = new Bean1();
String endpoint = "http://localhost:8084/WebModule1/services/CreatePrice?wsdl";
String method = "getPrice";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(method);
float myFund =(Float)call.invoke(new Object[]{100.0f});
System.out.print(myFund);


}
}
...全文
563 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
chwfirst 2007-02-09
  • 打赏
  • 举报
回复
//异步执行变量值为什么会丢失
this.HandleStateChange=function()
{
if (xmlhttp.readyState == 4)
{
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.load(xmlhttp.responseXML);
var curNode=xmlDoc.selectSingleNode("//string");
rtnText=curNode.text;
eval(this.method);
/*try
{
var labDoc=new ActiveXObject("Msxml2.DOMDocument");
labDoc.async=false;
labDoc.resolveExternals=false;
labDoc.loadXML(rtnText);
}
catch(e)
{
}*/
//window.status=this.ginfo+"执行成功.";
}
}

this.BeginSearch=function(svrName,parm)
{
//window.status="正在"+this.ginfo+"...";
var vPara=parm;
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST", svrName, false);
//xmlhttp.onreadystatechange= this.HandleStateChange;
xmlhttp.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0)");
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-Length",vPara.length.toString());
xmlhttp.send(vPara);
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.load(xmlhttp.responseXML);
var curNode=xmlDoc.selectSingleNode("//string");
this.rtnText=curNode.text;
eval(this.method);
}

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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