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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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