Load Data from Web Service to Dynamics CRM using SSIS

By | October 27, 2015


Sometimes there are cases where we need to make a call to web service, from where we get data and save that data to Dynamics CRM entity. The response which we get from web service is in xml form. In one of our recent post we explained about Iterating and Processing Records in Dynamics CRM using SSIS.

Also see : Analytics in Dynamics CRM now has a new name – Maplytics


Here let’s check out the whole process step by step.

Create a new SSIS package. Here we will take the free global weather returning web service for example. Add the web service control from the SSIS toolbox and rename it to the web service which you will be consuming as follows:-Load Data from Web Service to Dynamics CRM

Here I have named the web service control as Get Global Weather Service. Right click on the web service control à Edit. Add the Service connection string as follows and set it to the HTTPConnections in Connection tab as you can see highlighted below :-SSIS

Now you need to download the WSDL file for which you need to create a empty .wsdl file and point its location to the WSDLFile as you can see in below image:web service task editor

Set the OverwriteWSDL File property to True and click on the Download WSDL button which will download the WSDL file for the webservice pointed at the specified location.

Now move on to next tab i.e. Input.Load data using SSIS

In above image you can see, as soon as we switch to Input tab in the Service property we start to get the GlobalWeather service to choose from dropdown. In the Methods property we get all the methods that are provided by the GlobalWeather webservice. Here in this example we have taken GetWeather method. As soon as we select the method we get the input parameters that are exposed by the service method. Here we can see two parameters viz. CityName and CountryName. You can directly set the values for these input parameters or you can set the variables through which you can set its value as you can see in above image. Also check the Variable checkbox and you get the option to set the value for variables using package variables. Here I have created two package variables and set them as input parameters.

Then we move on to the next tab i.e. Output.Using SSIS in Dynamics CRM

In OutputType we can either set it as Variables where the response output from webservice will be stored in a variable we define as we have taken or else we can set it to file in which case the response will be written to the file.

After all the settings are done for the web service control click OK and the web service is set up.

Let’s declare following variables which will be used later.SSISNext we need to remove the library references if any which are returned in the web service response or else we will not be able to extract the exact data. To do this we add a sequence container and connect it to the web service control. Then we add the XML Task control to process the library reference and add get the data. In below image you can find that :-SSIS in Dynamics CRM

For removing the library reference we add the XML Task control and rename it to “Remove Library reference from XML” and right click –> Edit and set the following properties.SSIS

As you can see in the above image we need to set the Operation type as XSLT. Set the SourceType as Variable as we are saving our service response in variable. Set the Source to the variable in which the service response was set.

Set the SaveOperationResult to True and Set the variable where you want to save after the XSLT operation is performed. We set the output to the same “GlobalVariableResponse” variable. Set the secondOperandType to variable and specify the SecondOperand as the variable (removeXMLLibXSLT). Here in this variable we have stored the XSLT that will remove the namespaces from XML.

 Note: You can get this XSLT to remove namespace on net.

 <xsl:stylesheet xmlns:xsl =”http://www.w3.org/1999/XSL/Transform” version =”1.0″ >

  <xsl:template match =”@*” >

    <xsl:attribute name =”{local-name()}” >

      <xsl:value-of select =”.” />




  <xsl:template match =”*” >

    <xsl:element name =”{local-name()}” >

      <xsl:apply-templates select =”@* | node()” />




After the library reference is removed if further want to process the response and start from any particular node of XML we can do that by adding a script component as we have done in our case.

Next we want to extract the data from response. In our example we provided CountryName = “United States” and cityName = “New York” to get the weather report of New York city. And the XML response returned is something like this –

<string xmlns=”http://www.webserviceX.NET”>

<?xml version=”1.0″ encoding=”utf-16″?> <CurrentWeather> <Location>NEW YORK LA GUARDIA AIRPORT , NY, United States (KLGA) 40-47N 73-53W 11M</Location> <Time>Oct 25, 2015 – 09:51 AM EDT / 2015.10.25 1351 UTC</Time> <Wind> from the SW (220 degrees) at 9 MPH (8 KT):0</Wind> <Visibility> 7 mile(s):0</Visibility> <SkyConditions> overcast</SkyConditions> <Temperature> 57.0 F (13.9 C)</Temperature> <DewPoint> 53.1 F (11.7 C)</DewPoint> <RelativeHumidity> 86%</RelativeHumidity> <Pressure> 30.08 in. Hg (1018 hPa)</Pressure> <Status>Success</Status> </CurrentWeather>


We want to get Location, Time, Visibility and Temprature. We can do this by using XPATH method. As you can see in below image we add XML task and set XPATH in it as follows:-SSIS

Here we set OperationType as XPATH. SourceType as variable to point to the XML response variable. We specify the SaveOperationResult to True and store the OperationResult in the respective variables. Now to specify XPATH we set the SecondOperandType as Direct Input. And in SecondOperand we give the XPATH. In XPath Options we set the PutResultInOneNode to False and set XPathOperations to values.

Thus we set the XPATh for all the fields from XML response which we want to retrieve as you can see highlighted in below image :-SSIS

Next we add the DataFlowControl and move the data stored from XPATH to CRM fields as follows –Data flow control

We take script component where we get the data stored in the variables from XPATH operation and set it to the script Output which is then provided as input to the Dynamic CRM Source control and create a CityWeather entity record.

Note : Here we have used Kingswaysoft SSIS Integration Toolkit for Dynamics CRM.


Thus we can get data from Webservice and move it to Dynamics CRM smoothly.

Before you move to the next post, have you seen our new Click2Export Solution? A 1 click solution to export reports to Word/Excel and Pdf. Email us on crm@inogic.com for a trial or if you would like to see a live demo.

Leave a Reply