Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

Embed a file for download in SOAP response

Is there a way to embed a file in an XML documet in Binary or otherwise so that the resonse from a Soap request includes the file?

Is this question vague enough?

Just curious...no rush.

Thanks for responses,

Ben
0
bnye
Asked:
bnye
  • 4
  • 2
1 Solution
 
bnyeAuthor Commented:
This link talks about using a DIME service, however it seems that if I could encode the file in base64 I could stick it in the XML file in BIN.BASE64 tags. If anyone has any tips on how to do that from ASP please let me know I would be happy to cut my dev time down.

Thanks,

Ben
0
 
bnyeAuthor Commented:
I apologize, here is the link:

http://msdn.microsoft.com/msdnmag/issues/02/12/DIME/default.aspx

Thanks,

Ben
0
 
bnyeAuthor Commented:
I apologize, here is the link:

http://msdn.microsoft.com/msdnmag/issues/02/12/DIME/default.aspx

Thanks,

Ben
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sybeCommented:
(sometimes the link does not work, i'll just post the code there:)

Function BinaryToXML(ByVal strFileName As String) As String
Dim xmlDoc As New MSXML.DOMDocument
Dim xmlNode As MSXML.IXMLDOMNode
Dim xmlElement As MSXML.IXMLDOMElement
Dim st As ADODB.Stream
Set st = New ADODB.Stream
st.Type = adTypeBinary
st.Open
st.LoadFromFile strFileName
Set xmlElement = xmlDoc.createElement("binary")
Set xmlDoc.documentElement = xmlElement
Set xmlNode = xmlDoc.createElement("filename")
xmlElement.appendChild xmlNode
xmlNode.Text = Dir(txtFileName.Text)
Set xmlNode = xmlDoc.createElement("blob")
xmlElement.appendChild xmlNode
xmlNode.dataType = "bin.base64"
xmlNode.nodeTypedValue = st.Read
BinaryToXML = xmlDoc.xml
Set xmlDoc = Nothing
Set xmlNode = Nothing
Set xmlElement = Nothing
Set st = Nothing
End Function

Sub XMLToBinary(ByVal strXML As String)
Dim xmlDoc As New MSXML.DOMDocument
Dim xmlNode As MSXML.IXMLDOMNode
Dim st As ADODB.Stream
Dim arrBuffer() As Byte
If xmlDoc.loadXML(strXML) Then
Set xmlNode = xmlDoc.selectSingleNode("//binary")
arrBuffer = xmlNode.selectSingleNode("blob").nodeTypedValue
Set st = New ADODB.Stream
st.Type = adTypeBinary
st.Open
st.Write arrBuffer
st.SaveToFile xmlNode.selectSingleNode("filename").Text, adSaveCreateOverWrite
Set xmlNode = Nothing
Set st = Nothing
End If
Set xmlDoc = Nothing
End If
End Sub



0
 
bnyeAuthor Commented:
Sybe -

This a great example. This seems to be the most clear example I have seen on the subject. However I did find the following examples as well in case other readers decide to look into this.


http://support.microsoft.com/default.aspx?scid=KB;en-us;q254388

http://www.topxml.com/xml/articles/binary/XML%20and%20Binary%20Data2.asp

http://www.15seconds.com/issue/010522.htm

Thanks again,

Ben
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now