Dynamic Destination Users (or xmlfields) from an external Web Service

  • 28 August 2008
  • 8 replies
  • 0 views

Badge +1

Hi guys,


I need to call and process some xml data coming from an external Web Service.... that is going to return something like this:


<Implementors><Implementor>K2:DEVUser1</Implementor><Implementor>K2:DEVUser2</Implementor></Implementors>


(I copied that line from another post),,,  so, my questions are:


1- How/from Where can I call that web service?


2-And do I have to assign that info to an xmldata manually to destination users_?


 Any help will be much appreciated....


8 replies

Badge +5

You'll have to have these data available at the destination rule code, from there you can iterate over the <Implementor> node and assign the worklist items to the users.


It's up to you if you want to store the xml in a xml field, but whats matter is when the destination rule code executes, the data should be available then.

Badge +1

Thanks yousef, can you please give me any hints, code or some screenshot about how to this work with the destination rule code?


Regards

Badge +11

Here are some ideas to get you started in the order of your questions:


1.  You have several options available to call a web service. 


a.  First, in the project references dialog (the icon is on the top right part of the designer canvas) you can add a reference to .NET assemblies, COM components, and web services.  When you add a web service you just need specify the location of the WSDL.  Once you have added the reference, you can call the web service through a default server code event just like you would call a web service in any .NET application. 


TIP:  create an environment variable to hold the URL of the web service.  That way you can set the .Url property on the service to the correct development/production value easily.


b.  You can use the Dynamic Web Service project located on blackmarket to invoke the web service without code.  However, I'm not sure at this point if it handles complex datatypes like your example.


c.  You could write your own .NET assembly that makes the call to your web service and then use the project references dialog mentioned above to include it in the project.  I tend to use this method if I will re-use the item in several different workflows.


No matter which way you choose, you might want to consider storing the results in an XML data field.  To do this, create a new XML datafield and then use the dialog to load the schema for your data type. 


2.  If you have loaded your datatype into an XML field, you can use the context browser to drop the repeating element containing the user from your XML data field into the destination rule wizard with no code.


David

Badge +3

Hey David, Aaron Here.


Is there a way to use the repeating xml node in a destinatino rule and also assign a filter on that as well?


For instance I want to use the repeating node <identities> that has an attribute called "role'. I want all users that are a role = "author"


Is that possible to do?


 


Regards.

Badge +11

Hi Aaron,  (is this the Aaron of the far frozen north?)


Unfortunately you cannot filter XML repeating nodes in a destination rule using the wizard.  My own preference is not use code in destination rules. But in a server code event where you could filter out your values and store them in another XML field to be used in the destination rule of another activity


If the data was stored in a SmartObject the ability to filter is built-in. 


And you just gave me an idea for a new blackmarket project that does this...  :)


David

Badge +3

Yes, Im the one.


So maybe the solution is to dump the xml to a smart object first then use the built in filtering ability of said SO? Ive pretty much decided on using an xml document to contain all the necessasary information from my form submittal then dump to an xmlfield.


Regards,


 

Badge +3

On the other hand, I may just want to reorganize my xml with a different node list for each type of role.


 

Badge +11
That may be the easiest approach.

Reply