473,503 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display image retreived from SOAP as BLOB data

3 New Member
Hi All ,
I am New to this Form i am working on project to consume Java Webservice from PHP (front end).i have posted the same topic in this forum yesterday but i thought the topic which is discussed here is relavent to mine. So i need to display an image sent from JWS (WSDL) mode in PHP. I have used diff methods in JWS to send the image viz as BLOB type or byte type. But unable to display it in PHP. It need to be decoded back to display which i am unable to do. Does PHP's current version has this capabilty or not??. Here is my code snippet of the soap Response genertated to be consumed in PHP.

Expand|Select|Wrap|Line Numbers
  1. stdClass Object
  2. (
  3.     [return] => stdClass Object
  4.         (
  5.             [photo] => stdClass Object
  6.                 (
  7.                     [bytes] =>  Ю —5N5MGIF89a ‡ЯИ5Sх  z  jGIF89a ‡!1џZZZcџkkksss„„„œџЅЅЅНRННЦЮЮЦЮЮЮжЅЮо{оо*„чJяч  „œяџяJŒяRcяœBџџcџœџ1џBџ„џЮџЮџџџџџџџџџџџџџџџџџџџ  џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ  џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ  џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ  
  8.  )
  9.  
  10.             [student_address] => 123-933-22, LA, Hyd ,India
  11.             [student_history] => Completed M.Tech from             [student_hobbies] => Eating, Chatting ,Sleeping etc ...
  12.             [student_id] => 1
  13.                    )
  14.  
  15. )
  16.  
I am accessing this response thru this PHP code ::

Expand|Select|Wrap|Line Numbers
  1. $wsdl = "http://localhost:8084/webserviceproj/WebServicesService?wsdl";
  2. $client = new soapclient($wsdl,array('trace' => 1));
  3. $res=$client->__soapCall('studDetails', array('parameters' => $params));  
  4. $variables = get_object_vars($res);
  5. $keys = array_keys($variables);
  6. $abc= $variables[$keys[0]]->photo;
  7.  $aa = $abc->bytes;
  8.  
so i need to display image from SOAP response. see i am sending either BLOB Datatype or byte from Java. Can any one help me out. thanks
Jan 25 '08 #1
2 8563
Atli
5,058 Recognized Expert Expert
Hi.

I've moved your question into it's own thread to avoid hijacking Hejman's thread.

If you want PHP to display an image, it must be done in a separate PHP document that has it's Content-Type set to an image type.

You need to get the binary data from your SOAP response into this separate PHP document and print it there.

One way would be to temporarily store the image data on your file-system so it could be accessed by the image PHP document.

For example:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. # --
  3. # index.php
  4. #  This is the PHP document that
  5. #  would receive the SOAP data
  6. #  and display it.
  7. # --
  8.  
  9. # Get the SOAP stuff
  10. #  ... Insert code here
  11.  
  12. # Get the binary data into a temporary file
  13. $tempDir = "myTemporaryFiles/";
  14. $timeStamp = time() . mt_rand(100, 999);
  15. $tempName = "tempImage_{$timeStamp}.tmp";
  16.  
  17. $data = $soapObj->photo->bytes;
  18.  
  19. file_put_contents($tempDir . $tempName, $data);
  20.  
  21. # Display the image
  22. echo "<img src='showImage.php?ts={$timeStamp}' alt='' />";
  23. ?>
  24.  
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. # showImage.php
  3. #  This is the PHP that acutally
  4. #  shows the image.
  5. #  Browsers will consider this document
  6. #  to be an JPEG Image, rather than HTML
  7. # --
  8.  
  9. # Get the timeStamp sent via GET
  10. if(!isset($_GET['ts']) or empty($_GET['ts'])) {
  11.   die("Timestamp is missing or invalid");
  12. }
  13. else {
  14.   $timeStamp = trim($_GET['ts']);
  15. }
  16.  
  17. # Get the image data
  18. $tempDir = "myTemporaryFiles/";
  19. $tempName = "tempImage_{$timeStamp}.tmp";
  20. $data = file_get_contents($timeDir . $tempName);
  21.  
  22. # Remove the temporary file
  23. unlink($tempDir . $tempName);
  24.  
  25. # Set header and print data
  26. header("Content-Type: image/jpeg");
  27. echo $data;
  28. ?>
  29.  
Jan 25 '08 #2
adilzcool
3 New Member
Hi,
I have tried to display it but it is not displaying image correctly . I am passing data from Java Webservice using BLOB Datatype . it is creating tmp file in the specified folder but is not converting back to image file. Can MTOM solve this problem. If there is any example using MTOM can u plz provide it thanks.
Jan 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2232
by: Ellen K | last post by:
Hi all, It was my understanding (Please correct me if I'm wrong on this!) that BLOB data actually reside on their own separate pages and a BLOB field only holds a pointer to the location of the...
0
3128
by: Paul Kennedy | last post by:
I have a situation where I am utilizing code from MSDN to insert XLS files into a Microsoft Access Table in a column of Ole Object using VBA and DAO. That code also provides me with a method to...
2
4972
by: RedSouljaz | last post by:
Hi, How to display image that was saved in database ms sql server 2000 into picture box. The field type that I use in database is Images I can save to database but cannot show from database. ...
5
16085
by: Mark | last post by:
I have a VB 6 program that I have saved an audio file to using DAO and the appendchunk as is shown at http://support.microsoft.com/kb/103257/EN-US/. ; I have it working fine in that app (it saves...
3
5224
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
1
8216
by: jamal8t2 | last post by:
i have inserted blob data in database , but i am not able to access back that data to the browser. i have php script but it does not work proprly. our script is below if ($_REQUEST == 1) { ...
0
1835
by: Hemanth | last post by:
Hi, I'm trying to select the content from a BLOB field in a oracle table. The regular select statement doesn't seem to work (Eg. select content from file_table where file_id=1). It's returning...
5
1853
by: faizalahmd | last post by:
How to display image in image control , which is retrieved from the data base . using c# in asp.net regards, FAIZAL AHMED.H
4
8131
by: foss | last post by:
HI all, I am able to upload the image as blob to mysql. but while displaying the image i cant display it properly . The code used for uploading image to mysql inserts data into mysql table.The...
6
8472
by: vjayis | last post by:
hi i have stored user profile images in an BLOB field., and need to display it as an thumbnail image in their profile page., and i searched through the net and got the result using header...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
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
7460
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...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.