04-21-2011 09:42 AM
Web services are a very handy means for integrating third-party applications into SalesLogix. While binding to a web service in Visual Studio is very simple, I was having a hard time comming up with a way to reference a web servcie from within a CodeSnippet or c#Snippet.
For those who may not know the steps for doing this, it's actualy quite easy once you understand what happens when you add a Web Reference in Visual Studio.
I preferr to to most of my coding in Visual Studio, since IntelliSense goes allot deeper there. So, I add a Web reference in Visual Studio to bind to my web service. Do my coding using my new web service reference, and then copy the code back to Visual Studio to add to my SmartPart or business rule there.
From the Website that is open in visual studio you will see a folder at the Root called App_WebReferences. Copy that folder into the Root of Support files in the SalesLogix Portal folder in App Architect. This folder contains the files that define the namespace for your webservice.
Now all you need to do it tell Portal that the reference is there. To do this, you need to add a key to the Web.config of the portal. Under the <appSettings> section add the following key that tells the web client the URL location (default endpoint) of your web service...
<add key="myservice.myclass" value="https://myservcieurl/myservice.asmx"/>
For the exact syntax of your web service, you can copy this key from the Web.config for the portal you have open in Visual Studio where you orriginaly added your web refrence.
Something for the future: I'm haven't spent much time figuring it out, but you won't have IntelliSense when coding to your web service in App Architect. I'm sure there is an easy way to do this, but I haven't figured that part out yet. If anyone wants to contribute that to this post, I'm sure many (including myself) will appriciate the help.
Hope this saves someone some time working with Web Services in SLX...
07-11-2012 03:25 AM
This is a great article and helped me set up a link to webservices for the smart parts, and it works great there.
But I do have a question - is there a way I can use the same web.config changes for Code Snippets? I tried placing the same code that I used for the smart part, but when I build it doesn't understand the web service reference, am I missing something? Do the code snippets have access to web.config in some way, or do I need to add the reference differently?
I need a way to implement webservices in both smart parts and code snippets using a single config source for the URL. Since in our system we have Dev, QA, Pre-Prod and Live webservices with different URLS, so I need to be able to toggle this easily in a single config place when moving code between Development and Live.