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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

15 Experts available now in Live!

Get 1:1 Help Now