我需要能够从InfoPath表单上的重复表中提取数据并将其放入报表中。我在Codeplex上找到了一个解决方案文件,它将从重复表中读取数据,并通过SOAP查询将其作为XML输出。我正在尝试读取SOAP查询并通过CEWP中的JQuery将其输出到网页。我是一个相当新的尝试这个,我有点迷失在如何处理这个。 Web服务提供了此示例代码:
POST /_vti_bin/InfoPathDB/InfoPathDB.asmx HTTP/1.1
Host: 10.158.2.5
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<QueryFormLibrary xmlns="http://infopathdb.codeplex.com/">
<SiteURL>string</SiteURL>
<FormLibraryTitle>string</FormLibraryTitle>
<OptionalContentType>string</OptionalContentType>
<OptionalCAMLFilter>string</OptionalCAMLFilter>
<OptionalBooleanIncludeAttachments>string</OptionalBooleanIncludeAttachments>
</QueryFormLibrary>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<QueryFormLibraryResponse xmlns="http://infopathdb.codeplex.com/">
<QueryFormLibraryResult>xml</QueryFormLibraryResult>
</QueryFormLibraryResponse>
</soap12:Body>
</soap12:Envelope>
我有点困惑哪个部分需要在我的JQuery代码中去哪里。我试图改编的代码块是:
<script src="/Site_Assets/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var soapEnv =
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<QueryFormLibrary xmlns="http://infopathdb.codeplex.com/">
<SiteURL>http://255.255.255.1</SiteURL>
<FormLibraryTitle>List Entries</FormLibraryTitle>
<OptionalContentType></OptionalContentType>
<OptionalCAMLFilter></OptionalCAMLFilter>
<OptionalBooleanIncludeAttachments></OptionalBooleanIncludeAttachments>
</QueryFormLibrary>
</soap12:Body>
</soap12:Envelope>";
$.ajax({
url: "/_vti_bin/InfoPathDB/InfoPathDB.asmx HTTP/1.1",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
});
function processResult(xData, status) {
$(xData.responseXML).find("z\\:row").each(function() {
var iDesc=$(this).attr("FieldOne");
var iResp=$(this).attr("FieldTwo");
var iID=$(this).attr("ows_ID");
var liHtml = "<div class='question' id='"+iID+"'>" + iDesc + "</div><div class='answer' id='a"+iID+"'>"+ iResp +"</a></div>";
$("#entries").append(liHtml);
}</script>
<div id="entries"> </div>
关于我做错了什么/对吗?
答案 0 :(得分:0)
好的 - 经过多次抨击后,我发现了这一切,并得到了网络服务作者的一些支持。我正在使用JSON来获取我的数据。
以下是成功的代码块:
<script>
function getJSON(SiteURL, FormLibraryTitle, OptionalContentType, OptionalCAMLFilter, OptionalBooleanIncludeAttachments) {
var test;
$.ajax({
type: "POST",
url: "/_vti_bin/InfoPathDB/InfoPathDB.asmx/QueryFormLibraryAsJSON",
data: "{'SiteURL': '" + SiteURL + "', 'FormLibraryTitle': '" + FormLibraryTitle + "', 'OptionalContentType':'" + OptionalContentType + "', 'OptionalCAMLFilter':'" + OptionalCAMLFilter + "', 'OptionalBooleanIncludeAttachments':'" + OptionalBooleanIncludeAttachments + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
// Save for F15 Developer Tools to see
test = JSON.parse(msg.d);
outputJSON(test);
},
error: function (xhr) {
alert(xhr);
}
});
};
</script>
这是我的输出函数的源代码,它接受(测试)对象并将所选元素提供给HTML表格。