简体   繁体   中英

How to get response of soap web service in adobe acrobat reader?

I have created a soap web service and want to show the response that web service in adobe acrobat reader. I have created a new file in adobe acrobat->reader->javascripts folder named MenuConfig.js and added code in that file. Now I am trying to show the response of soap web service using ajax call.

Here is my code :

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

Two issues:

1) You can't use ajax to connect using the Acrobat extensions to JavaScript; ajax is a browser extension to JavaScript. The Javascript for Reader/Acrobat would look more like this

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

Then you'd process the response object. See the documentation for how to connect to SOAP using the Acrobat extensions here... 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) You can't use SOAP at all in Adobe Reader unless the file has extended usage rights enabled... which you can't do unless you are using LiveCycle or the Datalogics PDF JavaToolkit. You can't add the SOAP usage rights using Acrobat. Usage rights tend to be rather expensive so you might want to rethink your solution. You can accomplish the same thing by adding a step where the SOAP response gets reformatted on the server to FDF or XFDF which can be automatically imported by Reader/Acrobat and is a free soliution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM