UPDATE: Simon Fell caught me in the midst of evil, as he rightfully points out that when one bypasses a SOAP Stack and "does their own thing" as I have here, I must perform the SOAP Processing Rules. I've update the code below, changes in RED.
NOTE: In the interest of correctness, I've included namespace qualification in the NEW code.
A fellow emailed me wanting to get a PDF file out of a SOAP Envelope and write it directly out to the browser using Classic ASP. Here's the code I used:
<% Set m_Doc = Server.CreateObject("MSXML2.DOMDocument.4.0")m_Doc.async = falsem_Doc.ValidateOnParse = false'This could come from whereever, ADO, a file, another Web Service.m_Doc.Load Server.MapPath(".") + "\\soapresponse.txt" m_Doc.setProperty "SelectionNamespaces", "xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:def='http://localhost/'"'There's nothing that I DO understand, so if there's anything I must, I'm screwed.Set oHeader = m_Doc.selectNodes("//soap:Envelope/soap:Header/*[@soap:mustUnderstand = '1']")If (Not oHeader Is Nothing) Then If (oHeader.Length > 0) Then Response.Write("Crap! I can't continue! What to do?") Response.End End IfEnd If'Yes, it's a // XPath, but that's the LEAST of our problems before we get into microperfSet oNode = m_Doc.selectSingleNode("//def:GetImageAsBase64Result")'This is the Magic that makes it possible. Otherwise you'll get a string.oNode.dataType = "bin.base64" Response.ContentType="application/pdf"Response.AddHeader "Content-Disposition", "filename=whatever.pdf"Response.BinaryWrite oNode.nodeTypedValue%>
This is given a SOAP Response like this:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetImageAsBase64Response xmlns="http://localhost/"><GetImageAsBase64Result>JVBERi0xLjI SNIP....etc...
Scott at DevReach in Bulgaria in October
Developer Stand up Comedy - Coding 4 Fun
TechDays/DevDays Netherlands and Belgium:
Posts by Category Posts by Month
Greatest Hits Dev Tools List