473,394 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How can I deliver images to the client from a web service?

Hi,

I know this post will be considered off-topic. There are a lot of good
coders in these groups and I'm hoping someone can help me out. This is what
I'm working on. I used to use the webservice.htc alot, but now I have to
code for Netscape and Mozilla and it didn't work. This was a good thing,
the webservice.htc would choke if you sent back things like arraylists so I
wrote my own wrapper. No matter what you send (dataset, array, array of
classes, array list, etc.) it'll parse it and let you work with objects
created in javascript. Works great.

Here is the problem. I can't figure out how to dish back images. I have
the browser use XMLHTTP to request an image. I dish it back as a byte array
which I then parse. For the life of me I can't figure out how to change
this byte array into an image using javascript. I've tried everything I can
think of. But the way javascript works you can't just take a valid image in
an array and assign it to a new image object. The var you assign it to just
becomes an array, there is no type conversion that I know of.

With Mozilla I was able to overrun the buffer and then execute code that
would switch an old image with a new one. But I couldn't get it to work
with IE and since this is a total security hack I'm sure it'll be closed
soon for all browsers. I'm able to use javascript to hit a bogus page that
just does a response.write() that delivers the image. But this isn't
elegant because I then need to have the bogus page hit the web service and I
want the client to hit it directly. Anyone have a clue how to do this?

Since I'm on a rant I have another question. Take the XML below as an
example:

<Food>
<Pizza topping="pepperoni">
</Pizza>
</Food>

Parsing this with IE is easy. But in both Netscape and Mozilla the line
breaks are considered children. So while Food really only has one child in
Netscape and Mozilla it appears to have 2 children. The first child is
nothing but a line break, the 2nd child is Pizza. Now logic would tell you
there should at least be 3 then (for the line break between </Pizza> and
</Food>) but there is only two. Pizza also shows to have a child when it
really doesn't. So basically I'm stuck doing the code below. That code
will take any array (even an arraylist) that you return from a web service
and turn it into a javascript object that lets you refer to things by their
actual name. What ticks me off is that for Netscape and Mozilla I have to
test if they are the browser used, if they are I have to like pre-parse it
as you see below. Anyone know any way around this? Thanks for any help!
Ken.

P.S. I use my real email so feel free to spam me for being off topic (I am
doing all this with ASP.Net). But if my Hungarian Notation ticks you
off...spare me the spam and get a life! ;-}
case constArray:
if (flgMoz == false) {
strXML = objOTBReq.responseXML.documentElement;
intNumberOfNodes = strXML.childNodes.length;
}
else {
strXML = objOTBReq.responseXML.documentElement;
flgNotDone = true;
while(flgNotDone) {
flgNotDone = false;
for (intNumberOfElements = 0; intNumberOfElements <
strXML.childNodes.length; intNumberOfElements++) {
if (strXML.childNodes[intNumberOfElements].nodeType == 3) {
strXML.removeChild(strXML.childNodes[intNumberOfElements]);
flgNotDone = true;
break;
}
}
}
intNumberOfNodes = strXML.childNodes.length;
flgNotDone = true;
while(flgNotDone) {
for (intCounter = 0; intCounter < intNumberOfNodes; intCounter++) {
flgNotDone = false;
for (intNumberOfElements = 0; intNumberOfElements <
strXML.childNodes[intCounter].childNodes.length; intNumberOfElements++) {
if
((strXML.childNodes[intCounter].childNodes[intNumberOfElements].nodeType ==
3) &&
(strXML.childNodes[intCounter].childNodes[intNumberOfElements].nodeValue ==
"")) {

strXML.childNodes[intCounter].removeChild(strXML.childNodes[intCounter].chil
dNodes[intNumberOfElements]);
flgNotDone = true;
}
}
}
}
}
strNodeName = strXML.nodeName;
if (strNodeName.indexOf("anyType") != -1) {
intNumberOfNodes -= 1;
}
ReturnValue.Value = new Array();
objReturnValue = new Object();
for (intElementCounter = 0; intElementCounter <
strXML.childNodes[0].childNodes.length; intElementCounter++) {
if
(strXML.childNodes[0].childNodes[intElementCounter].childNodes.length != 0)
{
if (strXML.childNodes[0].childNodes[intElementCounter].firstChild
== null) {
eval("objReturnValue." +
strXML.childNodes[0].childNodes[intElementCounter].nodeName + " = '';");
}
else {
eval("objReturnValue." +
strXML.childNodes[0].childNodes[intElementCounter].nodeName + " =
strXML.childNodes[0].childNodes[intElementCounter].firstChild.nodeValue;");
}
}
else {
eval("objReturnValue.Value =
strXML.childNodes[0].childNodes[intElementCounter].nodeValue;");
}
}
ReturnValue.Value[0] = objReturnValue;
for (intNodeCounter = 1; intNodeCounter < intNumberOfNodes;
intNodeCounter++) {
objReturnValue = new Object();
for (intElementCounter = 0; intElementCounter <
strXML.childNodes[intNodeCounter].childNodes.length; intElementCounter++) {
if
(strXML.childNodes[intNodeCounter].childNodes[intElementCounter].childNodes.
length != 0) {
if
(strXML.childNodes[intNodeCounter].childNodes[intElementCounter].firstChild
== null) {
eval("objReturnValue." +
strXML.childNodes[intNodeCounter].childNodes[intElementCounter].nodeName + "
= '';");
}
else {
eval("objReturnValue." +
strXML.childNodes[intNodeCounter].childNodes[intElementCounter].nodeName + "
= strXML.childNodes[intNodeCounter].childNodes[intElementCounter].firstChild
..nodeValue;");
}
}
else {
eval("objReturnValue.Value =
strXML.childNodes[intNodeCounter].childNodes[intElementCounter].nodeValue;")
;
}
}
ReturnValue.Value[intNodeCounter] = objReturnValue;
}
break;
Nov 19 '05 #1
0 1279

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Don | last post by:
Does anyone know where I can find a client-side function I can reference from within an HTML/JavaScript web page? I'm currently using a core PHP function to do this, but I'd rather do it on the...
4
by: rachel | last post by:
Hello, I am currently contracted out by a real estate agent. He has a page that he has created himself that has a list of homes.. their images and data in html format. He wants me to take...
3
by: Gardar | last post by:
I'm creating a web service using ASP.net that needs to respond with pdf files or images to HTTP-GET requests. I've searched extensively and not found any documentation or examples. What I'm...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
0
by: Rod | last post by:
I orginally posted this to microsoft.public.sqlserver.ce but had not received any responses. I have a CF.NET application (C#) with a SqlCE database. We had originally planned to use SQL...
1
by: Geoff | last post by:
I'm new to web services but am trying to create a web service in VB.NET 2003 to query and convert MS Sql 2000 Data to a comma-delimited text file and transfer the data based on the parameters...
1
by: WebServiceSecurity | last post by:
The issue involves the following technologies: - 1. .NET 2.0 Framework 2. WSE2.0 (WS-Security) 3. X.509 certificates 4. BEA Weblogic 8.1.5
19
by: marckatsambis | last post by:
Hi, I'm struggling to find answers on the problem I'm having, and I desperately need some closure :) I have a bunch of background-images in a css file that are visible locally, but when I...
8
by: Frank Millman | last post by:
Hi all This is not strictly a Python question, but as the system to which relates is written in Python, hopefully it is not too off-topic. I have an accounting/business application, written in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.