1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    32
    Vote Rating
    0
    hrishikeshp19 is on a distinguished road

      0  

    Default extract an image from a web service

    extract an image from a web service


    Hello all,

    I have a web service which gives be just an image...i.e. a web service just returns this

    <img src="tmpcharts/cd__165.140.68.995115366001308696518_0.png" />

    How do I show this image into a panel.

    Please reply asap. Thanks for help.

  2. #2
    Sencha User jamesgpearce's Avatar
    Join Date
    Jun 2010
    Location
    Palo Alto
    Posts
    61
    Vote Rating
    0
    jamesgpearce is on a distinguished road

      0  

    Default


    Is it the same domain as the app? If so, just use an AJAX request to get this HTML fragment and .update() the panel with it.

    If it's not the same domain, you'll have to have the service returning some sort of JSON-P payload wrapping this fragment.

    Also check out the data-URL feature of src.sencha.io: http://docs.sencha.com/io/src/#data-urls if you need to programmatically access image data.

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    32
    Vote Rating
    0
    hrishikeshp19 is on a distinguished road

      0  

    Default


    Thank you for prompt reply.

    When I put the service request url in the web browser address bar, it actually shows me the image in the browser. So, I want something similar to this. So, I want to extract that image and put it onto the panel. Is there a way to do so.

    Thanks again,

    Hrishikesh P
    San Jose State Univ.

  4. #4
    Sencha User jamesgpearce's Avatar
    Join Date
    Jun 2010
    Location
    Palo Alto
    Posts
    61
    Vote Rating
    0
    jamesgpearce is on a distinguished road

      0  

    Default


    Just to be clear... the service returns the HTML, not the raw image itself? As I suggested, use AJAX and then the update() method of the panel to put the HTML into it.

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    32
    Vote Rating
    0
    hrishikeshp19 is on a distinguished road

      0  

    Default


    I tried a lot...but no luck...my service call is like

    "http://p.../.../.../..&target=screen"

    when opened in a web browser the "view source" source gives just this...

    <img src="tmpcharts/cd__165.140.68.4159272299081308775677_0.png" />

    ajax request always fails...I think I am doing a cross domain request. But, the image is not absolute path, its downloading a raw image.

    Could you please give me a sample code that I should work on.

    Thanks again,

    Hrishikesh

  6. #6
    Sencha User jamesgpearce's Avatar
    Join Date
    Jun 2010
    Location
    Palo Alto
    Posts
    61
    Vote Rating
    0
    jamesgpearce is on a distinguished road

      0  

    Default


    The browser could be faking the HTML. Can you just curl it on the command line:

    curl -I http://yourservice.com/whatever

    And see what the content-type header is.

    Is the domain the same as the one you have your app on? There's no point pasting code until we know if we need cross domain support (e.g. JSONP or CORS vs AJAX)

    JP

  7. #7
    Sencha User
    Join Date
    Jun 2011
    Posts
    32
    Vote Rating
    0
    hrishikeshp19 is on a distinguished road

      0  

    Default


    Yes, domains are different. So...is there any way to do it without changing the service?

  8. #8
    Sencha User jamesgpearce's Avatar
    Join Date
    Jun 2010
    Location
    Palo Alto
    Posts
    61
    Vote Rating
    0
    jamesgpearce is on a distinguished road

      0  

    Default


    Without changing the service your only option is an iFrame I think:

    Code:
    {
      xtype: "panel",
      html: "<iframe src='http://yourservice.com/...'> </iframe>"
      ...
    }

  9. #9
    Sencha User
    Join Date
    Jun 2011
    Posts
    32
    Vote Rating
    0
    hrishikeshp19 is on a distinguished road

      0  

    Default


    Thank you very much James. Actually, I changed the service to solve my problem.

    Best Regards,

    Hrishikesh Paranjape.

  10. #10
    Sencha User
    Join Date
    Sep 2012
    Posts
    3
    Vote Rating
    0
    jyotis017 is on a distinguished road

      0  

    Default consuming image from web service.

    consuming image from web service.


    i m taking image from jsonp web service in string form , but not getting hoe to display that string on panel..
    How can this be done?