我创建了一个肥皂网络服务,并希望在Adobe Acrobat Reader中显示该网络服务的响应。我在adobe acrobat-> reader-> javascripts文件夹中创建了一个名为MenuConfig.js的新文件,并在该文件中添加了代码。
现在,我试图显示使用ajax调用的soap Web服务的响应。
这是我的代码:
app.addMenuItem({
cName: "-",
cParent: "File",
cExec: " "
});
app.addMenuItem({
cName: "Save to Sharepoint",
cParent: "File",
cExec: "ShowDialog()",
nPos: 0
});
// Dialog Definition
var oDlg = {
strName: "",
initialize: function(dialog) {
dialog.load({
"desc": this.strName
});
},
commit: function(dialog) {
var data = dialog.store();
this.strName = data["desc"];
},
description: {
name: "Sharepoint", // Dialog box title
align_children: "align_left",
width: 250,
height: 250,
elements: [{
type: "cluster",
name: "Save File",
align_children: "align_left",
elements: [{
type: "view",
align_children: "align_row",
elements: [{
type: "static_text",
name: "Description",
width: 70
},
{
item_id: "desc", //item_id needs 4 characters only
type: "edit_text",
alignment: "align_right",
width: 200,
height: 20
}
]
},
{
type: "view",
align_children: "align_row",
elements: [{
type: "static_text",
name: "1. Client",
width: 70
},
{
item_id: "Clnt",
type: "popup",
alignment: "align_right",
width: 165,
height: 20
}
]
},
{
type: "view",
align_children: "align_row",
elements: [{
type: "static_text",
name: "2. Matter",
width: 70
},
{
item_id: "Matr",
type: "popup",
alignment: "align_right",
width: 165,
height: 20
}
]
},
{
type: "view",
align_children: "align_row",
elements: [{
type: "static_text",
name: "3. Doc. Type",
width: 70
},
{
item_id: "DocT",
type: "popup",
alignment: "align_right",
width: 165,
height: 20
}
]
},
{
type: "view",
align_children: "align_row",
elements: [{
type: "static_text",
name: "4. User ID",
width: 70
},
{
item_id: "UsID",
type: "edit_text",
alignment: "align_right",
width: 200,
height: 20
}
]
},
{
//alignment: "align_right",
type: "ok_cancel",
align_children: "align_row",
ok_name: "Ok",
cancel_name: "Cancel"
}
]
}]
}
};
function ShowDialog() {
var listId = '{19736DC6-B732-4D25-8DAA-9E0FD808CA30}';
var siteUrl = "http://www.rajman.in/json/productlistclient.php?wsdl";
oDlg.strName = "Larry";
if ("ok" == app.execDialog(oDlg)) {
getDocTypeListItems(siteUrl, listId);
}
}
function getDocTypeListItems(siteUrl, listId) {
var cURL = "http://www.rajman.in/json/productlist.php?wsdl";
ajax = function(siteUrl) {
var params = {
cVerb: "GET",
cURL: siteUrl,
oHandler: {
response: function(msg, uri, e, h) {
var stream = msg;
var string = "";
string = SOAP.stringFromStream(stream);
app.alert(string);
}
}
};
Net.HTTP.request(params);
}
}
最佳答案
两个问题:
1)您不能使用Ajax通过Acrobat扩展连接到JavaScript; ajax是JavaScript的浏览器扩展。 Reader / Acrobat的Javascript看起来像这样
var oAuthenticator =
{
Username: "myUserName",
Password: "myPassword"
};
var response = SOAP.request(
{
cURL: cURL,
oRequest: {
"http://soapinterop.org/:echoString":
{
inputString: cTestString
}
},
cAction: "http://soapinterop.org/",
oAuthenticate: oAuthenticator
});
然后,您将处理响应对象。请参阅此处的文档,了解如何使用Acrobat扩展连接到SOAP。
http://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/index.html#t=Acro12_MasterBook%2FJS_API_AcroJS%2FSOAP_methods.htm%23TOC_request1bc-4&rhtocid=_6_1_8_70_1_3
2)除非文件已启用扩展使用权,否则您根本无法在Adobe Reader中使用SOAP ...除非使用LiveCycle或Datalogics PDF JavaToolkit,否则您将无法使用SOAP。您无法使用Acrobat添加SOAP使用权限。使用权往往很昂贵,因此您可能需要重新考虑您的解决方案。您可以通过添加以下步骤来完成同一件事:将SOAP响应在服务器上重新格式化为FDF或XFDF,FDF或XFDF可以由Reader / Acrobat自动导入,并且是免费的。
关于javascript - 如何在Adobe Acrobat Reader中获得Soap Web服务的响应?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44858114/