byte[] array 
Author Message
 byte[] array

Hi,

How do I pass a byte array (byte[]) to COM interface?

Cheers

Ollie



Sun, 31 Oct 2004 19:25:31 GMT  
 byte[] array
Ok, i have COM interface implemented in VC++:-

interface IFooBar
{
    [id(1)] SendFile([in] BSTR bstrFileName, [in] VARIANT* varData);

Quote:
}

I want to call this from C# with byte[] that contains the data from a
file.....

FileStream fs = new FileStream("c:\\work\\temp\\Waremouse.mp3",
FileMode.Open);

BinaryReader Reader = new BinaryReader(fs);
Reader.BaseStream.Seek(0, SeekOrigin.Begin);

long lLength = Reader.BaseStream.Length;
Int32 nLength = System.Convert.ToInt32(lLength);

byte[] byteArray = Reader.ReadBytes(nLength);

////////////////////////////////////////////////////////////////////////////
////
// how do i put byte[] into a SAFEARRAY
m_FooBar.SendFile("test.mp3", byteArray);
////////////////////////////////////////////////////////////////////////////
////



Quote:
> How it want receive it? TLB definition ? Is it
> in/out/inout?



Sun, 31 Oct 2004 19:48:37 GMT  
 byte[] array
Ollie,

    How does the interface look in .NET when you import it?  The varData
parameter should be an object, and the marshaller should pick up on that,
marshalling the byte array into the COM object.

    Can you give more information?

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Ok, i have COM interface implemented in VC++:-

> interface IFooBar
> {
>     [id(1)] SendFile([in] BSTR bstrFileName, [in] VARIANT* varData);
> }

> I want to call this from C# with byte[] that contains the data from a
> file.....

> FileStream fs = new FileStream("c:\\work\\temp\\Waremouse.mp3",
> FileMode.Open);

> BinaryReader Reader = new BinaryReader(fs);
> Reader.BaseStream.Seek(0, SeekOrigin.Begin);

> long lLength = Reader.BaseStream.Length;
> Int32 nLength = System.Convert.ToInt32(lLength);

> byte[] byteArray = Reader.ReadBytes(nLength);

////////////////////////////////////////////////////////////////////////////
Quote:
> ////
> // how do i put byte[] into a SAFEARRAY
> m_FooBar.SendFile("test.mp3", byteArray);

////////////////////////////////////////////////////////////////////////////

- Show quoted text -

Quote:
> ////



> > How it want receive it? TLB definition ? Is it
> > in/out/inout?



Sun, 31 Oct 2004 20:19:55 GMT  
 byte[] array
Well,

I am trying to wirte a web service in VC++ 7.0, using the ATL Wizard, so i
orginally defined my COM interface as:-

__interface IFBFileServerService
{
//Uploads a file onto the web server....
[id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte bData[]);

Quote:
};

Then import the Web reference into a C# project and use the web service as
one expects....

.....
byte[] bData = Reader.ReadBytes(nLength);

//C++ Web Service.......
m_FileServer.UploadFile("Waremouse.mp3", bData);

The signature for the UploadFile is :- void FBFileServer.UploadFile(string
strFileName, System.Byte[] Data)

Any ideas gratefully appreicated

Cheers

Ollie



Quote:
> Ollie,

>     How does the interface look in .NET when you import it?  The varData
> parameter should be an object, and the marshaller should pick up on that,
> marshalling the byte array into the COM object.

>     Can you give more information?

> --
>                - Nicholas Paldino [.NET MVP]



> > Ok, i have COM interface implemented in VC++:-

> > interface IFooBar
> > {
> >     [id(1)] SendFile([in] BSTR bstrFileName, [in] VARIANT* varData);
> > }

> > I want to call this from C# with byte[] that contains the data from a
> > file.....

> > FileStream fs = new FileStream("c:\\work\\temp\\Waremouse.mp3",
> > FileMode.Open);

> > BinaryReader Reader = new BinaryReader(fs);
> > Reader.BaseStream.Seek(0, SeekOrigin.Begin);

> > long lLength = Reader.BaseStream.Length;
> > Int32 nLength = System.Convert.ToInt32(lLength);

> > byte[] byteArray = Reader.ReadBytes(nLength);

////////////////////////////////////////////////////////////////////////////
Quote:
> > ////
> > // how do i put byte[] into a SAFEARRAY
> > m_FooBar.SendFile("test.mp3", byteArray);

////////////////////////////////////////////////////////////////////////////

- Show quoted text -

Quote:
> > ////


message

> > > How it want receive it? TLB definition ? Is it
> > > in/out/inout?



Sun, 31 Oct 2004 20:43:31 GMT  
 byte[] array
Ollie,

    When you define your interface like this:

[id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte bData[]);

    It defines bData as a c-style array.  This is not automation compliant.
What you want is to define bData as a SAFEARRAY (forgive the caps, but that
is the way it is declared).  You want your definition to look something like
this:

[id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]
SAFEARRAY(unsigned char) bData);

    This should show up as a byte array when you import the interface
definition into .NET.

    Hope this helps.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Well,

> I am trying to wirte a web service in VC++ 7.0, using the ATL Wizard, so i
> orginally defined my COM interface as:-

> __interface IFBFileServerService
> {
> //Uploads a file onto the web server....
> [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte bData[]);
> };

> Then import the Web reference into a C# project and use the web service as
> one expects....

> .....
> byte[] bData = Reader.ReadBytes(nLength);

> //C++ Web Service.......
> m_FileServer.UploadFile("Waremouse.mp3", bData);

> The signature for the UploadFile is :- void FBFileServer.UploadFile(string
> strFileName, System.Byte[] Data)

> Any ideas gratefully appreicated

> Cheers

> Ollie


wrote

> > Ollie,

> >     How does the interface look in .NET when you import it?  The varData
> > parameter should be an object, and the marshaller should pick up on
that,
> > marshalling the byte array into the COM object.

> >     Can you give more information?

> > --
> >                - Nicholas Paldino [.NET MVP]



> > > Ok, i have COM interface implemented in VC++:-

> > > interface IFooBar
> > > {
> > >     [id(1)] SendFile([in] BSTR bstrFileName, [in] VARIANT* varData);
> > > }

> > > I want to call this from C# with byte[] that contains the data from a
> > > file.....

> > > FileStream fs = new FileStream("c:\\work\\temp\\Waremouse.mp3",
> > > FileMode.Open);

> > > BinaryReader Reader = new BinaryReader(fs);
> > > Reader.BaseStream.Seek(0, SeekOrigin.Begin);

> > > long lLength = Reader.BaseStream.Length;
> > > Int32 nLength = System.Convert.ToInt32(lLength);

> > > byte[] byteArray = Reader.ReadBytes(nLength);

////////////////////////////////////////////////////////////////////////////
Quote:
> > > ////
> > > // how do i put byte[] into a SAFEARRAY
> > > m_FooBar.SendFile("test.mp3", byteArray);

////////////////////////////////////////////////////////////////////////////

- Show quoted text -

Quote:
> > > ////


> message

> > > > How it want receive it? TLB definition ? Is it
> > > > in/out/inout?



Sun, 31 Oct 2004 21:00:41 GMT  
 byte[] array
Cheers for that, I read this in the help but  it will not compile with a
signature like that, so i thought pass variant that contains the SAFEARRAY
(the normal way to do it).....

BUT the Atl Attribute Provider can not process variant, i guess cos they are
unions and this can not be represented in XML...

So any ides on how to pass variable length data to a ATL implemented web
service, i do not want to break the data down into fix lengths, because then
i have to maintain state on the server side which is just another headache i
do not want to get into at the moment...

Cheers

Ollie



Quote:
> Ollie,

>     When you define your interface like this:

> [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte bData[]);

>     It defines bData as a c-style array.  This is not automation
compliant.
> What you want is to define bData as a SAFEARRAY (forgive the caps, but
that
> is the way it is declared).  You want your definition to look something
like
> this:

> [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]
> SAFEARRAY(unsigned char) bData);

>     This should show up as a byte array when you import the interface
> definition into .NET.

>     Hope this helps.

> --
>                - Nicholas Paldino [.NET MVP]



> > Well,

> > I am trying to wirte a web service in VC++ 7.0, using the ATL Wizard, so
i
> > orginally defined my COM interface as:-

> > __interface IFBFileServerService
> > {
> > //Uploads a file onto the web server....
> > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte bData[]);
> > };

> > Then import the Web reference into a C# project and use the web service
as
> > one expects....

> > .....
> > byte[] bData = Reader.ReadBytes(nLength);

> > //C++ Web Service.......
> > m_FileServer.UploadFile("Waremouse.mp3", bData);

> > The signature for the UploadFile is :- void

FBFileServer.UploadFile(string

- Show quoted text -

Quote:
> > strFileName, System.Byte[] Data)

> > Any ideas gratefully appreicated

> > Cheers

> > Ollie


> wrote

> > > Ollie,

> > >     How does the interface look in .NET when you import it?  The
varData
> > > parameter should be an object, and the marshaller should pick up on
> that,
> > > marshalling the byte array into the COM object.

> > >     Can you give more information?

> > > --
> > >                - Nicholas Paldino [.NET MVP]



> > > > Ok, i have COM interface implemented in VC++:-

> > > > interface IFooBar
> > > > {
> > > >     [id(1)] SendFile([in] BSTR bstrFileName, [in] VARIANT* varData);
> > > > }

> > > > I want to call this from C# with byte[] that contains the data from
a
> > > > file.....

> > > > FileStream fs = new FileStream("c:\\work\\temp\\Waremouse.mp3",
> > > > FileMode.Open);

> > > > BinaryReader Reader = new BinaryReader(fs);
> > > > Reader.BaseStream.Seek(0, SeekOrigin.Begin);

> > > > long lLength = Reader.BaseStream.Length;
> > > > Int32 nLength = System.Convert.ToInt32(lLength);

> > > > byte[] byteArray = Reader.ReadBytes(nLength);

////////////////////////////////////////////////////////////////////////////
Quote:
> > > > ////
> > > > // how do i put byte[] into a SAFEARRAY
> > > > m_FooBar.SendFile("test.mp3", byteArray);

////////////////////////////////////////////////////////////////////////////

- Show quoted text -

Quote:
> > > > ////


> > message

> > > > > How it want receive it? TLB definition ? Is it
> > > > > in/out/inout?



Sun, 31 Oct 2004 21:28:47 GMT  
 byte[] array
Ollie,

    Whdn you say that it will not compile, what is the error that you are
getting?

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Cheers for that, I read this in the help but  it will not compile with a
> signature like that, so i thought pass variant that contains the SAFEARRAY
> (the normal way to do it).....

> BUT the Atl Attribute Provider can not process variant, i guess cos they
are
> unions and this can not be represented in XML...

> So any ides on how to pass variable length data to a ATL implemented web
> service, i do not want to break the data down into fix lengths, because
then
> i have to maintain state on the server side which is just another headache
i
> do not want to get into at the moment...

> Cheers

> Ollie


wrote

> > Ollie,

> >     When you define your interface like this:

> > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte bData[]);

> >     It defines bData as a c-style array.  This is not automation
> compliant.
> > What you want is to define bData as a SAFEARRAY (forgive the caps, but
> that
> > is the way it is declared).  You want your definition to look something
> like
> > this:

> > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]
> > SAFEARRAY(unsigned char) bData);

> >     This should show up as a byte array when you import the interface
> > definition into .NET.

> >     Hope this helps.

> > --
> >                - Nicholas Paldino [.NET MVP]



> > > Well,

> > > I am trying to wirte a web service in VC++ 7.0, using the ATL Wizard,
so
> i
> > > orginally defined my COM interface as:-

> > > __interface IFBFileServerService
> > > {
> > > //Uploads a file onto the web server....
> > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte bData[]);
> > > };

> > > Then import the Web reference into a C# project and use the web
service
> as
> > > one expects....

> > > .....
> > > byte[] bData = Reader.ReadBytes(nLength);

> > > //C++ Web Service.......
> > > m_FileServer.UploadFile("Waremouse.mp3", bData);

> > > The signature for the UploadFile is :- void
> FBFileServer.UploadFile(string
> > > strFileName, System.Byte[] Data)

> > > Any ideas gratefully appreicated

> > > Cheers

> > > Ollie


> > wrote

> > > > Ollie,

> > > >     How does the interface look in .NET when you import it?  The
> varData
> > > > parameter should be an object, and the marshaller should pick up on
> > that,
> > > > marshalling the byte array into the COM object.

> > > >     Can you give more information?

> > > > --
> > > >                - Nicholas Paldino [.NET MVP]



> > > > > Ok, i have COM interface implemented in VC++:-

> > > > > interface IFooBar
> > > > > {
> > > > >     [id(1)] SendFile([in] BSTR bstrFileName, [in] VARIANT*
varData);
> > > > > }

> > > > > I want to call this from C# with byte[] that contains the data
from
> a
> > > > > file.....

> > > > > FileStream fs = new FileStream("c:\\work\\temp\\Waremouse.mp3",
> > > > > FileMode.Open);

> > > > > BinaryReader Reader = new BinaryReader(fs);
> > > > > Reader.BaseStream.Seek(0, SeekOrigin.Begin);

> > > > > long lLength = Reader.BaseStream.Length;
> > > > > Int32 nLength = System.Convert.ToInt32(lLength);

> > > > > byte[] byteArray = Reader.ReadBytes(nLength);

////////////////////////////////////////////////////////////////////////////
Quote:
> > > > > ////
> > > > > // how do i put byte[] into a SAFEARRAY
> > > > > m_FooBar.SendFile("test.mp3", byteArray);

////////////////////////////////////////////////////////////////////////////

- Show quoted text -

Quote:
> > > > > ////


> > > message

> > > > > > How it want receive it? TLB definition ? Is it
> > > > > > in/out/inout?



Sun, 31 Oct 2004 21:39:40 GMT  
 byte[] array
Ok the errors are:-

c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
        Atl Attribute Provider : error ATL2220: Failed processing
"UploadFile"
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
        Atl Attribute Provider : error ATL2200: Invalid struct field
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
        Atl Attribute Provider : error ATL2225: Cannot process: "__unnamed":
unions are not supported.

And they code that generated them is:-

// FBFileServer.h : Defines the ATL Server request handler class
//
#pragma once

namespace FBFileServerService
{
// all struct, enum, and typedefs for your webservice should go inside the
namespace

// IFBFileServerService - web service interface declaration
//
[
 uuid("E2F6C03D-3B76-413C-AFDF-627B4429FB21"),
 object
]
__interface IFBFileServerService
{
 //Uploads a file onto the web server....
 [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in]VARIANT Data);

Quote:
};

// FBFileServerService - web service implementation
//
[
 request_handler(name="Default", sdl="GenFBFileServerWSDL"),
 soap_handler(
  name="FBFileServerService",
  namespace="urn:FBFileServerService",
  protocol="soap"
 )
]
class CFBFileServerService :
 public IFBFileServerService
{
public:

 //Uploads a file onto the web server....
 [soap_method]
 HRESULT UploadFile(/*[in]*/ BSTR bstrFileName, /*[in]*/VARIANT Data)
 {
  return S_OK;
 }

Quote:
}; // class CFBFileServerService
} // namespace FBFileServerService

Cheers

Ollie



Quote:
> Ollie,

>     Whdn you say that it will not compile, what is the error that you are
> getting?

> --
>                - Nicholas Paldino [.NET MVP]



> > Cheers for that, I read this in the help but  it will not compile with a
> > signature like that, so i thought pass variant that contains the
SAFEARRAY
> > (the normal way to do it).....

> > BUT the Atl Attribute Provider can not process variant, i guess cos they
> are
> > unions and this can not be represented in XML...

> > So any ides on how to pass variable length data to a ATL implemented web
> > service, i do not want to break the data down into fix lengths, because
> then
> > i have to maintain state on the server side which is just another
headache
> i
> > do not want to get into at the moment...

> > Cheers

> > Ollie


> wrote

> > > Ollie,

> > >     When you define your interface like this:

> > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte bData[]);

> > >     It defines bData as a c-style array.  This is not automation
> > compliant.
> > > What you want is to define bData as a SAFEARRAY (forgive the caps, but
> > that
> > > is the way it is declared).  You want your definition to look
something
> > like
> > > this:

> > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]
> > > SAFEARRAY(unsigned char) bData);

> > >     This should show up as a byte array when you import the interface
> > > definition into .NET.

> > >     Hope this helps.

> > > --
> > >                - Nicholas Paldino [.NET MVP]



> > > > Well,

> > > > I am trying to wirte a web service in VC++ 7.0, using the ATL
Wizard,
> so
> > i
> > > > orginally defined my COM interface as:-

> > > > __interface IFBFileServerService
> > > > {
> > > > //Uploads a file onto the web server....
> > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte
bData[]);
> > > > };

> > > > Then import the Web reference into a C# project and use the web
> service
> > as
> > > > one expects....

> > > > .....
> > > > byte[] bData = Reader.ReadBytes(nLength);

> > > > //C++ Web Service.......
> > > > m_FileServer.UploadFile("Waremouse.mp3", bData);

> > > > The signature for the UploadFile is :- void
> > FBFileServer.UploadFile(string
> > > > strFileName, System.Byte[] Data)

> > > > Any ideas gratefully appreicated

> > > > Cheers

> > > > Ollie

> > > > "Nicholas Paldino [.NET/C# MVP]"


- Show quoted text -

Quote:
> > > wrote

> > > > > Ollie,

> > > > >     How does the interface look in .NET when you import it?  The
> > varData
> > > > > parameter should be an object, and the marshaller should pick up
on
> > > that,
> > > > > marshalling the byte array into the COM object.

> > > > >     Can you give more information?

> > > > > --
> > > > >                - Nicholas Paldino [.NET MVP]



> > > > > > Ok, i have COM interface implemented in VC++:-

> > > > > > interface IFooBar
> > > > > > {
> > > > > >     [id(1)] SendFile([in] BSTR bstrFileName, [in] VARIANT*
> varData);
> > > > > > }

> > > > > > I want to call this from C# with byte[] that contains the data
> from
> > a
> > > > > > file.....

> > > > > > FileStream fs = new FileStream("c:\\work\\temp\\Waremouse.mp3",
> > > > > > FileMode.Open);

> > > > > > BinaryReader Reader = new BinaryReader(fs);
> > > > > > Reader.BaseStream.Seek(0, SeekOrigin.Begin);

> > > > > > long lLength = Reader.BaseStream.Length;
> > > > > > Int32 nLength = System.Convert.ToInt32(lLength);

> > > > > > byte[] byteArray = Reader.ReadBytes(nLength);

////////////////////////////////////////////////////////////////////////////
Quote:
> > > > > > ////
> > > > > > // how do i put byte[] into a SAFEARRAY
> > > > > > m_FooBar.SendFile("test.mp3", byteArray);

////////////////////////////////////////////////////////////////////////////

- Show quoted text -

Quote:
> > > > > > ////


in
> > > > message

> > > > > > > How it want receive it? TLB definition ? Is it
> > > > > > > in/out/inout?



Sun, 31 Oct 2004 21:50:38 GMT  
 byte[] array
Not very help errors :)


Quote:
> Ok the errors are:-

> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
>         Atl Attribute Provider : error ATL2220: Failed processing
> "UploadFile"
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
>         Atl Attribute Provider : error ATL2200: Invalid struct field
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
>         Atl Attribute Provider : error ATL2225: Cannot process:
"__unnamed":
> unions are not supported.

> And they code that generated them is:-

> // FBFileServer.h : Defines the ATL Server request handler class
> //
> #pragma once

> namespace FBFileServerService
> {
> // all struct, enum, and typedefs for your webservice should go inside the
> namespace

> // IFBFileServerService - web service interface declaration
> //
> [
>  uuid("E2F6C03D-3B76-413C-AFDF-627B4429FB21"),
>  object
> ]
> __interface IFBFileServerService
> {
>  //Uploads a file onto the web server....
>  [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in]VARIANT Data);
> };

> // FBFileServerService - web service implementation
> //
> [
>  request_handler(name="Default", sdl="GenFBFileServerWSDL"),
>  soap_handler(
>   name="FBFileServerService",
>   namespace="urn:FBFileServerService",
>   protocol="soap"
>  )
> ]
> class CFBFileServerService :
>  public IFBFileServerService
> {
> public:

>  //Uploads a file onto the web server....
>  [soap_method]
>  HRESULT UploadFile(/*[in]*/ BSTR bstrFileName, /*[in]*/VARIANT Data)
>  {
>   return S_OK;
>  }

> }; // class CFBFileServerService

> } // namespace FBFileServerService

> Cheers

> Ollie


wrote

> > Ollie,

> >     Whdn you say that it will not compile, what is the error that you
are
> > getting?

> > --
> >                - Nicholas Paldino [.NET MVP]



> > > Cheers for that, I read this in the help but  it will not compile with
a
> > > signature like that, so i thought pass variant that contains the
> SAFEARRAY
> > > (the normal way to do it).....

> > > BUT the Atl Attribute Provider can not process variant, i guess cos
they
> > are
> > > unions and this can not be represented in XML...

> > > So any ides on how to pass variable length data to a ATL implemented
web
> > > service, i do not want to break the data down into fix lengths,
because
> > then
> > > i have to maintain state on the server side which is just another
> headache
> > i
> > > do not want to get into at the moment...

> > > Cheers

> > > Ollie


> > wrote

> > > > Ollie,

> > > >     When you define your interface like this:

> > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte
bData[]);

> > > >     It defines bData as a c-style array.  This is not automation
> > > compliant.
> > > > What you want is to define bData as a SAFEARRAY (forgive the caps,
but
> > > that
> > > > is the way it is declared).  You want your definition to look
> something
> > > like
> > > > this:

> > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]
> > > > SAFEARRAY(unsigned char) bData);

> > > >     This should show up as a byte array when you import the
interface
> > > > definition into .NET.

> > > >     Hope this helps.

> > > > --
> > > >                - Nicholas Paldino [.NET MVP]



> > > > > Well,

> > > > > I am trying to wirte a web service in VC++ 7.0, using the ATL
> Wizard,
> > so
> > > i
> > > > > orginally defined my COM interface as:-

> > > > > __interface IFBFileServerService
> > > > > {
> > > > > //Uploads a file onto the web server....
> > > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte
> bData[]);
> > > > > };

> > > > > Then import the Web reference into a C# project and use the web
> > service
> > > as
> > > > > one expects....

> > > > > .....
> > > > > byte[] bData = Reader.ReadBytes(nLength);

> > > > > //C++ Web Service.......
> > > > > m_FileServer.UploadFile("Waremouse.mp3", bData);

> > > > > The signature for the UploadFile is :- void
> > > FBFileServer.UploadFile(string
> > > > > strFileName, System.Byte[] Data)

> > > > > Any ideas gratefully appreicated

> > > > > Cheers

> > > > > Ollie

> > > > > "Nicholas Paldino [.NET/C# MVP]"

> > > > wrote

> > > > > > Ollie,

> > > > > >     How does the interface look in .NET when you import it?  The
> > > varData
> > > > > > parameter should be an object, and the marshaller should pick up
> on
> > > > that,
> > > > > > marshalling the byte array into the COM object.

> > > > > >     Can you give more information?

> > > > > > --
> > > > > >                - Nicholas Paldino [.NET MVP]



> > > > > > > Ok, i have COM interface implemented in VC++:-

> > > > > > > interface IFooBar
> > > > > > > {
> > > > > > >     [id(1)] SendFile([in] BSTR bstrFileName, [in] VARIANT*
> > varData);
> > > > > > > }

> > > > > > > I want to call this from C# with byte[] that contains the data
> > from
> > > a
> > > > > > > file.....

> > > > > > > FileStream fs = new

FileStream("c:\\work\\temp\\Waremouse.mp3",

- Show quoted text -

Quote:
> > > > > > > FileMode.Open);

> > > > > > > BinaryReader Reader = new BinaryReader(fs);
> > > > > > > Reader.BaseStream.Seek(0, SeekOrigin.Begin);

> > > > > > > long lLength = Reader.BaseStream.Length;
> > > > > > > Int32 nLength = System.Convert.ToInt32(lLength);

> > > > > > > byte[] byteArray = Reader.ReadBytes(nLength);

////////////////////////////////////////////////////////////////////////////
Quote:
> > > > > > > ////
> > > > > > > // how do i put byte[] into a SAFEARRAY
> > > > > > > m_FooBar.SendFile("test.mp3", byteArray);

////////////////////////////////////////////////////////////////////////////

- Show quoted text -

Quote:
> > > > > > > ////


> in
> > > > > message

> > > > > > > > How it want receive it? TLB definition ? Is it
> > > > > > > > in/out/inout?



Sun, 31 Oct 2004 21:54:12 GMT  
 byte[] array
Ollie,

    What is the error you are getting with the SAFEARRAY signature.  This is
the way to go ultimately, IMO.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Ok the errors are:-

> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
>         Atl Attribute Provider : error ATL2220: Failed processing
> "UploadFile"
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
>         Atl Attribute Provider : error ATL2200: Invalid struct field
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
>         Atl Attribute Provider : error ATL2225: Cannot process:
"__unnamed":
> unions are not supported.

> And they code that generated them is:-

> // FBFileServer.h : Defines the ATL Server request handler class
> //
> #pragma once

> namespace FBFileServerService
> {
> // all struct, enum, and typedefs for your webservice should go inside the
> namespace

> // IFBFileServerService - web service interface declaration
> //
> [
>  uuid("E2F6C03D-3B76-413C-AFDF-627B4429FB21"),
>  object
> ]
> __interface IFBFileServerService
> {
>  //Uploads a file onto the web server....
>  [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in]VARIANT Data);
> };

> // FBFileServerService - web service implementation
> //
> [
>  request_handler(name="Default", sdl="GenFBFileServerWSDL"),
>  soap_handler(
>   name="FBFileServerService",
>   namespace="urn:FBFileServerService",
>   protocol="soap"
>  )
> ]
> class CFBFileServerService :
>  public IFBFileServerService
> {
> public:

>  //Uploads a file onto the web server....
>  [soap_method]
>  HRESULT UploadFile(/*[in]*/ BSTR bstrFileName, /*[in]*/VARIANT Data)
>  {
>   return S_OK;
>  }

> }; // class CFBFileServerService

> } // namespace FBFileServerService

> Cheers

> Ollie


wrote

> > Ollie,

> >     Whdn you say that it will not compile, what is the error that you
are
> > getting?

> > --
> >                - Nicholas Paldino [.NET MVP]



> > > Cheers for that, I read this in the help but  it will not compile with
a
> > > signature like that, so i thought pass variant that contains the
> SAFEARRAY
> > > (the normal way to do it).....

> > > BUT the Atl Attribute Provider can not process variant, i guess cos
they
> > are
> > > unions and this can not be represented in XML...

> > > So any ides on how to pass variable length data to a ATL implemented
web
> > > service, i do not want to break the data down into fix lengths,
because
> > then
> > > i have to maintain state on the server side which is just another
> headache
> > i
> > > do not want to get into at the moment...

> > > Cheers

> > > Ollie


> > wrote

> > > > Ollie,

> > > >     When you define your interface like this:

> > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte
bData[]);

> > > >     It defines bData as a c-style array.  This is not automation
> > > compliant.
> > > > What you want is to define bData as a SAFEARRAY (forgive the caps,
but
> > > that
> > > > is the way it is declared).  You want your definition to look
> something
> > > like
> > > > this:

> > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]
> > > > SAFEARRAY(unsigned char) bData);

> > > >     This should show up as a byte array when you import the
interface
> > > > definition into .NET.

> > > >     Hope this helps.

> > > > --
> > > >                - Nicholas Paldino [.NET MVP]



> > > > > Well,

> > > > > I am trying to wirte a web service in VC++ 7.0, using the ATL
> Wizard,
> > so
> > > i
> > > > > orginally defined my COM interface as:-

> > > > > __interface IFBFileServerService
> > > > > {
> > > > > //Uploads a file onto the web server....
> > > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte
> bData[]);
> > > > > };

> > > > > Then import the Web reference into a C# project and use the web
> > service
> > > as
> > > > > one expects....

> > > > > .....
> > > > > byte[] bData = Reader.ReadBytes(nLength);

> > > > > //C++ Web Service.......
> > > > > m_FileServer.UploadFile("Waremouse.mp3", bData);

> > > > > The signature for the UploadFile is :- void
> > > FBFileServer.UploadFile(string
> > > > > strFileName, System.Byte[] Data)

> > > > > Any ideas gratefully appreicated

> > > > > Cheers

> > > > > Ollie

> > > > > "Nicholas Paldino [.NET/C# MVP]"

> > > > wrote

> > > > > > Ollie,

> > > > > >     How does the interface look in .NET when you import it?  The
> > > varData
> > > > > > parameter should be an object, and the marshaller should pick up
> on
> > > > that,
> > > > > > marshalling the byte array into the COM object.

> > > > > >     Can you give more information?

> > > > > > --
> > > > > >                - Nicholas Paldino [.NET MVP]



> > > > > > > Ok, i have COM interface implemented in VC++:-

> > > > > > > interface IFooBar
> > > > > > > {
> > > > > > >     [id(1)] SendFile([in] BSTR bstrFileName, [in] VARIANT*
> > varData);
> > > > > > > }

> > > > > > > I want to call this from C# with byte[] that contains the data
> > from
> > > a
> > > > > > > file.....

> > > > > > > FileStream fs = new

FileStream("c:\\work\\temp\\Waremouse.mp3",

- Show quoted text -

Quote:
> > > > > > > FileMode.Open);

> > > > > > > BinaryReader Reader = new BinaryReader(fs);
> > > > > > > Reader.BaseStream.Seek(0, SeekOrigin.Begin);

> > > > > > > long lLength = Reader.BaseStream.Length;
> > > > > > > Int32 nLength = System.Convert.ToInt32(lLength);

> > > > > > > byte[] byteArray = Reader.ReadBytes(nLength);

////////////////////////////////////////////////////////////////////////////
Quote:
> > > > > > > ////
> > > > > > > // how do i put byte[] into a SAFEARRAY
> > > > > > > m_FooBar.SendFile("test.mp3", byteArray);

////////////////////////////////////////////////////////////////////////////

- Show quoted text -

Quote:
> > > > > > > ////


> in
> > > > > message

> > > > > > > > How it want receive it? TLB definition ? Is it
> > > > > > > > in/out/inout?



Sun, 31 Oct 2004 21:57:13 GMT  
 byte[] array
Ok with the following signature:-

[id(1)] HRESULT UploadFile([in] BSTR bstrFileName,
[in,out]SAFEARRAY(unsigned char) bData);

errors are:-

c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error :
missing ')' before identifier 'Data'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error :
missing ';' before identifier 'Data'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(18): error C2059: syntax error : ')'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(18): error C2501:
'FBFileServerService::IFBFileServerService::Data' : missing storage-class or
type specifiers
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error :
missing ')' before identifier 'Data'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error :
missing ';' before identifier 'Data'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(39): error C2338: soap_method
        Atl Attribute Provider : error ATL2248: Cannot process: "UploadFile"
: SOAP methods cannot have unnamed parameters.
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(39): error C2059: syntax error : ')'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(40): error C2501:
'FBFileServerService::CFBFileServerService::Data' : missing storage-class or
type specifiers
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(41): error C2059: syntax error :
'return'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(41): error C2238: unexpected token(s)
preceding ';'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(42): error C2338: soap_handler
        Atl Attribute Provider : error ATL2203: soap_handler class must
expose at least one method using soap_method
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(46): error C2143: syntax error :
missing ';' before '}'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error : '}'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(48): error C2143: syntax error :
missing ';' before '}'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error : '}'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.cpp(13): error C2143: syntax error :
missing ';' before '{'
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.cpp(13): error C2447: '{' : missing
function header (old-style formal list?)

So i tried using the signature:-

[id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]SAFEARRAY bData);

errors are :-

c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
        Atl Attribute Provider : error ATL2200: Invalid struct field
c:\Documents and Settings\ollie\My Documents\Visual Studio
Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
        Atl Attribute Provider : error ATL2220: Failed processing
"UploadFile"

Cheers

Ollie



Quote:
> Ollie,

>     What is the error you are getting with the SAFEARRAY signature.  This
is
> the way to go ultimately, IMO.

> --
>                - Nicholas Paldino [.NET MVP]



> > Ok the errors are:-

> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> >         Atl Attribute Provider : error ATL2220: Failed processing
> > "UploadFile"
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> >         Atl Attribute Provider : error ATL2200: Invalid struct field
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> >         Atl Attribute Provider : error ATL2225: Cannot process:
> "__unnamed":
> > unions are not supported.

> > And they code that generated them is:-

> > // FBFileServer.h : Defines the ATL Server request handler class
> > //
> > #pragma once

> > namespace FBFileServerService
> > {
> > // all struct, enum, and typedefs for your webservice should go inside
the
> > namespace

> > // IFBFileServerService - web service interface declaration
> > //
> > [
> >  uuid("E2F6C03D-3B76-413C-AFDF-627B4429FB21"),
> >  object
> > ]
> > __interface IFBFileServerService
> > {
> >  //Uploads a file onto the web server....
> >  [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in]VARIANT Data);
> > };

> > // FBFileServerService - web service implementation
> > //
> > [
> >  request_handler(name="Default", sdl="GenFBFileServerWSDL"),
> >  soap_handler(
> >   name="FBFileServerService",
> >   namespace="urn:FBFileServerService",
> >   protocol="soap"
> >  )
> > ]
> > class CFBFileServerService :
> >  public IFBFileServerService
> > {
> > public:

> >  //Uploads a file onto the web server....
> >  [soap_method]
> >  HRESULT UploadFile(/*[in]*/ BSTR bstrFileName, /*[in]*/VARIANT Data)
> >  {
> >   return S_OK;
> >  }

> > }; // class CFBFileServerService

> > } // namespace FBFileServerService

> > Cheers

> > Ollie


> wrote

> > > Ollie,

> > >     Whdn you say that it will not compile, what is the error that you
> are
> > > getting?

> > > --
> > >                - Nicholas Paldino [.NET MVP]



> > > > Cheers for that, I read this in the help but  it will not compile
with
> a
> > > > signature like that, so i thought pass variant that contains the
> > SAFEARRAY
> > > > (the normal way to do it).....

> > > > BUT the Atl Attribute Provider can not process variant, i guess cos
> they
> > > are
> > > > unions and this can not be represented in XML...

> > > > So any ides on how to pass variable length data to a ATL implemented
> web
> > > > service, i do not want to break the data down into fix lengths,
> because
> > > then
> > > > i have to maintain state on the server side which is just another
> > headache
> > > i
> > > > do not want to get into at the moment...

> > > > Cheers

> > > > Ollie

> > > > "Nicholas Paldino [.NET/C# MVP]"


- Show quoted text -

Quote:
> > > wrote

> > > > > Ollie,

> > > > >     When you define your interface like this:

> > > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte
> bData[]);

> > > > >     It defines bData as a c-style array.  This is not automation
> > > > compliant.
> > > > > What you want is to define bData as a SAFEARRAY (forgive the caps,
> but
> > > > that
> > > > > is the way it is declared).  You want your definition to look
> > something
> > > > like
> > > > > this:

> > > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]
> > > > > SAFEARRAY(unsigned char) bData);

> > > > >     This should show up as a byte array when you import the
> interface
> > > > > definition into .NET.

> > > > >     Hope this helps.

> > > > > --
> > > > >                - Nicholas Paldino [.NET MVP]



> > > > > > Well,

> > > > > > I am trying to wirte a web service in VC++ 7.0, using the ATL
> > Wizard,
> > > so
> > > > i
> > > > > > orginally defined my COM interface as:-

> > > > > > __interface IFBFileServerService
> > > > > > {
> > > > > > //Uploads a file onto the web server....
> > > > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte
> > bData[]);
> > > > > > };

> > > > > > Then import the Web reference into a C# project and use the web
> > > service
> > > > as
> > > > > > one expects....

> > > > > > .....
> > > > > > byte[] bData = Reader.ReadBytes(nLength);

> > > > > > //C++ Web Service.......
> > > > > > m_FileServer.UploadFile("Waremouse.mp3", bData);

> > > > > > The signature for the UploadFile is :- void
> > > > FBFileServer.UploadFile(string
> > > > > > strFileName, System.Byte[] Data)

> > > > > > Any ideas gratefully appreicated

> > > > > > Cheers

> > > > > > Ollie

> > > > > > "Nicholas Paldino [.NET/C# MVP]"

> > > > > wrote

> > > > > > > Ollie,

> > > > > > >     How does the interface look in .NET when you import it?
The

...

read more »



Sun, 31 Oct 2004 22:13:46 GMT  
 byte[] array
The reason is:-

VARIANT is not a type supported by the XSD specification (which the ATL
Server Web Services implementation is following), therefore, it should be
marshalled as a structure (according to the definition of the VARIANT type).
Now, ATL Server Web Services do not currently support unions.

You could work around this issue by using a structure like
stWrapper
{
    /*someEnumeratedType*/ discriminant;
    BSTR                                bstrVariantAsText;

Quote:
}

You have to write the code to convert between VARIANT and BSTR, but this
should not affect the performance very much, as the content of the VARIANT
would be serialized to string (XML) anyway.


Quote:
> Ok with the following signature:-

> [id(1)] HRESULT UploadFile([in] BSTR bstrFileName,
> [in,out]SAFEARRAY(unsigned char) bData);

> errors are:-

> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error :
> missing ')' before identifier 'Data'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error :
> missing ';' before identifier 'Data'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(18): error C2059: syntax error : ')'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(18): error C2501:
> 'FBFileServerService::IFBFileServerService::Data' : missing storage-class
or
> type specifiers
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error :
> missing ')' before identifier 'Data'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error :
> missing ';' before identifier 'Data'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(39): error C2338: soap_method
>         Atl Attribute Provider : error ATL2248: Cannot process:
"UploadFile"
> : SOAP methods cannot have unnamed parameters.
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(39): error C2059: syntax error : ')'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(40): error C2501:
> 'FBFileServerService::CFBFileServerService::Data' : missing storage-class
or
> type specifiers
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(41): error C2059: syntax error :
> 'return'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(41): error C2238: unexpected token(s)
> preceding ';'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(42): error C2338: soap_handler
>         Atl Attribute Provider : error ATL2203: soap_handler class must
> expose at least one method using soap_method
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(46): error C2143: syntax error :
> missing ';' before '}'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error : '}'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(48): error C2143: syntax error :
> missing ';' before '}'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error : '}'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.cpp(13): error C2143: syntax error :
> missing ';' before '{'
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.cpp(13): error C2447: '{' : missing
> function header (old-style formal list?)

> So i tried using the signature:-

> [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]SAFEARRAY
bData);

> errors are :-

> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
>         Atl Attribute Provider : error ATL2200: Invalid struct field
> c:\Documents and Settings\ollie\My Documents\Visual Studio
> Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
>         Atl Attribute Provider : error ATL2220: Failed processing
> "UploadFile"

> Cheers

> Ollie


wrote

> > Ollie,

> >     What is the error you are getting with the SAFEARRAY signature.
This
> is
> > the way to go ultimately, IMO.

> > --
> >                - Nicholas Paldino [.NET MVP]



> > > Ok the errors are:-

> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > >         Atl Attribute Provider : error ATL2220: Failed processing
> > > "UploadFile"
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > >         Atl Attribute Provider : error ATL2200: Invalid struct field
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > >         Atl Attribute Provider : error ATL2225: Cannot process:
> > "__unnamed":
> > > unions are not supported.

> > > And they code that generated them is:-

> > > // FBFileServer.h : Defines the ATL Server request handler class
> > > //
> > > #pragma once

> > > namespace FBFileServerService
> > > {
> > > // all struct, enum, and typedefs for your webservice should go inside
> the
> > > namespace

> > > // IFBFileServerService - web service interface declaration
> > > //
> > > [
> > >  uuid("E2F6C03D-3B76-413C-AFDF-627B4429FB21"),
> > >  object
> > > ]
> > > __interface IFBFileServerService
> > > {
> > >  //Uploads a file onto the web server....
> > >  [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in]VARIANT Data);
> > > };

> > > // FBFileServerService - web service implementation
> > > //
> > > [
> > >  request_handler(name="Default", sdl="GenFBFileServerWSDL"),
> > >  soap_handler(
> > >   name="FBFileServerService",
> > >   namespace="urn:FBFileServerService",
> > >   protocol="soap"
> > >  )
> > > ]
> > > class CFBFileServerService :
> > >  public IFBFileServerService
> > > {
> > > public:

> > >  //Uploads a file onto the web server....
> > >  [soap_method]
> > >  HRESULT UploadFile(/*[in]*/ BSTR bstrFileName, /*[in]*/VARIANT Data)
> > >  {
> > >   return S_OK;
> > >  }

> > > }; // class CFBFileServerService

> > > } // namespace FBFileServerService

> > > Cheers

> > > Ollie


> > wrote

> > > > Ollie,

> > > >     Whdn you say that it will not compile, what is the error that
you
> > are
> > > > getting?

> > > > --
> > > >                - Nicholas Paldino [.NET MVP]



> > > > > Cheers for that, I read this in the help but  it will not compile
> with
> > a
> > > > > signature like that, so i thought pass variant that contains the
> > > SAFEARRAY
> > > > > (the normal way to do it).....

> > > > > BUT the Atl Attribute Provider can not process variant, i guess
cos
> > they
> > > > are
> > > > > unions and this can not be represented in XML...

> > > > > So any ides on how to pass variable length data to a ATL
implemented
> > web
> > > > > service, i do not want to break the data down into fix lengths,
> > because
> > > > then
> > > > > i have to maintain state on the server side which is just another
> > > headache
> > > > i
> > > > > do not want to get into at the moment...

> > > > > Cheers

> > > > > Ollie

> > > > > "Nicholas Paldino [.NET/C# MVP]"

> > > > wrote

> > > > > > Ollie,

> > > > > >     When you define your interface like this:

> > > > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte
> > bData[]);

> > > > > >     It defines bData as a c-style array.  This is not automation
> > > > > compliant.
> > > > > > What you want is to define bData as a SAFEARRAY (forgive the
caps,
> > but
> > > > > that
> > > > > > is the way it is declared).  You want your definition to look
> > > something
> > > > > like
> > > > > > this:

> > > > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]
> > > > > > SAFEARRAY(unsigned char) bData);

> > > > > >     This should show up as a byte array when you import the
> > interface
> > > > > > definition into .NET.

> > > > > >     Hope this helps.

> > > > > > --
> > > > > >                - Nicholas Paldino [.NET MVP]



> > > > > > > Well,

> > > > > > > I am trying to wirte a web service in VC++ 7.0,

...

read more »



Mon, 01 Nov 2004 02:44:25 GMT  
 byte[] array
Ollie,

    Sorry, I made a mistake.  Your declaration for the IDL should be as
follows:

[id(1)] HRESULT UploadFile([in] BSTR bstrFileName,
    [in,out] SAFEARRAY(unsigned char) *bData);

    If this isn't working, then I think there is something else wrong, as it
is a valid IDL construct.  Once you have that, then interop should have no
problem marshalling a byte array.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> The reason is:-

> VARIANT is not a type supported by the XSD specification (which the ATL
> Server Web Services implementation is following), therefore, it should be
> marshalled as a structure (according to the definition of the VARIANT
type).
> Now, ATL Server Web Services do not currently support unions.

> You could work around this issue by using a structure like
> stWrapper
> {
>     /*someEnumeratedType*/ discriminant;
>     BSTR                                bstrVariantAsText;
> }

> You have to write the code to convert between VARIANT and BSTR, but this
> should not affect the performance very much, as the content of the VARIANT
> would be serialized to string (XML) anyway.



> > Ok with the following signature:-

> > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName,
> > [in,out]SAFEARRAY(unsigned char) bData);

> > errors are:-

> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error :
> > missing ')' before identifier 'Data'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error :
> > missing ';' before identifier 'Data'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(18): error C2059: syntax error :
')'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(18): error C2501:
> > 'FBFileServerService::IFBFileServerService::Data' : missing
storage-class
> or
> > type specifiers
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error :
> > missing ')' before identifier 'Data'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error :
> > missing ';' before identifier 'Data'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(39): error C2338: soap_method
> >         Atl Attribute Provider : error ATL2248: Cannot process:
> "UploadFile"
> > : SOAP methods cannot have unnamed parameters.
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(39): error C2059: syntax error :
')'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(40): error C2501:
> > 'FBFileServerService::CFBFileServerService::Data' : missing
storage-class
> or
> > type specifiers
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(41): error C2059: syntax error :
> > 'return'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(41): error C2238: unexpected
token(s)
> > preceding ';'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(42): error C2338: soap_handler
> >         Atl Attribute Provider : error ATL2203: soap_handler class must
> > expose at least one method using soap_method
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(46): error C2143: syntax error :
> > missing ';' before '}'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error :
'}'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(48): error C2143: syntax error :
> > missing ';' before '}'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error :
'}'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.cpp(13): error C2143: syntax error :
> > missing ';' before '{'
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.cpp(13): error C2447: '{' : missing
> > function header (old-style formal list?)

> > So i tried using the signature:-

> > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]SAFEARRAY
> bData);

> > errors are :-

> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> >         Atl Attribute Provider : error ATL2200: Invalid struct field
> > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> >         Atl Attribute Provider : error ATL2220: Failed processing
> > "UploadFile"

> > Cheers

> > Ollie


> wrote

> > > Ollie,

> > >     What is the error you are getting with the SAFEARRAY signature.
> This
> > is
> > > the way to go ultimately, IMO.

> > > --
> > >                - Nicholas Paldino [.NET MVP]



> > > > Ok the errors are:-

> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > > >         Atl Attribute Provider : error ATL2220: Failed processing
> > > > "UploadFile"
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > > >         Atl Attribute Provider : error ATL2200: Invalid struct field
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > > >         Atl Attribute Provider : error ATL2225: Cannot process:
> > > "__unnamed":
> > > > unions are not supported.

> > > > And they code that generated them is:-

> > > > // FBFileServer.h : Defines the ATL Server request handler class
> > > > //
> > > > #pragma once

> > > > namespace FBFileServerService
> > > > {
> > > > // all struct, enum, and typedefs for your webservice should go
inside
> > the
> > > > namespace

> > > > // IFBFileServerService - web service interface declaration
> > > > //
> > > > [
> > > >  uuid("E2F6C03D-3B76-413C-AFDF-627B4429FB21"),
> > > >  object
> > > > ]
> > > > __interface IFBFileServerService
> > > > {
> > > >  //Uploads a file onto the web server....
> > > >  [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in]VARIANT
Data);
> > > > };

> > > > // FBFileServerService - web service implementation
> > > > //
> > > > [
> > > >  request_handler(name="Default", sdl="GenFBFileServerWSDL"),
> > > >  soap_handler(
> > > >   name="FBFileServerService",
> > > >   namespace="urn:FBFileServerService",
> > > >   protocol="soap"
> > > >  )
> > > > ]
> > > > class CFBFileServerService :
> > > >  public IFBFileServerService
> > > > {
> > > > public:

> > > >  //Uploads a file onto the web server....
> > > >  [soap_method]
> > > >  HRESULT UploadFile(/*[in]*/ BSTR bstrFileName, /*[in]*/VARIANT
Data)
> > > >  {
> > > >   return S_OK;
> > > >  }

> > > > }; // class CFBFileServerService

> > > > } // namespace FBFileServerService

> > > > Cheers

> > > > Ollie

> > > > "Nicholas Paldino [.NET/C# MVP]"


- Show quoted text -

Quote:
> > > wrote

> > > > > Ollie,

> > > > >     Whdn you say that it will not compile, what is the error that
> you
> > > are
> > > > > getting?

> > > > > --
> > > > >                - Nicholas Paldino [.NET MVP]



> > > > > > Cheers for that, I read this in the help but  it will not
compile
> > with
> > > a
> > > > > > signature like that, so i thought pass variant that contains the
> > > > SAFEARRAY
> > > > > > (the normal way to do it).....

> > > > > > BUT the Atl Attribute Provider can not process variant, i guess
> cos
> > > they
> > > > > are
> > > > > > unions and this can not be represented in XML...

> > > > > > So any ides on how to pass variable length data to a ATL
> implemented
> > > web
> > > > > > service, i do not want to break the data down into fix lengths,
> > > because
> > > > > then
> > > > > > i have to maintain state on the server side which is just
another
> > > > headache
> > > > > i
> > > > > > do not want to get into at the moment...

> > > > > > Cheers

> > > > > > Ollie

> > > > > > "Nicholas Paldino [.NET/C# MVP]"

> > > > > wrote

> > > > > > > Ollie,

> > > > > > >     When you define your interface like this:

> > > > > > > [id(1)] HRESULT UploadFile([in] BSTR

...

read more »



Mon, 01 Nov 2004 02:53:09 GMT  
 byte[] array
Maybe the ATLSOAP_BLOB structure will help in this scenario. It is intended
for passing a byte array through a Web Service. It will take care of
encoding the byte array as base64. ATL Server supports that (just add an
ATLSOAP_BLOB parameter to your SOAP method) and C# supports it as well,
treating it as a byte[]

--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. It is for newsgroup
purposes only.

Thanks,
Bogdan



Quote:
> Ollie,

>     Sorry, I made a mistake.  Your declaration for the IDL should be as
> follows:

> [id(1)] HRESULT UploadFile([in] BSTR bstrFileName,
>     [in,out] SAFEARRAY(unsigned char) *bData);

>     If this isn't working, then I think there is something else wrong, as
it
> is a valid IDL construct.  Once you have that, then interop should have no
> problem marshalling a byte array.

> --
>                - Nicholas Paldino [.NET MVP]



> > The reason is:-

> > VARIANT is not a type supported by the XSD specification (which the ATL
> > Server Web Services implementation is following), therefore, it should
be
> > marshalled as a structure (according to the definition of the VARIANT
> type).
> > Now, ATL Server Web Services do not currently support unions.

> > You could work around this issue by using a structure like
> > stWrapper
> > {
> >     /*someEnumeratedType*/ discriminant;
> >     BSTR                                bstrVariantAsText;
> > }

> > You have to write the code to convert between VARIANT and BSTR, but this
> > should not affect the performance very much, as the content of the
VARIANT
> > would be serialized to string (XML) anyway.



> > > Ok with the following signature:-

> > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName,
> > > [in,out]SAFEARRAY(unsigned char) bData);

> > > errors are:-

> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error :
> > > missing ')' before identifier 'Data'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error :
> > > missing ';' before identifier 'Data'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(18): error C2059: syntax error :
> ')'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(18): error C2501:
> > > 'FBFileServerService::IFBFileServerService::Data' : missing
> storage-class
> > or
> > > type specifiers
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error :
> > > missing ')' before identifier 'Data'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error :
> > > missing ';' before identifier 'Data'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(39): error C2338: soap_method
> > >         Atl Attribute Provider : error ATL2248: Cannot process:
> > "UploadFile"
> > > : SOAP methods cannot have unnamed parameters.
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(39): error C2059: syntax error :
> ')'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(40): error C2501:
> > > 'FBFileServerService::CFBFileServerService::Data' : missing
> storage-class
> > or
> > > type specifiers
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(41): error C2059: syntax error :
> > > 'return'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(41): error C2238: unexpected
> token(s)
> > > preceding ';'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(42): error C2338: soap_handler
> > >         Atl Attribute Provider : error ATL2203: soap_handler class
must
> > > expose at least one method using soap_method
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(46): error C2143: syntax error :
> > > missing ';' before '}'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error :
> '}'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(48): error C2143: syntax error :
> > > missing ';' before '}'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error :
> '}'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.cpp(13): error C2143: syntax error
:
> > > missing ';' before '{'
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.cpp(13): error C2447: '{' : missing
> > > function header (old-style formal list?)

> > > So i tried using the signature:-

> > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]SAFEARRAY
> > bData);

> > > errors are :-

> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > >         Atl Attribute Provider : error ATL2200: Invalid struct field
> > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > >         Atl Attribute Provider : error ATL2220: Failed processing
> > > "UploadFile"

> > > Cheers

> > > Ollie


> > wrote

> > > > Ollie,

> > > >     What is the error you are getting with the SAFEARRAY signature.
> > This
> > > is
> > > > the way to go ultimately, IMO.

> > > > --
> > > >                - Nicholas Paldino [.NET MVP]



> > > > > Ok the errors are:-

> > > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > > > >         Atl Attribute Provider : error ATL2220: Failed processing
> > > > > "UploadFile"
> > > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > > > >         Atl Attribute Provider : error ATL2200: Invalid struct
field
> > > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > > > >         Atl Attribute Provider : error ATL2225: Cannot process:
> > > > "__unnamed":
> > > > > unions are not supported.

> > > > > And they code that generated them is:-

> > > > > // FBFileServer.h : Defines the ATL Server request handler class
> > > > > //
> > > > > #pragma once

> > > > > namespace FBFileServerService
> > > > > {
> > > > > // all struct, enum, and typedefs for your webservice should go
> inside
> > > the
> > > > > namespace

> > > > > // IFBFileServerService - web service interface declaration
> > > > > //
> > > > > [
> > > > >  uuid("E2F6C03D-3B76-413C-AFDF-627B4429FB21"),
> > > > >  object
> > > > > ]
> > > > > __interface IFBFileServerService
> > > > > {
> > > > >  //Uploads a file onto the web server....
> > > > >  [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in]VARIANT
> Data);
> > > > > };

> > > > > // FBFileServerService - web service implementation
> > > > > //
> > > > > [
> > > > >  request_handler(name="Default", sdl="GenFBFileServerWSDL"),
> > > > >  soap_handler(
> > > > >   name="FBFileServerService",
> > > > >   namespace="urn:FBFileServerService",
> > > > >   protocol="soap"
> > > > >  )
> > > > > ]
> > > > > class CFBFileServerService :
> > > > >  public IFBFileServerService
> > > > > {
> > > > > public:

> > > > >  //Uploads a file onto the web server....
> > > > >  [soap_method]
> > > > >  HRESULT UploadFile(/*[in]*/ BSTR bstrFileName, /*[in]*/VARIANT
> Data)
> > > > >  {
> > > > >   return S_OK;
> > > > >  }

> > > > > }; // class CFBFileServerService

> > > > > } // namespace FBFileServerService

> > > > > Cheers

> > > > > Ollie

> > > > > "Nicholas Paldino [.NET/C# MVP]"

> > > > wrote

> > > > > > Ollie,

> > > > > >     Whdn you say that it will not compile, what is the error
that
> > you
> > > > are
> > > > > > getting?

> > > > > > --
> > > > > >                - Nicholas Paldino [.NET MVP]



> > > > > > > Cheers for that, I read this in the help but  it will

...

read more »



Mon, 01 Nov 2004 03:48:21 GMT  
 byte[] array
Cheers Bogan, this is exactly what I wanted, Thanks Nicholas for the help.

Cheers

Ollie


Quote:
> Maybe the ATLSOAP_BLOB structure will help in this scenario. It is
intended
> for passing a byte array through a Web Service. It will take care of
> encoding the byte array as base64. ATL Server supports that (just add an
> ATLSOAP_BLOB parameter to your SOAP method) and C# supports it as well,
> treating it as a byte[]

> --
> --
> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Please do not send email directly to this alias. It is for newsgroup
> purposes only.

> Thanks,
> Bogdan


wrote

> > Ollie,

> >     Sorry, I made a mistake.  Your declaration for the IDL should be as
> > follows:

> > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName,
> >     [in,out] SAFEARRAY(unsigned char) *bData);

> >     If this isn't working, then I think there is something else wrong,
as
> it
> > is a valid IDL construct.  Once you have that, then interop should have
no
> > problem marshalling a byte array.

> > --
> >                - Nicholas Paldino [.NET MVP]



> > > The reason is:-

> > > VARIANT is not a type supported by the XSD specification (which the
ATL
> > > Server Web Services implementation is following), therefore, it should
> be
> > > marshalled as a structure (according to the definition of the VARIANT
> > type).
> > > Now, ATL Server Web Services do not currently support unions.

> > > You could work around this issue by using a structure like
> > > stWrapper
> > > {
> > >     /*someEnumeratedType*/ discriminant;
> > >     BSTR                                bstrVariantAsText;
> > > }

> > > You have to write the code to convert between VARIANT and BSTR, but
this
> > > should not affect the performance very much, as the content of the
> VARIANT
> > > would be serialized to string (XML) anyway.



> > > > Ok with the following signature:-

> > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName,
> > > > [in,out]SAFEARRAY(unsigned char) bData);

> > > > errors are:-

> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error
:
> > > > missing ')' before identifier 'Data'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(18): error C2146: syntax error
:
> > > > missing ';' before identifier 'Data'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(18): error C2059: syntax error
:
> > ')'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(18): error C2501:
> > > > 'FBFileServerService::IFBFileServerService::Data' : missing
> > storage-class
> > > or
> > > > type specifiers
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error
:
> > > > missing ')' before identifier 'Data'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(39): error C2146: syntax error
:
> > > > missing ';' before identifier 'Data'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(39): error C2338: soap_method
> > > >         Atl Attribute Provider : error ATL2248: Cannot process:
> > > "UploadFile"
> > > > : SOAP methods cannot have unnamed parameters.
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(39): error C2059: syntax error
:
> > ')'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(40): error C2501:
> > > > 'FBFileServerService::CFBFileServerService::Data' : missing
> > storage-class
> > > or
> > > > type specifiers
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(41): error C2059: syntax error
:
> > > > 'return'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(41): error C2238: unexpected
> > token(s)
> > > > preceding ';'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(42): error C2338: soap_handler
> > > >         Atl Attribute Provider : error ATL2203: soap_handler class
> must
> > > > expose at least one method using soap_method
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(46): error C2143: syntax error
:
> > > > missing ';' before '}'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error
:
> > '}'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(48): error C2143: syntax error
:
> > > > missing ';' before '}'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(48): error C2059: syntax error
:
> > '}'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.cpp(13): error C2143: syntax
error
> :
> > > > missing ';' before '{'
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.cpp(13): error C2447: '{' :
missing
> > > > function header (old-style formal list?)

> > > > So i tried using the signature:-

> > > > [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in,out]SAFEARRAY
> > > bData);

> > > > errors are :-

> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > > >         Atl Attribute Provider : error ATL2200: Invalid struct field
> > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > Projects\FBFileServer\FBFileServer.h(46): error C2338: soap_method
> > > >         Atl Attribute Provider : error ATL2220: Failed processing
> > > > "UploadFile"

> > > > Cheers

> > > > Ollie

> > > > "Nicholas Paldino [.NET/C# MVP]"


- Show quoted text -

Quote:
> > > wrote

> > > > > Ollie,

> > > > >     What is the error you are getting with the SAFEARRAY
signature.
> > > This
> > > > is
> > > > > the way to go ultimately, IMO.

> > > > > --
> > > > >                - Nicholas Paldino [.NET MVP]



> > > > > > Ok the errors are:-

> > > > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > > > Projects\FBFileServer\FBFileServer.h(46): error C2338:
soap_method
> > > > > >         Atl Attribute Provider : error ATL2220: Failed
processing
> > > > > > "UploadFile"
> > > > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > > > Projects\FBFileServer\FBFileServer.h(46): error C2338:
soap_method
> > > > > >         Atl Attribute Provider : error ATL2200: Invalid struct
> field
> > > > > > c:\Documents and Settings\ollie\My Documents\Visual Studio
> > > > > > Projects\FBFileServer\FBFileServer.h(46): error C2338:
soap_method
> > > > > >         Atl Attribute Provider : error ATL2225: Cannot process:
> > > > > "__unnamed":
> > > > > > unions are not supported.

> > > > > > And they code that generated them is:-

> > > > > > // FBFileServer.h : Defines the ATL Server request handler class
> > > > > > //
> > > > > > #pragma once

> > > > > > namespace FBFileServerService
> > > > > > {
> > > > > > // all struct, enum, and typedefs for your webservice should go
> > inside
> > > > the
> > > > > > namespace

> > > > > > // IFBFileServerService - web service interface declaration
> > > > > > //
> > > > > > [
> > > > > >  uuid("E2F6C03D-3B76-413C-AFDF-627B4429FB21"),
> > > > > >  object
> > > > > > ]
> > > > > > __interface IFBFileServerService
> > > > > > {
> > > > > >  //Uploads a file onto the web server....
> > > > > >  [id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in]VARIANT
> > Data);
> > > > > > };

> > > > > > // FBFileServerService - web service implementation
> > > > > > //
> > > > > > [
> > > > > >  request_handler(name="Default", sdl="GenFBFileServerWSDL"),
> > > > > >  soap_handler(
> > > > > >   name="FBFileServerService",
> > > > > >   namespace="urn:FBFileServerService",
> > > > > >   protocol="soap"
> > > > > >  )
> > > > > > ]
> > > > > > class CFBFileServerService :
> > > > > >  public IFBFileServerService
> > > > > > {
> > > > > > public:

> > > > > >  //Uploads a file onto the web server....
> > > > > >  [soap_method]
> > > > > >  HRESULT UploadFile(/*[in]*/ BSTR bstrFileName, /*[in]*/VARIANT
> > Data)
> > > > > >  {
> > > > > >   return S_OK;
> > > > > >  }

> > > > > > }; // class CFBFileServerService

> > > > > > } // namespace FBFileServerService

> > > > > > Cheers

> > > > > > Ollie

...

read more »



Mon, 01 Nov 2004 16:56:28 GMT  
 
 [ 15 post ] 

 Relevant Pages 

1. MD5 byte array to hex array

2. String to byte array conversion and back....

3. byte array question

4. Convert HBITMAP to byte array...

5. Serialize to byte[] array

6. Convert a string to a byte array

7. byte[] array

8. Passing byte array from C# to C++ COM interface

9. Converting byte arrays in managed extensions

10. Passing a byte array that is CLS compliant

11. Passing a byte array to ATL Server method

12. Copy Struct to Byte Array

 

 
Powered by phpBB® Forum Software