in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

C1ZipEntry no XML serializable

Last post 05-25-2007 10:38 AM by C1_BernardoC. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-23-2007 3:22 PM

    • Josh
    • Top 200 Contributor
    • Joined on 04-03-2006
    • Posts 21

    C1ZipEntry no XML serializable

    My existing software sends xml data from a windows client to windows server via IIS and Web Services. All web service parameters are currently data type "string".  What is the best way to compress this transfer of information using C1Zip?

    When i create a web service such as:

    <WebMethod()> Public Function TestZip(ByVal oFile As C1.C1Zip.C1ZipFile) As String

    i get this error: 

    To be XML serializable, types which inherit from ICollection must have an implementation of Add(C1.C1Zip.C1ZipEntry) at all levels of their inheritance hierarchy. C1.C1Zip.C1ZipEntryCollection does not implement Add(C1.C1Zip.C1ZipEntry).

    what are my options here?  i simply want to send a zip from a client to server using MS web services.

    note: i do not want to use http form post methods.  my guess is i will have to convert the zip to a byte array?  but i dont know how

    thanks

    josh

  • 05-23-2007 3:34 PM In reply to

    • Josh
    • Top 200 Contributor
    • Joined on 04-03-2006
    • Posts 21

    Re: C1ZipEntry no XML serializable

    so far i found this sample which will require the client to convert the C1zip file to a byte array, but im not sure what that client code will look like to convert zip to byte array?

    also i would like if the server doesnt have to write the file to disk, but somehow get access to the c1zipfile.entries function via the memorystream below "m" ?  (hope that makes sense)

    <WebMethod()> PublicFunction UploadFile(ByVal fs()As Byte,ByVal FlName As String)As String
      Try
          Dim m As New MemoryStream(fs)
          Dim f As New FileStream("c:\tempUploaded\" & FlName, FileMode.Create)
          m.WriteTo(f)
          m.Close()
          f.Close()       
          f = Nothing
          m = Nothing
          Return "File Uploaded"

      Catch ex As Exception
        Return ex.Message
      End Try
    End Function

  • 05-24-2007 12:41 PM In reply to

    • Josh
    • Top 200 Contributor
    • Joined on 04-03-2006
    • Posts 21

    Re: C1ZipEntry no XML serializable

    I found the solution in your previous post and sample : Memory.zip and discussed in http://helpcentral.componentone.com/cs/forums/192841/ShowPost.aspx

    I recommend you change the title of the sample to "Strings to streams" or something useful, the short title "memory" is somewhat ambiguous and I passed it up my first time around as it appears many others have also.

     

    I do have a question concerning datasets which can read xml from a stream:

    In the servers .readxml method could I provide sr as the stream object or is it necessary to use the reader object?

     

    ***Server Code***

    Dim strFinal As String = ""

    Dim ms As MemoryStream = New MemoryStream(fs)

    Dim sr As C1.C1Zip.C1ZStreamReader = New C1.C1Zip.C1ZStreamReader(ms)

    Dim reader As StreamReader = New StreamReader(sr)

    Dim DsSQL1 as new dataset  ‘actual code uses typed dataset

     

    DsSQL1.ReadXml(sr)  'or DsSQL1.ReadXml(reader)

     

    ms.Close()

     

    ***Client Code****

    Dim str1 As String = ""

    str1 = Me.dsSQL1.GetXml

    Dim ms As MemoryStream = New MemoryStream()

    Dim sw As C1.C1Zip.C1ZStreamWriter = New C1.C1Zip.C1ZStreamWriter(ms)

    Dim writer As StreamWriter = New StreamWriter(sw)

    writer.Write(str1)

    writer.Flush()

    clsWebServiceInstance.webMethodCall(ms.ToArray())

  • 05-25-2007 10:38 AM In reply to

    Re: C1ZipEntry no XML serializable

    > In the servers .readxml method could I provide sr as the stream object or
    > is it necessary to use the reader object?

    You should be able to use 'sr', it really is a stream.
Page 1 of 1 (4 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.