I need to achieve this:

  1. a SharePoint page (form) with 2 fields, firstname and lastname
  2. connect to a wsdl and get info for parameters firstname and lastname
  3. on the same SharePoint page, show the results coming back from the wsdl

I know SharePoint but have no idea how to start on this. Any help is welcome. And it might be done using Designer, or SP OOTB, ...

  • 1
    What do you need to do is submit the data to a web service ryt? – Malin De Silva Aug 29 '14 at 11:04
  • Are you using SP2013? – Andrey Markeev Aug 29 '14 at 11:48

Consider the following approach:

  1. Put a Script Editor Webpart to your page, below or above the fields
  2. Create a script element and put there a script, that would perform the following:
    • get values of First name and Last name fields
    • perform the web service call
    • display the results

Get field values

I assume you're using OOTB list form, so in this case field values can be acquired via CSR.

Go to your form page, open developer console (F12->Console tab in IE), and execute the following code:

document.querySelector("#onetIDListForm div[webpartid]").id

You will see something like this:

enter image description here

In my case it is "WebPartWPQ2". You need "WPQ2" part of this string. Now you can get the CSR context object for this webpart.

var csrContext = window["WPQ2FormCtx"];

Having the context, it is very simple to get the field values:

var firstName = window["WPQ2FormCtx"].ListData["FirstName"];
var lastName = window["WPQ2FormCtx"].ListData["Title"]; // this is Last name for OOTB Contacts list

Note: Please use internal names of your fields. E.g. it might be First_x0020_Name, because if you create fields manually, spaces are transformed into _x0020_. The example above is for the OOTB Contacts list.

enter image description here

Web Service Call

Now, you have First name and Last name values. How do you perform soap request and get the results?

I recommend leveraging an opensource library for that purpose. There are plenty of those. For example:

Or if you don't want to meddle with libraries, then have a look at this SO answer, that provides example code for accessing SOAP web service from JS.

Displaying results

If you're content with having your data below or above the list form, then you can simply add something like <div id="mydiv"></div> into the Script Editor WebPart, and then $get('mydiv').innerHTML = '... html here, based on received results ...'; will do the trick.

If you need to put the data you receive from the Web Service inside the form rather than below or above, you then might want to read the following CodeProject article, explaining in detail how that can be done using CSR (see section "Example: manipulating form layout"):

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.