HTML页面代码
<!DOCTYPE html>
<html>
<head lang="zh-CN">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>DEMO—演示SOAP调用</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css">
</head>
<body>
<div class="container">
<form class="form-horizontal" role="form">
<div class="page-header text-left"><h2>输入账户号</h2></div>
<div class="form-group">
<div class="row">
<label class="col-md-1" for="p_userdn1">租户账户号</label>
<div class="col-md-6"><input type="text" id="tenantcount" placeholder="请输入租户账户号" /></div>
</div>
</div>
<div class="form-group">
<div class="row">
<button type="button" class="btn btn-primary btn-lg" id="btnLoadUserXML" >用户XML信息</button>
<button type="button" class="btn btn-primary btn-lg" id="btnLoadUser" >用户名称</button>
</div>
<div class="row">
<textarea class="form-control" rows="6" id="userXML"></textarea>
</div>
</div>
</form>
</div>
<script src="js/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script src="js/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#btnLoadUserXML").click(loadUserXML);
});
function loadUserXML(){
//Gateway代码是获取服务器安全认证权限,其中expense_ct是安装Cordys服务器名称,按实际情况,需要参数化进行管理。
var gwUrl = "http://192.168.100.108/home/DOrg/com.eibus.web.soap.Gateway.wcp?SAMLart=" + $.cookie("defaultinst_SAMLart")+"&defaultinst_ct=" + $.cookie("defaultinst_ct") ;
/*
若只要单个参数 SAMLart
禁用CRSF功能,必须在wcp.properties文件添加
gateway.csrf.strict=false
gateway.csrf.cookiename=
详情:https://wiki.cordys.com/display/secmanforum/403+Forbidden+error+when+calling+cordys+web+service+with+saml
var gwUrl = "http://192.168.100.108/home/DOrg/com.eibus.web.soap.Gateway.wcp?SAMLart=" + $.cookie("defaultinst_SAMLart")
*/
var gwUrl = "http://192.168.100.108/home/DOrg/com.eibus.web.soap.Gateway.wcp?SAMLart=" + $.cookie("defaultinst_SAMLart");
var getAcountByName ="<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+" <SOAP:Body>"
+ " <GetAcountByName xmlns=\"http://schemas.cordys.com/DavidWSAppServerPackage\" preserveSpace=\"no\" qAccess=\"0\" qValues=\"\">"
+ " <Name>"+$("#tenantcount").val()+"</Name>"
+ "</GetAcountByName>"
+"</SOAP:Body>"
+"</SOAP:Envelope>";
$.ajax(
{url:gwUrl,
type:"POST",
dataType:"xml",
data: getAcountByName,
contentType:"text/xml; charset=\"utf-8\"",
complete:getResult
}
);
return false;
}
function getResult(result, status){
$("#userXML").val(result.responseText);
}
$(function(){
$("#btnLoadUser").click(getUserName);
});
function getUserName(){
var v_userXML = $("#userXML").val();
$("#userXML").val($(v_userXML).find("getAcountByName > getAcountByName").text());
}
</script>
</body>
</html>