/******************** this.entityManager; //实体管理器 this.applications; //访问系统内服务 this.requestText//请求正文 this.request//请求 this.currentPerson//当前用户 this.response//响应对象。通过this.response.setBody(data)设置响应内容 this.organization; //组织访问 this.org; //组织快速访问方法 this.service; //webSerivces客户端 ********************/ try{ var result = { } var wsdl = "http://172.16.1.235:8009/hello?wsdl"; //WebService调用地址 var method = "sayHello"; //WebService方法 var ws = this.service; //webSerivces客户端 var parameter = "wwx"; //需传入的参数 var res = ws.jaxws(wsdl, method, parameter); //进行调用并接收返回内容 print(res[0]);//输出返回内容 result.state = "NMT0001"; result.message = "成功"; }catch(e){ e.printStackTrace(); result.state = "NMT0002"; result.message = "失败"; result.data = e.name + ": " + e.message } //JSON.stringify(result); this.response.setBody(result,"application/json");
先通过url获取soap http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl
/********************
this.entityManager; //实体管理器
this.applications; //访问系统内服务
this.requestText//请求正文
this.request//请求
this.currentPerson//当前用户
this.response//响应对象。通过this.response.setBody(data)设置响应内容
this.organization; //组织访问
this.org; //组织快速访问方法
this.service; ///webSerivces客户端
********************/
try{
var result = {
}
var wsdl = "http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl"; //WebService调用地址
var soapXML = "<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://WebXml.com.cn/">"; //soap
soapXML = soapXML + "<soap:Header/>";
soapXML = soapXML + "<soap:Body>";
soapXML = soapXML + "<web:getSupportCity Dataset>";
soapXML = soapXML + "<web:theRegionCode>31119</theRegionCode>";
soapXML = soapXML + "</web:getSupportCity Dataset>";
soapXML = soapXML + "</soap:Body>";
soapXML = soapXML + "</soap:Envelope>";
var ws = this.service; //webSerivces客户端
var res = ws.jaxwsXml(wsdl, soapXML);
print(res[0]);//输出返回内容
result.state = "NMT0001";
result.message = "成功";
}catch(e){
e.printStackTrace();
result.state = "NMT0002";
result.message = "失败";
result.data = e.name + ": " + e.message
}
//JSON.stringify(result);
this.response.setBody(result,"application/json");