Iframe web service call

Last post 05-05-2008 8:25 PM by gt1329a. 8 replies.

Sort Posts:

  • Iframe web service call

    04-30-2008, 5:17 AM
    • Loading...
    • Dested
    • Joined on 10-11-2006, 6:26 AM
    • Phoenix
    • Posts 166

    Is there any kind of api for using .net webservices in an iframe that anyone knows of? Anyone have any references so I can write my own? I am trying to make a webservice call cross-domain and this is the only way I see possible. Anyone know of another way?                 

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Iframe web service call

    04-30-2008, 7:39 AM
    • Loading...
    • kim3er
    • Joined on 04-30-2008, 10:29 AM
    • West Yorkshire, UK
    • Posts 10
    Hi, I would avoid using iframes if possible. Instead, I'd suggest creating a proxy on your server. So, consume the external web service on your server. Then write a web service on your server that exposes the required functionality to your client. Rich
  • Re: Iframe web service call

    04-30-2008, 7:57 AM
    • Loading...
    • Dested
    • Joined on 10-11-2006, 6:26 AM
    • Phoenix
    • Posts 166

     I am writing an API that I need to be accessible outside of my domain, can you think of another way? Isnt this why google maps uses iframes?

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Iframe web service call

    04-30-2008, 8:07 AM
    • Loading...
    • kim3er
    • Joined on 04-30-2008, 10:29 AM
    • West Yorkshire, UK
    • Posts 10
    Okay, I understand now. No, I'm not aware of another way. I would certainly not suggest using iframes in your markup, however I believe it is an acceptable compromise to create one dynamically as part of a client script.
    My suggestion for this would be to provide a location to a JavaScript file. The JavaScript file can be accessed from an external domain. If you generating the JavaScript dynamically you accept query strings, allowing for customisation. This is the model that Google use for a lot of their services including Maps and Charts.
    Rich
  • Re: Iframe web service call

    04-30-2008, 8:17 AM
    • Loading...
    • Dested
    • Joined on 10-11-2006, 6:26 AM
    • Phoenix
    • Posts 166

     Its an api to make a series of calls, each returning an xml (or json) string to be interpreted. I currently have it all working as web service calls. What do you think is the best way to implement this?

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Iframe web service call

    04-30-2008, 8:28 AM
    • Loading...
    • kim3er
    • Joined on 04-30-2008, 10:29 AM
    • West Yorkshire, UK
    • Posts 10
    Okay, before I start I should mention that I have never done this before, so a few tests would not hurt before you commit yourself to a course of action.

    Having said that, I would write ASHX that returns JavaScript (much like a JSON WebService). This ASHX would build pre-packaged functions based on the QueryString passed in for the external client. When the external developer embeds your ASHX into their page using a script tag, the returned JavaScript should be available to the page. Please correct me if I'm wrong.

    Google Maps and Google Charts use this technique to dynamically embed HTML elements into an external domains website. Similarly, Google Analytics uses this technique to gather information about the external domains client.

    Rich
  • Re: Iframe web service call

    04-30-2008, 8:40 AM
    • Loading...
    • Dested
    • Joined on 10-11-2006, 6:26 AM
    • Phoenix
    • Posts 166

    I think that this will only work if I load the script in the beginning. I need to be able to make calls on the page asynchronously using this javascript api. I would still need to use a iframe to call the ashx page, although that would get me around my current problem of trying to post an iframe. I think I may try this. 

     

    As far as a real solution to this problem, anyone else interested in writing a javascript api to access the .net webservices via iframe as to allow cross-domain access? 

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Iframe web service call

    04-30-2008, 9:33 AM
    Answer
    • Loading...
    • mrmercury
    • Joined on 04-04-2006, 2:26 PM
    • Mexico City, Mexico
    • Posts 316

    Maybe this article can help you:

    http://dotnetslackers.com/columns/ajax/MashitUpwithASPNETAJAX.aspx

    Hope this helps,

    Elias.

    If this post helped you please remember to set it as Answer so it can help others.
  • Re: Iframe web service call

    05-05-2008, 8:25 PM
    • Loading...
    • gt1329a
    • Joined on 06-23-2002, 8:53 PM
    • Atlanta
    • Posts 1,704
    JSONP is the way to go for remote calls, if the target service supports it.
Page 1 of 1 (9 items)
Microsoft Communities
Page view counter