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,199 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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