response = service.getInfo(request);
How can I display an image while my response object is being populated? Service is a web service located on another server that I have no control over.
Any help is greatly appreciated.
Here is one way to do it.
The bottom line is that you will need some asynchronous process going on. And that implies AJAX. The library or methodology you use is up to you.
Related
For a Business question, I have created one specific detail page. Based on querystring parameters contents could be changed (dynamic contents are fetched from Datasource Repository by id) e.g.
*http://localhost/page/detail?id={88A1AA95-633D-4B0E-AAC7-BA0610F0V091}*
This is not SEO-friendly, so I created a pipeline to fetch the contents in a nicer way. I am using the Sitecore WebUtil to make a request to the application itself.
var content = WebUtil.ExecuteWebPage("http://localhost/page/detail?id={88A1AA95-633D-4B0E-AAC7-BA0610F0V091}")
It's working, but I am asking myself if there is a better way to resolve the rendered page html. I do not like the webrequest to the application itself.
Does anyone have a better solution?
Thanks in advance,
Jordy
If I have a gridview being used in a Default.aspx file, how do I access that gridview in the WebService.cs file? I've been experimenting with interfaces and public classes but I honestly don't know if I'm even on the right track.
Can anyone point me in the right direction?
You can't.
Presumably "webservice.cs" is code for some web service called via AJAX from the page. In this case there is no way to access any controls from the page (including gridview) as this information is not sent to the service.
You can either move code to full page postback (i.e. call same method server side directly) or pass all necessary information to the service.
Hello to everyone!
I am working on project that is client program( WinForm ). When i create new form for new functionality, i need to make a lot of requests to API. For instance i need get statuses to show on form, get data for grid view, check some users data, and so on!
So, question is: Is it ok to have more than 1 request to API, when i load form?
If not how to decrease number of request? or may be i need new method to API, that will return all that data? Thanks!
It is not a best solution that u can make more request to api in form load. You try to write override methods to api if it is open source. so that you can reduce more calls. Learn the api completely about its functionality. If you need more precise answer please post the code or samples which might help you to get what exactly you want.
I'm making a iOS game which will pick a random clue(text) and image (clue and image come in a set, 1 row) from the clue repository in the database. I have a web service with webMethods and functions that allow me to pull the database row out. (tested for clue) I've been searching on Google for articles on how to import image to iOS from db but to no avail.
how to import image from DB by web service (build using c#)? Can anyone please guide me in the right direction? I would like it to be stored in mutableArray so that after the player are done playing, the clue and image will be wipe off the temp array. (i don't want to put the image in the app as that will make the app very large and that user are able to upload their own clues and image, so live feed from database is the ideal method.
Right now I'm stuck on the web service side on importing the image over. I'm currently using List to store the clue, but have no idea on what to use to store image. I am thinking of using ArrayList which store object, but have no idea how to convert it to image at the iOS side. And as I mentioned above, I can't seem to find any tutorial or example that import image to iOS app via web service. (or am I using the wrong search term)
Will be helpful if any1 can help me out, or give alternate solution which enable live update of image and clues.
EDIT - I found ImageList() and List. which one should I be using now?
Also found out to make image file is just -> image testfile;
EDIT2 - problem I'm facing
-dealing with image file (image? imagelist?
-when drawing datarow from DB in webservice, how do i deal with the image file. (guessing ImageList or List<image> (after some luck on research)
-assuming 2nd point works fine, i should be able to solve the client side
(sorry, noobie at webservice, )
.
what I have
-webservice that draw datarow from database for clue(string) (tested and working fine with my function)
-iOS client side with RESTful architecture
.
what I need
-webservice that draw datarow from database for picture(image (format not so important yet)) (code should be similar to drawing clue, only which function to store it in. (using List<string> for clues)
Sounds like you might be getting a bit ahead of yourself. Try solving just one problem at a time; you'll make much more progress.
First, do you know how to download an image to your iOS application? Try downloading a very simple publicly available image like a Google doodle: https://www.google.com/logos/2012/gymnastics-2012-hp.jpg. Whatever IOS application toolkit you're using should have a walkthrough for how to download an image and present it via HTTP.
Second, do you know how to host an image file on your web server? Try downloading a random JPG or PNG image yourself and hosting it on your server as a static file. Then point your IOS application at that static file and download it just like you did with the Google doodle.
If both of those steps work, you can then begin to host dynamic images on your server. Create a page (if you're using ASP.NET) or a controller path (if you're using MVC) and have your C# code use Response.TransmitFile to upload an image to the clickstream. Again, download that image to your IOS application to verify it worked.
Finally, modify your server application to take a parameter - either by a querystring (example: myhost.com/mypage.aspx?image_id=1) or by an MVC path (example: myhost.com/images/1). Use that ID number to retrieve the image information from your database. Then transmit the image to the client. If all goes well, you should then be able to retrieve this image in your IOS app.
I hope this helps you get closer to your project!
I have no experience programming on iOS, but I think that the easiest way is to prepare RESTful api for that. With the REST guidelines in mind, what you end up with is a webservice that defines a resource, and your client needs only to request a particular file (I assume that client somehow knows what the id/name of the image is). This has one big advantage - it is very easy to develop (on any platform) - server side.
When it comes to client side:
1. Use WebRequest object to create a http get request
2. Wait for the data to be downloaded (you may use background worker or just another thread, so that your app is not blocked)
3. When request is complete and you get the response object - read what was sent. It is going to be binary image.
4. Use the binary data (image) and display it in your app.
A sample of how to use WebRequest object is provided by me in different SO thread: https://stackoverflow.com/a/11891240/165751
Note: I assume you know how to retrieve the image from the DB (or any kind of store actually) on your server side so that your webservices can read it and return it as a webresponse.
There are plenty of possibilities when it comes to server side technology, but if you want to stay with .Net technology stack - I suggest to have a look at WCF REST Service Template 40(CS) - I've been using it in the past (and my service was returning images as well :) and I was very happy with it.
We are downloading a full web page using System.Net.WebClient class. But we only want less than half of the page. So is there a way to download a portion of the page, say 1/3rd, half etc of a page using .net library so that We can save the network bandwidth and the space? If so, please throw your ideas, thanks.
You need to provide an "Accept-Ranges header" to your GET or POST request. That can be done by using the AddRange method of your HttpWebRequest:
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create("http://www.foo.com");
myHttpWebRequest.AddRange(0,100);
That would yield the first 100 bytes. The server, however, needs to support this.
The sort answer is not unless the web app supports some way to tailor it's response to what you want it to return.
This could take the form of a
query string parameter
header field value
The simplest way to add this would be a query string parameter and when detected write out the necessary HTML to the response object. If you are unable to make changes to the web app then you won't be able to control how much of a page is returned to you.
You might want to read up on how HTTP works since the question and it's answer relies upon this. Specifically the Header Definition should be helpful.