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

x
?
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
Medium Priority
?
2,327 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
[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
3 Comments
 
LVL 12

Accepted Solution

by:
ShazbotOK earned 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

730 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