2

I am trying to call a SharePoint web service from Acrobat JavaScript, and I am encountering an error that I cant seem to get around. Hoping for some help on what I am doing wrong to call sharepoint. I have seen two ways of doing a SOAP call to a web service:

Way 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);

This works when I copy the code directly, but when I try and replace it with my code, I get "service is undefined" error message:

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);

Since this didn't work, I tried method 2 for calling the 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});

I got an error with this style though saying that CountryName was not supplied. Using my code, I got a similar error saying that pageUrl was missing or invalid:

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
        });

Can someone help me figure out why I cant seem to call this SharePoint web service? I dont care which method I use as long as I can talk to the webservice from within Acrobat's javascript. Also, in case it helps, here is the recommended call when navigating to the webservice manually in the browser:

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>
Nikkoli
  • 502
  • 5
  • 13
  • Have you succeeded in doing so? I really need help with this - I can't get `soap.request()` to work under Acrobat Reader (I get an error saying this method is restricted) – Shai Aug 08 '12 at 09:39

1 Answers1

1

After doing some experimenting, I have learned that instead of using acrobat to build the request portion of the code, you can instead pass raw XML and it will pass it exactly as typed. Because of this, I determined that sharepoint must be looking for a specific way that XML is structured. By changing the code to pass XML Sharepoint and Acrobat were able to successfully communicate. The revised (working) code looks like this:

/**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;}
Nikkoli
  • 502
  • 5
  • 13
  • One thing to keep in mind though... Acrobat doesn't recognize that the file is checked in or out when using this method, so it cant be used for suppressing the checkin/checkout process. – Nikkoli Oct 27 '11 at 14:28