Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBScript Byte Array WebService

Posted on 2007-03-29
7
Medium Priority
?
2,070 Views
Last Modified: 2012-05-05
I am trying to call a webservice which returns a byte array which is a file.... I am trying to do this with vbscript.  I can call the webservice no problem the issue is how do I get the contents (which is the actual file) to disk?  I can get through the document and locate the contents the question is how do I get it to disk?  I have essentially a text string which is an array of bytes and I dont know what to do with it.. in vb.net this is no problem I just dont know how to handle in vbscript.. can anyone help?
0
Comment
Question by:NTGuru705
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18817188
Hello NTGuru705,
You just need to write it to a file?
Use the FSO...
Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim objOutput: SetobjOutput=objFSO.CreateTextFile("C:\YourFile.txt")
objOutput.WriteLine YourData

~sirbounty
0
 
LVL 1

Author Comment

by:NTGuru705
ID: 18817250
Well not really... the data isnt text... so I am ot writing a text file...

The webservice is handing me a binary file... and it is handing it to me as a return parameter which is a byte array...

So i .net I can do something like this..

Public Function WriteFile(ByVal ccDocument As Byte(), ByVal FilePath As String) As Integer
        Dim objFstream As FileStream
        Dim lngLen As Long = ccDocument.Length
        Try
            objFstream = File.Open(FilePath, FileMode.Create, FileAccess.Write)
            objFstream.Write(ccDocument, 0, CInt(lngLen))
            objFstream.Flush()
            objFstream.Close()
        Catch ex As Exception
            ErrorHandler("WriteFile", ex.Message, AgentName, EventLogEntryType.Error, -5000)
            Return -5000
        End Try

        If Not objFstream Is Nothing Then
            objFstream.Close()
            objFstream = Nothing
        End If
        'IF YOU DIDNT ENCOUNTER AN ERROR RETURN 0
        Return 0
    End Function

How to do this in vbscript though?
0
 
LVL 22

Accepted Solution

by:
WMIF earned 1000 total points
ID: 18818007
you should be able to do the same thing in asp/vbscript using the adodb.stream object.
http://www.w3schools.com/ado/ado_ref_stream.asp
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:NTGuru705
ID: 18818456
right but to write binary data you have to use the wrtie method and the parameter is a byte array which I dont think vbscript supports.
0
 
LVL 1

Author Comment

by:NTGuru705
ID: 18819135
Ok I am making progress here...

This is what the XML looks like.. note the content is in the document element...
Problem is when I write it back to disk it isnt right.. anyone recognize the encoding or something?  This is just being returned from a vb.net webservice as a byte array.


<ccDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://services.firstfleetinc.com/">
  <ccDocGID>1004</ccDocGID>
  <Document>DQogImNjX0FkZEF0dHJpYnV0ZSAiICYgY2NEb2NHSUQgJiAiLCIgJiBjY0FUeXBlR0lEICYgIiwnIiAmIGNjQVZhbHVlICYgIg0KLS0gUkVUVVJOUyBUSEUgQVZBTFVFR0lEDQoNCnNxbCA9ICJjY19WYWxpZGF0ZUFWYWx1ZSAiICYgY2NBVHlwZUdJRCAmICIsJyIgJiBjY0FWYWx1ZSAmICInIg0KLS0gUkVUVVJOUyAxIE9SIDAgRk9SIFRSVUUgT1IgRkFMU0U=</Document>
- <ccDocProperties>
  <ccDocGID>1004</ccDocGID>
  <ccDocStatus>1</ccDocStatus>
  <ccDocStatusName>Pending Index</ccDocStatusName>
  <ccSorceFileExt>txt</ccSorceFileExt>
  <ccDocTypeGID>1000</ccDocTypeGID>
  <ccDocType>DEFAULT</ccDocType>
  <ccDocDate>2007-03-26T14:44:46.407</ccDocDate>
  <ccDocSize>203</ccDocSize>
  <ccDocQueueGID>1000</ccDocQueueGID>
  <ccDocWFName>UNK</ccDocWFName>
  <ccDocWFGID>0</ccDocWFGID>
  <ccDocWFSequence>0</ccDocWFSequence>
  <ccDocAdded>2007-03-26T14:44:46.407</ccDocAdded>
  <ccDocAuthor>1000</ccDocAuthor>
  <ccDocAuthorID>admin</ccDocAuthorID>
  <ccDocEdited>2007-03-26T14:44:46.407</ccDocEdited>
  <ccDocEditor>1000</ccDocEditor>
  <ccDocEditorID>admin</ccDocEditorID>
  <ccDocViewed>2007-03-26T16:11:24.28</ccDocViewed>
  <ccDocViewer>1000</ccDocViewer>
  <ccDocViewerID>admin</ccDocViewerID>
  <ccErrorCode>0</ccErrorCode>
  <ccErrorString />
  </ccDocProperties>
- <ccDocAttribues>
- <ccDocAttributes>
  <ccRowID>3</ccRowID>
  <ccATypeGID>1000</ccATypeGID>
  <ccATypeName>DEFAULT</ccATypeName>
  <ccAValueGID>1</ccAValueGID>
  <ccAValue>Test</ccAValue>
  <ccErrorCode>0</ccErrorCode>
  <ccErrorString />
  </ccDocAttributes>
- <ccDocAttributes>
  <ccRowID>4</ccRowID>
  <ccATypeGID>1000</ccATypeGID>
  <ccATypeName>DEFAULT</ccATypeName>
  <ccAValueGID>2</ccAValueGID>
  <ccAValue>Sivils</ccAValue>
  <ccErrorCode>0</ccErrorCode>
  <ccErrorString />
  </ccDocAttributes>
  </ccDocAttribues>
  <ccErrorCode>0</ccErrorCode>
  <ccErrorString />
  </ccDocument>
0
 
LVL 29

Assisted Solution

by:rdivilbiss
rdivilbiss earned 1000 total points
ID: 18820304
Probably Base64 encoded
0
 
LVL 1

Author Comment

by:NTGuru705
ID: 18876888
yes and there are lots of dlls I have found to help me write this file to disk... thank for your help.. reference link

http://www.experts-exchange.com/Programming/Languages/Scripting/Q_22497192.html

0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question