Dec 23, 2008

iLSP - SharePoint Designer “Call a Web Service” Action

“iLSP” – is the abbreviation for iLove SharePoint.

The “Call a WebService” workflow action is included in the iLSP -SharePoint Designer Actions 1.0 release. Installation see readme.txt.

The action supports SOAP 1.1, SOAP 1.2, basic and windows authentication.

Let’s go and call a built-in SharePoint web service – Lists.asmx and create a new List with the AddList operation.

  • Bring up SharePoint Designer and create a new workflow on an list with a “Title” and “Response” (Multiple lines of text – plain text) column.
  • Add the “Call a Web Service” action from the “iLove SharePoint” category

image

  • Configure the action as follows:
    • URL: http://[siteurl]/_vti_bin/Lists.asmx
    • SOAP Version: SOAP 1.2
    • SOAPAction: not needed for SOAP 1.2
    • Envelope:

<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>
<AddList xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>[%MyList:Title%]</listName>
<description>Created by iLSP action</description>
<templateID>100</templateID>
</AddList>
</soap12:Body>
</soap12:Envelope>

You can copy the SOAP 1.2 example request from http://[siteurl]/_vti_bin/Lists.asmx?op=AddList

      • For the <listName> insert a reference to the current item’s title.

image

      • As <description> enter “Created by iLSP action
      • Set the <templateID> to 100” = custom list

  • Response: create a new string workflow variable named “response” and assign it. The action will fill the variable with the response from web service call (xml string).
  • User: leave empty. Empty user = use default credentials.
  • Password: leave empty

Now the “Call a WebService” action is configured.

To check the response, we will write it in the “Response” column of the item using the built-in “Set field in current item” action. Set field to “Response” and “Value” to the above defined workflow variable “response”

image

Try it – Start the workflow on an item

The response:

image

The new list:

image

Because the raw response isn’t very useful, we now parse it using iLSP “Query XML” action. Place the action between the “Call a WebService” and the “Set field in current item” action.

  • Add the “Query XML” action to the workflow

image

  • Configure the “Query XML” action
    • Input: choose the above defined workflow variable “response
    • XPath: //*[local-name()='List']/@ID
      • You can use any valid XPath expression e.g. count(//*). Is the expression result is a single node it will write the node’s inner XML to the result variable. Is the result a node collection, it will merge all the node’s inner XML separated by an semicolon into the result variable. You should identify the node by the local name, because you can’t use xml namespaces.
    • Result: Create a new string workflow variable named “ListID” and assign it.

The “Query XML” action is now configured

Now modify the “Set field in current item” action so that the response column is set to the ListID variable.

image

Start the workflow again

Result:

image

THE END

37 comments:

Chanda said...

Christian,
Thanks for these great activites! I do have one question about the Call A Web Service activity - I am using that to call the UpdateListItems web service. I am able to add new items successfully, however the response I get back seems to just be the error code and not the full response that you see in your posting here. Can you tell me what I might be doing wrong? I would like to capture the full response in order to parse the ID of the newly created item. Thanks,
Chanda

Chanda said...

Christian,
Disregard my previous comment, the response is returning the full xml, I was just viewing it in email which only displayed the error code. When I viewed the source of the email it shows the full response. Thanks again!
Chanda

Maik Zeyen said...
This comment has been removed by the author.
Maik Zeyen said...

Hello Christian,
i want to add a list item to a list via web service. But everytime i get an 500 Internal Server error.
This only happens when trying to add an Item via UpdatelistsItem. Createing a new List, like discribed in your Post works. Any idea why adding an Item fails? here is my Soap 1.2 Code for adding:

?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/env...">
soap:Body>
UpdateListItems
xmlns="http://schemas.microsoft.com/sharep...">
listName>Aufgaben
updates>
Batch OnError="Continue" ListVersion="1">
Method ID="1" Cmd="Update">
Field Name="ID">1
Field Name="Title">Joe
/Method>
/Batch>
/updates>
/UpdateListItems>
/soap:Body>
/soap:Envelope>

The Adress is the _vti_bin folder where the Application and this List are placed.

Thanks

Christian said...

Hello, I recommend troubleshooting with Fiddler (HTTP Monitor). Make the call with a C# Test App and monitor the Http Request and llok if there are any differences. You could also take a look into the SharePoint log file, maybe you'll find a more detailed error description.

bye, Christian

Anonymous said...

Christian,

The "Call a Web Service" function works great!
But I've got a timeout on web services during workflow which returns data after 5 minutes. Is there anyway to fix the "Error calling Web Service. The operation has timed out" issue?
Please enlighten me

Regards,
Justin Wong

Christian said...

Hi Justin, at the moment you would have to change the source code to change the client's timeout e.g. client.Timeout = 600000

Bye, Christian

Justin Wong said...

Thanks for the comment :)
Now, this is lovely!

Anonymous said...

This is a great and to have this in Sharepoint makes it even better. I have a question on "Query XML" action.

%bookstore%

%book%
%title lang="eng"%Harry Potter%/title%
%price%29.99%/price%
%/book%

%book%
%title lang="eng"%Learning XML%/title%
%price%39.95%/price%
%/book%
%/bookstore%

What would you put in the "XPath:' to get the result for ? Or is this Action specific to a Sharepoint list only? Thank you for any response.

Anonymous said...

Sorry for the double post! Arrghh.

This is a great and to have this in Sharepoint makes it even better. I have a question on "Query XML" action.

%bookstore%

%book%
%title lang="eng"%Harry Potter%/title%
%price%29.99%/price%
%/book%

%book%
%title lang="eng"%Learning XML%/title%
%price%39.95%/price%
%/book%
%/bookstore%

What would you put in the "XPath:' to get the result for price? Or is this Action specific to a Sharepoint list only? Thank you for any response.

Anonymous said...

Can you explain this?

Where does 'List' come from?

XPath: “//*[local-name()='List']/@ID”
You can use any valid XPath expression e.g. count(//*). Is the expression result is a single node it will write the node’s inner XML to the result variable. Is the result a node collection, it will merge all the node’s inner XML separated by an semicolon into the result variable. You should identify the node by the local name, because you can’t use xml namespaces.

Anonymous said...

I found the answer I was looking for //*[local-name()='']

Between the quotes put the node name.

Madhu said...

I am having trouble using iLove Sharepoint. I am unable to add activities to the workflow, when i do add , nothing seems to happen. I have copied the language

As suggested below and the results are the same.

You have to copy %commonprogramfiles%\Microsoft Shared\web server extensions\12\TEMPLATE\1033\Workflow\iLoveSharePoint_Activities_EN.ACTIONS in the specific language folder that you want to use. For example 1033 is english.

Madhu said...

resolved it by adding the in the web site i was using. I had included it the sharepoint central. thank you ....

Madhu said...
This comment has been removed by the author.
Madhu said...

Error calling Web Service. The remote server returned an error: (500) Internal Server Error.

I tried to run the webservice directly it runs as expected without any problems.





dateTime




I am not sure where i have gone wrong.

Chris said...

Love your iLSP pack of custom SPD actions! I can't figure out how to resolve an error and would appreciate any assistance.

After using the "Call a Web Service" action to call the GetListItems method of the Lists web service, the "Query XML" action is used to retrieve the total number of items returned in the XML response (i.e. the "ItemCount" attribute of the "rs:data" element). The workflow keeps throwing the error: "Error querying XML. Object of type 'System.String' cannot be converted to type 'System.Int32'."

How may I access the "rs:data" or "z:row" elements of most Lists web service responses?

Thanks

Chris said...

Workflow variable type was set to "List Item ID" rather than "String"... :(

Christian said...

The result type of this action is always a string.

Irene said...

Hello Christian,

if I tried to run the webservice directly it runs without any problems.
But if i run automatically when create an item i get the error:

"Error calling Web Service. The remote server returned an error: (500) Internal Server Error."
In the error log this error means

"Workflow Infrastructure 98d4 Unexpected System.NullReferenceException: Workflow association not found at iLoveSharePoint.Activities.StartWorkflowActivity"

Thanks,
Irene

Jeff said...

I am using Call A Web Service activity to call the UpdateListItems web service. Everything works fine except for updating date fields. When I pass a sharepoint date field value it does not update however when I hard code mm-dd-yyyy it works fine. I find it hard to believe that this web service activity and the actual lists.asmx cannot work together to update a date value using a date value from within sharepoint

digital certificate said...

Thank you for broaching this subject. I believe it is more important than is generally believed. Thanks for the work that you do and your willingness to share it.

Hermes iPhone 6 plus case said...

I think the fact that there are links between – that exist between the Pakistani government and the Haqqani network – the nature of those I think can be assessed and is complicated, but there is no question that they have safe havens in Pakistan... and that Pakistan has not taken action to eliminate those safe havens

Hug Day said...

happy hug day 2016
happy hug day 2016 Date SMS Messages Quotes
How Hug Day Is Celebrated
Happy hug day sms

Mary said...

happy new year 2016, happy new year images 2016, happy new year wallpapers 2016, happy new year quotes 2016, happy new year wishes 2016, happy new year sms 2016, happy new year greetings 2016, whatsapp status

Pervez Joarder said...

We have been for that reason pleased you merely examine this type of. My partner and I significantly enjoyed these records in addition to the seeking dispute. At present register Payday Loans Thank you regarding fantastic details.

Libin Huang said...

20160426libinhollister clothing store
oakley sunglasses
michael kors handbags
tiffany outlet
ray-ban sunglasses
gucci outlet online
ray-ban sunglasses
burberry outlet online
coach outlet canada
ray-ban sunglasses
herve leger outlet
ray ban sunglasses sale
air max 90
oakley sunglasses
adidas wings shoes
michael kors outlet
michael kors factory outlet
louis vuitton bags
michael kors online outlet
nba jerseys
ralph lauren pas cher
oakley sunglasses
toms shoes
nike air max 90
nike tn pas cher
air max 90
lululemon outlet
nike air force 1
true religion outlet
michael kors outlet
burberry outlet store
ray ban sunglasses
kobe shoes
true religion outlet
discount michael kors handbags

Yuanyuan Lin said...

7.14llllllyuan"ferragamo shoes"
"chrome hearts outlet"
"air jordan shoes for sale"
"tory burch outlet online"
"hollister"
"michael kors outlet"
"ralph lauren femme"
"thomas sabo uk"
"adidas uk store"
"louis vuitton outlet"
"coach outlet"
"coach handbags"
"burberry outlet"
"coach outlet online"
"rolex watches"
"cheap oakley sunglasses"
"tiffany outlet"
"cheap football shirts"
"celine outlet online"
"michael kors handbags clearance"
"snapbacks wholesale"
"michael kors outlet"
"toms outlet store"
"true religion outlet uk"
"coach outlet store"
"oakley sunglasses"
"celine outlet"
"swarovski outlet"
"cheap snapbacks"
"longchamp pas cher"
"michael kors outlet online"
"fitflops clearance"
"nike roshe run"
"coach outlet online"
"oakley sunglasses"
7.14

Fangyaya said...

coach factory outlet
kate spade handbags
jordan 11
abercrombie outlet
cheap toms
ray ban sunglasses uk
adidas uk
michael kors canada outlet
lebron 13 shoes
burberry outlet
insanity workout
the north face jackets
kobe 10
louis vuitton purses
adidas factory outlet
timberlands
fitflop sale
lebron 12
fitflop shoes
concords 11
ladies cartier watches
ralph lauren polo shirts
coach outlet store online
toms shoes outlet
adidas superstar shoes
lebron 13
cheap jerseys
oakley sunglasses
instyler
adidas yeezy
louis vuitton outlet online
gucci outlet
tods outlet store
coach factory outlet online
juicy couture
pandora charms
coach outlet
cheap beats headphones
coach outlet
michael kors outlet online
20168.8chenjinyan

dada24 Xu said...

nmd adidas
oakley vault
cheap uggs
adidas nmd
moncler jackets
longchamp
michael kors outlet clearance
polo ralph lauren outlet online
michael kors watches
nike flyknit
2016921caiyan

Ann Lily said...

I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. I like play game five nights at freddy’s 4, game word cookies game , game word cookies answers , hotmail sign in and hotmail login, and u? I hope people visit my website.

huali10 Cai said...

rolex watches for sale
louis vuitton
cheap jordans for sale
air max 90
longchamp outlet
nike outlet store online
tory burch outlet online
futbol baratas
cheap oakley sunglasses
michael kors outlet clearance
qqqqqing20170411

Unknown said...

cheap replica watches
air max 90
iphone case uk
michael kors handbags
ralph lauren outlet
michael kors canada
nike air max 90
coach outlet
michael kors outlet clearance
michael kors outlet
chanyuan2017.05.08

xjd7410@gmail.com said...

coach handbags outlet
ralph lauren outlet
kate spade uk
true religion jeans
mac cosmetics sale
ray-ban sunglasses
coach outlet online
ralph lauren
true religion jeans
new balance outlet
chanyuan2017.05.24

chenlina said...

ralph lauren uk
canada goose outlet store
coach outlet online
michael kors outlet online
adidas yeezy shoes
oakley sunglasses
michael kors outlet
mbt shoes clearance outlet
true religion outlet online
michael kors outlet
20170719wanglili

raybanoutlet001 said...

ferragamo outlet
polo ralph lauren outlet
ugg boots
ugg outlet
ugg boots
nike huarache
supra sneakers
cleveland cavaliers jerseys
jacksonville jaguars jersey
snapbacks wholesale

Home Improvement Westchester County said...

Ajrin Construction Inc. is a privately owned firm and has been providing home improvement and remolding services to clients all across the boroughs of Westchester County NY. Home Improvement Westchester County