Skip to main content
Participant
July 26, 2016
Question

RaiseError with SOAP.request

  • July 26, 2016
  • 2 replies
  • 1083 views

Hi all,

what I'm trying to do is to synchronize the value of some formular field to SharePoint list columns. I try to realize this by executing a SOAP.request.

Actually my experience with JS is poor and I did also not really work with XML and SOAP before. Maybe someone can tell me what I'm doing wrong here.

function SyncMetadata(){

    var webUrl = "https://website/_vti_bin/Lists.asmx?wsdl";

    var action = "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems";

    var xmlmsg;

    var listname = "Orders";

    var anumber = this.getField("OrderID").value;

    var user = app.response({cLabel:"Username", cTitle:"Authentification"});

    var pwd = app.response({bPassword:true, cLabel:"Password", cTitle:"Authentification"});

    var auth ={

        Username: user,

        Password: pwd

    }

    xmlmsg = '<?xml version="1.0" encoding="utf-8"?>'+

            '<soap:Envelope '+

                'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '+

                'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '+

                'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+

                '<soap:Body>'+

                    '<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">'+

                    '<listName>'+listname+'</listName>'+

                    '<Where><Eq><FieldRef Name="ID"><Value Type="Integer">+8+</Value></Eq></Where>'+

                    '<updates>'+

                        '<Batch OnError="Continue">'+

                        '<Method ID="1" Cmd="Update">'+

                            '<Field Name="OrderID"/>'+anumber+'</Field>'+

                        '</Method>'+

                        '</Batch>'+

                    '</updates>'+

                    '</UpdateListItems>'+

                '</soap:Body>'+

            '</soap:Envelope>';

    try{ 

    Net.SOAP.connect(webUrl);

    } catch(e){

        app.alert({

            cMsg: "Connection failed for",

            cTitle: "SOAP Error"

        })

        return null;

    };

    Net.SOAP.request(

    {

        cURL: webUrl,

        cAction: action,

        oAuthentication: auth,

        oRequest: xmlmsg

    });

}

The code stops with:

RaiseError:

Net.SOAP.request:50:AcroForm:Sync:Annot1:OnFocus:Action1

===>

Line 50 points to oRequest: xmlmsg

This topic has been closed for replies.

2 replies

Karl Heinz  Kremer
Community Expert
Community Expert
July 27, 2016

Let's take a step back: Why are you trying to pass XML directly to the web service? It's much simpler to use the SOAP interface by just calling the methods provided by SOAP directly. You can find a simple example here: Getting a Serial Number Into a Form Using SOAP - KHKonsulting LLC

S_M_1Author
Participant
July 28, 2016

I want to copy the values of different fields in my PDF into SharePoint list columns.

For MS Word files this works with autotext quickparts which are handled as additional metadata.

I know that it is possible to include the SP columns as metadata in PDFs but i can't change them (automatically) with javascript.

Karl Heinz  Kremer
Community Expert
Community Expert
July 26, 2016

I've never used XML directly to call a web service, so this is not based on experience, but by looking at your code, I found this:

The 'oRequest' parameter needs to be an object. In your code, it's just a string. See here for more information: Acrobat DC SDK Documentation

A quick Google search turned up this SO answer: web services - Calling WebServices from Adobe Acrobat X Javascript - Stack Overflow - it contains some sample code you may be able to adapt.

S_M_1Author
Participant
July 27, 2016

Ok, this was the first fault but it seems like the error already happens before. The try block for the Net.SOAP.connect function never gave me an error, now I used a try block for my Net.SOAP.request and it throws a connection error.

try{
var response = Net.SOAP.request(
{
    cURL: webUrl,
    oRequest: { "https://website:port/:echoString": { inputString: xmlmsg }},
    cAction: action,
    oAuthenticate: auth
});
} catch(e){
    this.getField("catchOutput").value = e.message;
};