Solved

how to convert browsed .zip compressed  file as byte [] array to pass as a parameter to web service 's web method

Posted on 2008-10-21
3
2,186 Views
Last Modified: 2012-05-05
i have web service method which takes compressed .zip file as a byte.

// web service method
 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/LogBatchEvents", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public string LogBatchEvents([System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] byte[] InputFile) {
            object[] results = this.Invoke("LogBatchEvents", new object[] {
                        InputFile});
            return ((string)(results[0]));
        }

// converting file into byte

private byte[] StreamFile(string filename)
    {
        FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);

        // Create a byte array of file stream length
        byte[] ImageData = new byte[fs.Length];

        //Read block of bytes from stream into the byte array
        fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length));

        //Close the File Stream
        fs.Close();
        return ImageData; //return the byte data
    }

// following code where i m using above methods

 StrFileName = Server.MapPath(StrFileName);
                byte[] xmlData = new byte[1000];
                xmlData = StreamFile(StrFileName);
                UtilityWebApp._6202k3sesp1.Logging webserviceObj = new Logging();
                string strOutPut = string.Empty;                
                strOutPut = webserviceObj.LogBatchEvents(xmlData);

Problem :1. i belive it is not taking file as Byte[] array.how to convert browsed file as a byte[] array becuase web service will take only byte [] array as a parameter.

2. when i am runing above written code it is giving
    strOutPut = "<?xml version="1.0" encoding="utf-8"?><Parameters><version>1.0</version><ErrorCode>1</ErrorCode><ErrorMessage>Could not load file or assembly 'vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</ErrorMessage></Parameters>"

what can be problem ?
0
Comment
Question by:ajay1feb
3 Comments
 
LVL 12

Accepted Solution

by:
ShazbotOK earned 500 total points
ID: 22766546
Using MTOM or DIME is you best option for send/receive of binary data over a service:
http://msdn.microsoft.com/en-us/library/ms824597.aspx
Base64 transmissions will only cause a download to be inflated by 10x the origional size of the binary file.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now