+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Call ImageService web service from javascript

Call ImageService web service from javascript

7 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    06 Apr 2011
    Link to this post
    Hi,

    Is it possible to call the ImageService web service from the JS of a control designer? I want to pass the image ID, and retrieve back properties of the image.

    Thanks
    higgsy
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    06 Apr 2011
    Link to this post
    Hello higgsy,

    You can use the client manager to invoke the service call



            this._successDelegate = Function.createDelegate(this, this._successHandler);
            this._failureDelegate = Function.createDelegate(this, this._failureHandler);

            var clientManager = new Telerik.Sitefinity.Data.ClientManager();
            var serviceUrl = this._webServiceUrl;
            var urlParams = [];        
            if (this._defaultItemTypeName) {
                urlParams["itemType"] = this._defaultItemTypeName;
            }
            if (providerName) {
                urlParams["provider"] = providerName;
            }
            urlParams["published"] = true;

            var keys = [defaultImageId];
            clientManager.InvokeGet(serviceUrl, urlParams, keys, this._successDelegate, this._failureDelegate, this);


    ....



    _successHandler: function (caller, data, request, context) {
            var item = data.Item;
        },

    _failureHandler: function (error, caller, context) {

            alert(error.Detail);
        },

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    06 Apr 2011
    Link to this post
    Hi Ivan - thanks for your quick response. Can I ask why this differs from the documentation? The documentation suggests that the ImageService can be called directly? I'm certainly not questioning your answer, I'm just trying to better understand the sitefinity 4 architecture. Thanks again Higgsy
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    06 Apr 2011
    Link to this post
    Hello higgsy,

    I am calling the service through the client side using ClientManager. In its basis the ClientManager uses Sys.Net.WebRequest(); that performs an actual web request

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    07 Apr 2011
    Link to this post
    Hi Ivan,

    Do you have an example of this  working anywhere? I would like to see how it is structured in a control designer script...

    Thanks
    higgsy
  6. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    07 Apr 2011
    Link to this post
    Hi Ivan,

    I've almost got this working, however when I run the code something odd is happening to the URL - if I check firebug there is always a 404 error returned, and when I look at the url it looks like so:

    /Sitefinity/Services/Content/ImageService.svc//e/5/c/b/e/4/b/6/-/4/7/a/4/-/4/1/c/8/-/b/e/6/5/-/5/b/e/8/1/b/3/c/5/9/a/e/?itemType=Telerik.Sitefinity.Libraries.Model.Image&published=true&provider=OpenAccessDataProvider&checkOut=true&unv_tstmp_prm=1302197071985

    It looks like the key, the Image Guid - has been messed up....is there any reason why this might be happening?

    Thanks
    higgsy
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    08 Apr 2011
    Link to this post
    Hello higgsy,

    You should instantiate the keys as

    var keys = [];

    Then use push method to add a new element to the end of the array.

    The same applies for urlParams (var urlParams = [];)

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
7 posts, 0 answered