Getting a picture by web service

Hi all,
I'm building a web service that gets a pupile details from a database by giving his ID number. I have no problem with the personal details. Now I'm dealing with the pupile picture.
1. How can I deal with the pictures in the database.
2. How to get them by the web service.
3. What is the format can I get the picture, can I get it as XML stream, and get it back.

Please help me. and if you know a link for a web service tutorial that get a pictures.

Best regards...

[500 byte] By [Wasim] at [2007-12-17]
# 1
Hello Wasim,

You should pass the image data as a byte array. Take a look at the following link for a quick sample.

Cheers,
-Todd Foust

ToddFoust at 2007-9-9 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 2

Thanks alot,
When I try to open the file stream with the following path :

"C:\\Inetpub\\wwwroot\\MirseWebService\\bin\\Pictures\\Ramz.jpeg"

Always I get the exception : couldn't find the

"C:\\Inetpub\\wwwroot\\MirseWebService\\bin\\Pictures\\Ramz.jpeg"
file.
I tried to add the @ at the start, but no succeed.

What can be the problem...

Wasim at 2007-9-9 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 3
Were you able to figure that last error out? Have you tried using @"C:\Inetpub\wwwroot\MirseWebService\bin\Pictures\Ramz.jpeg" or just "C:\Inetpub\wwwroot\MirseWebService\bin\Pictures\Ramz.jpeg"? Either of those work for you?

Cheers
-Todd Foust

ToddFoust at 2007-9-9 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 4
Dear Cheers,
I tried :

@"C:\Inetpub\wwwroot\MirseWebService\bin\Pictures\Ramz.jpeg"
and I get the same error, I have a FileExceptionError.

I checked carefully, by copying the path and past it exactly, by no result.
My code is the following:

string strPersonPictureFilePath=@"C:\Inetpub\wwwroot\MirseWebService\bin\Pictures\Ramz.jpeg";

try

{

FileStream personPictureFile =

new FileStream(strPersonPictureFilePath,FileMode.Open, FileAccess.Read);

personPictureData = new Byte[personPictureFile.Length];

personPictureFile.Read(personPictureData, 0, personPictureData.Length);

personPictureFile.Close();

}

catch (Exception error)

{
int i=0; // only for stopping here

}

Is there any relation to security or IIS problems that can cause this.

Please help me...

Wasim at 2007-9-9 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 5

The full exception, message, and possibly callstack would help us here. It does sound like you have to worry about permissions here. You can use Filemon from sysinternals.com to determine if you're missing permissions on the folders or files. Try giving the Everyone account read access to these folders/files and see if that helps get past whatever error message you're getting.

-Todd

ToddFoust at 2007-9-9 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 6
I get the message:
Could not finf the file,
@"C:\Inetpub\wwwroot\MirseWebService\bin\Pictures\Ramz.jpeg"

I copied the exact path and past it. the file is exsist.

How can I use the callstack to solve the problem.
Regards...

Wasim at 2007-9-9 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 7
If it was a permissions issue then you should probably get a Sytem.UnauthorizedAccessException with the error "Access to the path <path> is denied".

Try creating a empty text (.txt) file and put it on the root of your C:\ drive, like C:\test.txt, then change your application to see if it gets same error on this file.

If that still fails, then try running the same code from a Windows Form application instead of your web service. Can you get a console application or Windows Form application to execute the same code trying to find this Rams.jpeg file? Are you absolutely certain that the path and filename are correct?

As far as getting full error details, if you are not familiar with how to do this, then just try taking off the try...catch.. statements, and just let the VS.NET debugger show you the error in a dialog.

ToddFoust at 2007-9-9 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...

.NET Development

Site Classified