0

How to extract a bmp data from webresponse in c#.Need to extract only the bmp data and save it as bmp file. Not getting idea for extracting this data from respose stream.. Response stream is something like this...

--==vR1se8TeJPE+OIhZBEh4LvMWHzRSAJyHPubj6sIo4uxOan2qLg+N0L67Pnxc==
Content-Type: application/xop+xml; type="application/soap+xml"; 
charset="utf-8"
Content-Transfer-Encoding: binary
Content-ID: <d569a93d-2406-4130-ba60-a61cb17f2818@uuid>

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-    
envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"     
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:mex="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:PNPX="http://schemas.microsoft.com/windows/pnpx/2005/08" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:xmime1="http://www.w3.org/2004/06/xmlmime" xmlns:xmime2="http://www.w3.org/2004/11/xmlmime" xmlns:wsdp="http://schemas.xmlsoap.org/ws/2005/05/devprof" xmlns:wprt="http://schemas.microsoft.com/windows/2005/05/wdp/print" xmlns:wscn="http://schemas.microsoft.com/windows/2006/08/wdp/scan" xmlns:UNS1="http://schemas.microsoft.com/windows/test/testdevice/11/2005">
<SOAP-ENV:Header><wsa:Action>http://schemas.microsoft.com/windows/2006/08/wdp/scan/RetrieveImageResponse</wsa:Action><wsa:MessageID>urn:uuid:6b416342-543c-4371-b46e-c9abbfeb362f</wsa:MessageID><wsa:RelatesTo>uuid:1ec39293-61c3-421e-86d8-a2e1e392c388</wsa:RelatesTo><wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To></SOAP-ENV:Header><SOAP-ENV:Body><wscn:RetrieveImageResponse><wscn:ScanData><xop:Include href="cid:01c50dcb-8e69-4b68-8ee0-962ae9d9702d@uuid"/></wscn:ScanData></wscn:RetrieveImageResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

--==vR1se8TeJPE+OIhZBEh4LvMWHzRSAJyHPubj6sIo4uxOan2qLg+N0L67Pnxc==
Content-Type: image/dib
Content-Transfer-Encoding: binary
Content-ID: <01c50dcb-8e69-4b68-8ee0-962ae9d9702d@uuid>
//////////////////Sample bmp data...format not supporting to paste 
here...........

**BMクYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY**

--==vR1se8TeJPE+OIhZBEh4LvMWHzRSAJyHPubj6sIo4uxOan2qLg+N0L67Pnxc==--
Aamir
  • 2,380
  • 3
  • 24
  • 54
  • Find where the BMP data starts using String.IndexOf and you've got your BMP! – Shannon Holsinger Sep 01 '16 at 02:58
  • WebResponse response = webrequest.GetResponse(); System.IO.Stream st = response.GetResponseStream(); but when we try to read using streamreader ,data format is corrupting...is there any way to sort it out in stream... – user2235253 Sep 01 '16 at 03:05
  • I can't help much without being able to see the returned HTTP, but check out http://stackoverflow.com/questions/2368115/how-to-use-httpwebrequest-to-pull-image-from-website-to-local-file – Shannon Holsinger Sep 01 '16 at 03:12

0 Answers0