Calling WebServices from Adobe Acrobat X Javascript
Calling WebServices from Adobe Acrobat X Javascript
我正在尝试从Acrobat JavaScript调用SharePoint web服务,并且我遇到了一个错误,我似乎无法绕过。希望有一些帮助,我做错了叫sharepoint。我已经看到了对web服务进行SOAP调用的两种方法:
方式1:
var strURL = "http://www.webservicex.net/globalweather.asmx?wsdl";
var service = SOAP.connect(strURL);
var sCountryName = "United States";
var sCityName = "New York";
var result = {
soapType: "xsd:string",
CountryName: sCountryName,
CityName: sCityName
//soapValue:
};
var results = service.GetWeather(result);
当我直接复制代码时,这是有效的,但是当我尝试用我的代码替换它时,我得到"service is undefined"错误消息:
var strURL = "http://dev-dc:40570/branches/GHIS/XXXXXXX/_vti_bin/lists.asmx?wsdl";
var service = SOAP.connect(strURL);
var sPageURL = "http://devdc:40570/branches/GHIS/XXXXXXX/Other%20Client%20Documents/XXXXXXX.pdf";
var sCheckoutToLocal = "false";
var sLastModified = "";
var result = {
soapType: "xsd:string",
pageURL: sPageURL,
checkoutToLocal: sCheckoutToLocal,
LastModified: sLastModified
};
var results = service.CheckOutFile(result);
由于这不起作用,我尝试了方法2调用webservice:
var oAuthenticator ={ UsePlatformAuth: "true"};
var cURL = "http://www.webservicex.net/globalweather.asmx";
var oRequest = {"http://www.webserviceX.NET:GetWeather":{CityName:"New York",CountryName:"United States"}};
var cAction = "http://www.webserviceX.NET/GetWeather";
var ver = SOAPVersion.version_1_2;
SOAP.wireDump = "true";
var response = Net.SOAP.request({cURL:cURL,oRequest:oRequest,cAction:cAction,oAuthenticate:oAuthenticator,bEncoded:false,cVersion:ver});
我得到了一个错误与此样式,虽然说没有提供CountryName。使用我的代码,我得到了一个类似的错误,说pageUrl丢失或无效:
var oAuthenticator ={ UsePlatformAuth: "true"};
var cURL = "http://dev-dc:40570/branches/GHIS/XXXXXXX/_vti_bin/lists.asmx?wsdl";
var oRequest = {
"http://schemas.microsoft.com/sharepoint/soap:CheckOutFile":{
pageUrl:"http://dev-dc:40570/branches/GHIS/XXXXXXX/Other%20Client%20Documents/XXXXXXX.pdf",
checkoutToLocal:"false",
lastmodified:""
}};
var cAction = "http://schemas.microsoft.com/sharepoint/soap/CheckOutFile";
var ver = SOAPVersion.version_1_1;
SOAP.wireDump = "true";
var response = SOAP.request({
cURL:cURL,
oRequest:oRequest,
cAction:cAction,
oAuthenticate:oAuthenticator,
bEncoded:false,
cVersion:ver
});
谁能帮我弄清楚为什么我似乎不能调用这个SharePoint web服务?我不在乎我使用哪种方法,只要我可以从Acrobat的javascript中与web服务对话。另外,如果有帮助的话,下面是在浏览器中手动导航到web服务时的推荐调用:
POST /_vti_bin/lists.asmx HTTP/1.1
Host: dev-dc
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>
<CheckOutFile xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<pageUrl>string</pageUrl>
<checkoutToLocal>string</checkoutToLocal>
<lastmodified>string</lastmodified>
</CheckOutFile>
</soap12:Body>
</soap12:Envelope>
在做了一些实验之后,我了解到不用使用acrobat来构建代码的请求部分,而是可以传递原始XML,它将完全按照键入的方式传递它。因此,我确定sharepoint必须寻找一种特定的XML结构方式。通过更改代码传递XML, Sharepoint和Acrobat能够成功通信。修改后的(有效的)代码如下所示:
/**WebService Call to the Sharepoint Lists service for Checking Out the current document**/
function CheckOutFile(myFileVal){
var oAuthenticator ={ UsePlatformAuth: "true"};
var cURL = GetDocLibraryWS(myFileVal.path);
var oRequest = {
soapValue: "<CheckOutFile xmlns='http://schemas.microsoft.com/sharepoint/soap/'>"+
"<pageUrl>"+myFileVal.path+"</pageUrl>"+
"<checkoutToLocal>false</checkoutToLocal>"+
"<lastmodified/>"+
"</CheckOutFile>"};
var cAction = "http://schemas.microsoft.com/sharepoint/soap/CheckOutFile";
var ver = SOAPVersion.version_1_2;
var response = SOAP.request({
cURL:cURL,
oRequest:oRequest,
cAction:cAction,
oAuthenticate:oAuthenticator,
bEncoded:false,
cVersion:ver
});}
/**derives the document library web service path from the file URL**/
function GetDocLibraryWS(myFile){
var myString = myFile.substring(0,myFile.lastIndexOf("/"));
myString = myString + "/_vti_bin/Lists.asmx";
return myString;}
相关文章:
- Adobe acrobat每隔30页插入一个空页面-javascript
- 在 Adobe Acrobat X Pro 中使用 javascript 导出页面
- 使用javascript将图像插入pdf(Adobe Acrobat Pro)中
- Javascript(Adobe Acrobat XI)从表单第一页的输入答案填充第二页表单
- 如何从Acrobat PDF JavaScript访问Django Rest Api
- 如何在Acrobat中使用javascript获取PDF表单字段的所有键值对
- Acrobat DC 应用程序和用户 JavaScript 文件夹问题
- 如何在Adobe Acrobat中使JavaScript处于睡眠状态
- 3D PDF acrobat javascript
- 通过 Excel VBA 引用 Acrobat Javascript 全局变量所需的语法是什么?
- Adobe Acrobat - 使用 JavaScript 遍历 PDF 中的所有字段时出错
- 使用 javascript 在网络浏览器中的 Acrobat Reader 中切换页面
- 如何在 Acrobat 11 中清除签名时触发 JavaScript 事件
- Acrobat JavaScript-将JavaScript页面链接转换为“;真正的链接”;
- 将Acrobat JavaScript代码添加到pdf导出中
- 通过HTML(非Acrobat)中的Javascript将PDF作为附件(非页面)附加到PDF
- adobe acrobat dc document level javascript
- Acrobat'的Javascript控制台不工作
- 如何创建&使用acrobat PDF中的javascript将嵌套的OCG/层附加到父层
- Javascript (Acrobat Reader)的全局变量