473,569 Members | 2,836 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 8574
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
2235
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 actual data, therefore the BLOB data per se would not get written to the log, only the pointer would be written. If log shipping works by...
0
3134
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 extract the XLS files later. This works wonderfully. The Article is 103257, ACC: Reading, Storing, & Writing Binary Large Objects (BLOBs)...
2
4982
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. Thanks
5
16099
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 to an access database and I can save the data back to a file using getchunk and everything works correctly). The issue is that I am now trying to...
3
5229
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 database and display it in a Image web control dynamically(at runtime). The process after being displayed in the web control, user click insert/add...
1
8288
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) { header("Content-type: image/jpeg"); print $bytes; exit (); }
0
1842
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 empty content. I'm using ADODB (http://phplens.com/adodb/) library to execute sql statements. Could someone please help me out on how to fetch the...
5
1858
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
8138
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 uploading code is: MYSQL_CONNECT("localhost","root",""); mysql_select_db("sample"); $data = addslashes(fread(fopen($form_data, "r"),...
6
8484
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 functions as follows.,
0
7695
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5218
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.