{"id":1881,"date":"2015-10-27T18:52:48","date_gmt":"2015-10-27T13:22:48","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=1881"},"modified":"2015-10-27T18:52:48","modified_gmt":"2015-10-27T13:22:48","slug":"load-data-from-web-service-to-dynamics-crm-using-ssis","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2015\/10\/load-data-from-web-service-to-dynamics-crm-using-ssis\/","title":{"rendered":"Load Data from Web Service to Dynamics CRM using SSIS"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"text-decoration: underline;\"><strong>Introduction: <\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">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\u00a0<a href=\"https:\/\/www.inogic.com\/blog\/2015\/09\/iterating-and-processing-records-in-dynamics-crm-using-ssis\/\">Iterating and Processing Records in Dynamics CRM using SSIS<\/a>.<\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #800000;\"><strong><em>Also see :<a href=\"http:\/\/bit.ly\/1KD7s8e\" target=\"_blank\" rel=\"noopener noreferrer\">\u00a0<\/a><a title=\"Inogic Dynamics CRM Solutions\" href=\"https:\/\/www.inogic.com\/blog\/2015\/09\/inogic-dynamics-crm-solutions-change-the-pace-of-your-business-decisions\/\" target=\"_blank\" rel=\"noopener noreferrer\">Analytics in Dynamics CRM\u00a0now has a new name &#8211; Maplytics<\/a><\/em><\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"text-decoration: underline;\"><strong>Walkthrough:<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">Here let\u2019s check out the whole process step by step.<\/p>\n<p style=\"text-align: justify;\">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:-<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1882 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS.png\" alt=\"Load Data from Web Service to Dynamics CRM\" width=\"754\" height=\"166\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Here I have named the web service control as Get Global Weather Service. Right click on the web service control \u00e0 Edit. Add the Service connection string as follows and set it to the HTTPConnections in Connection tab as you can see highlighted below :-<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1883 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS1.png\" alt=\"SSIS\" width=\"748\" height=\"639\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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:<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS2.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1884 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS2.png\" alt=\"web service task editor\" width=\"750\" height=\"640\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">Now move on to next tab i.e. Input.<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS3.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1885 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS3.png\" alt=\"Load data using SSIS\" width=\"747\" height=\"637\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">Then we move on to the next tab i.e. Output.<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS4.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1886 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS4.png\" alt=\"Using SSIS in Dynamics CRM\" width=\"747\" height=\"635\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">After all the settings are done for the web service control click OK and the web service is set up.<\/p>\n<p style=\"text-align: justify;\">Let\u2019s declare following variables which will be used later.<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS5.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1887 size-large\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS5-1024x275.png\" alt=\"SSIS\" width=\"665\" height=\"178\" \/><\/a>Next 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 :-<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS6.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1888 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS6.png\" alt=\"SSIS in Dynamics CRM\" width=\"743\" height=\"595\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">For removing the library reference we add the XML Task control and rename it to \u201cRemove Library reference from XML\u201d and right click &#8211;&gt; Edit and set the following properties.<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS7.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1889 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS7.png\" alt=\"SSIS\" width=\"747\" height=\"636\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">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 \u201cGlobalVariableResponse\u201d 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.<\/p>\n<p style=\"text-align: justify;\">\u00a0Note: You can get this XSLT to remove namespace on net.<\/p>\n<p style=\"text-align: justify;\">\u00a0&lt;xsl:stylesheet xmlns:xsl =&#8221;http:\/\/www.w3.org\/1999\/XSL\/Transform&#8221; version =&#8221;1.0&#8243; &gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0 &lt;xsl:template match =&#8221;@*&#8221; &gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0\u00a0\u00a0 &lt;xsl:attribute name =&#8221;{local-name()}&#8221; &gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;xsl:value-of select =&#8221;.&#8221; \/&gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0\u00a0\u00a0 &lt;\/xsl:attribute&gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0\u00a0\u00a0 &lt;xsl:apply-templates\/&gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0 &lt;\/xsl:template&gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0 &lt;xsl:template match =&#8221;*&#8221; &gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0\u00a0\u00a0 &lt;xsl:element name =&#8221;{local-name()}&#8221; &gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;xsl:apply-templates select =&#8221;@* | node()&#8221; \/&gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0 \u00a0\u00a0&lt;\/xsl:element&gt;<\/p>\n<p style=\"text-align: justify;\">\u00a0 &lt;\/xsl:template&gt;<\/p>\n<p style=\"text-align: justify;\">&lt;\/xsl:stylesheet&gt;<\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">Next we want to extract the data from response. In our example we provided CountryName = \u201cUnited States\u201d and cityName = \u201cNew York\u201d to get the weather report of New York city. And the XML response returned is something like this \u2013<\/p>\n<p style=\"text-align: justify;\">&lt;string\u00a0xmlns=&#8221;http:\/\/www.webserviceX.NET&#8221;&gt;<\/p>\n<p style=\"text-align: justify;\">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-16&#8243;?&gt; &lt;CurrentWeather&gt; &lt;Location&gt;NEW YORK LA GUARDIA AIRPORT , NY, United States (KLGA) 40-47N 73-53W 11M&lt;\/Location&gt; &lt;Time&gt;Oct 25, 2015 &#8211; 09:51 AM EDT \/ 2015.10.25 1351 UTC&lt;\/Time&gt; &lt;Wind&gt; from the SW (220 degrees) at 9 MPH (8 KT):0&lt;\/Wind&gt; &lt;Visibility&gt; 7 mile(s):0&lt;\/Visibility&gt; &lt;SkyConditions&gt; overcast&lt;\/SkyConditions&gt; &lt;Temperature&gt; 57.0 F (13.9 C)&lt;\/Temperature&gt; &lt;DewPoint&gt; 53.1 F (11.7 C)&lt;\/DewPoint&gt; &lt;RelativeHumidity&gt; 86%&lt;\/RelativeHumidity&gt; &lt;Pressure&gt; 30.08 in. Hg (1018 hPa)&lt;\/Pressure&gt; &lt;Status&gt;Success&lt;\/Status&gt; &lt;\/CurrentWeather&gt;<\/p>\n<p style=\"text-align: justify;\">&lt;\/string&gt;<\/p>\n<p style=\"text-align: justify;\">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:-<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS8.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1890 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS8.png\" alt=\"SSIS\" width=\"750\" height=\"640\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">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 :-<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS9.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1891 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS9.png\" alt=\"SSIS \" width=\"740\" height=\"663\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Next we add the DataFlowControl and move the data stored from XPATH to CRM fields as follows \u2013<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS10.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1892 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/10\/SSIS10.png\" alt=\"Data flow control\" width=\"692\" height=\"348\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">Note : Here we have used Kingswaysoft SSIS Integration Toolkit for Dynamics CRM.<\/p>\n<p style=\"text-align: justify;\"><span style=\"text-decoration: underline;\"><strong>Conclusion:<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">Thus we can get data from Webservice and move it to Dynamics CRM smoothly.<\/p>\n<p>Before you move to the next post, have you seen our new\u00a0<a href=\"https:\/\/www.inogic.com\/blog\/2015\/10\/word-excel-or-pdf-now-exporting-in-dynamics-crm-is-1-click\/\" target=\"_blank\" rel=\"noopener noreferrer\">Click2Export<\/a>\u00a0Solution? A 1 click solution to export reports to Word\/Excel and Pdf. Email us on\u00a0<a href=\"mailto:crm@inogic.com\">crm@inogic.com<\/a>\u00a0for a trial or if you would like to see a live demo.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: 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\u00a0Iterating and Processing Records in Dynamics CRM\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2015\/10\/load-data-from-web-service-to-dynamics-crm-using-ssis\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[19,24,31,57],"tags":[592,998,1654],"class_list":["post-1881","post","type-post","status-publish","format-standard","hentry","category-dynamics-crm","category-dynamics-crm-2016","category-integrations-dynamics-crm","category-ssis","tag-dynamics-crm","tag-load-data-from-web-service","tag-ssis"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/1881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=1881"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/1881\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=1881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=1881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=1881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}