How Can I add reference to Webservice in C1

Topics: General, XSLT
Sep 3, 2011 at 7:28 PM

I have a project that requires calls from a webservice. How can I add the reference in the project and make calls from the Webservice which returns the XML.  With that XML, I need to transform using XSLT to display the page.  Can this all be done in C1?  How?  Please help.  Thank you

Coordinator
Sep 5, 2011 at 8:02 AM

You can either

1. use Composite.Xml.LoadUrl function,

2. add an external function:

a) Create a "C# Class library" project,

b) add the web reference through Visual Studio, create the code that reads the feed,

c) copy the result dll to "/Bin" folder and call it as an "External C# function"

Sep 6, 2011 at 3:47 AM
napernik wrote:

You can either

1. use Composite.Xml.LoadUrl function,

2. add an external function:

a) Create a "C# Class library" project,

b) add the web reference through Visual Studio, create the code that reads the feed,

c) copy the result dll to "/Bin" folder and call it as an "External C# function"

 

Thank you Napernik for the response. Can you clarify a bit more with an example of what you mean?

1, Composite.Xml.LoadUrl function:
- how would use this function to call a webservice function without referencing the webservice within C1 project?

Right now, I have a div tag run at server and code behind that uses the XML transform function to call my webservice for the XML and getting my XSLT to place the string into the div tag I had on the aspx file. How would I translate this to what you mean above, using the LoadUrl function or with the external function?

2, External Function:
To fully understand, I like to check if I properly understand what you wrote here and the documentation link you provided:
A) do you mean, I first create a new web project in visual studio. In this project, I create my classes and reference the webservice. Then I compile to a dll and placed inside the /bin folder of the C1 project. Any changes to my classes, I would have to open my external classes project abd recompile, correct?  Finally within C1, I reference the function of my classes abd pass parameters as shown in your documentation pages. Is this correct?

Thank you again!

Coordinator
Sep 8, 2011 at 7:34 AM

Sorry for the late answer

 

1. To think of it, it won't work on for standard asp.net web services, since you need to do a POST reguest to get data, and and LoadUrl usually does GET. I often expose data as xml without using web services, f.e., like http://community.composite.net/EventCalendar/EventCalendar.GetEvents.ashx so it is easy get by using LoadUrl or JQuery

2. >> do you mean, I first create a new web project in visual studio. 

I meant "Class library" project, the one that compiles in to a dll. But alternatively (and it will be quicker to do), you can open the site in Visual Studio and add a "Service reference", and use it in App_Code file, this way you will not have to deal with an additional dll


>> Finally within C1, I reference the function of my classes abd pass parameters as shown in your documentation pages. Is this correct?

 Yes, in C1 you can add an "external function" that will be defined in App_Code folder of the site

Sep 8, 2011 at 11:59 AM

napernik > when exposing data for use in jQuery you should sent JSON data instead of xml. Not just because of less data on the wire, but also because the browser can parse JSON a multitude faster than xml.

Sep 8, 2011 at 5:22 PM

Thank you both! I created the Class Library with the Web Reference and just passed in the string for the path of XSLT and it works.