Example does not work - Uploading Attachments via the WS

This forum is now locked, since gold support is no longer offered.

Moderator: SourceGear

Locked
mshe
Posts: 38
Joined: Tue Nov 29, 2005 4:18 pm

Example does not work - Uploading Attachments via the WS

Post by mshe » Sat Jul 15, 2006 9:31 pm

Hello,

I tried to emulate the following example in VB.NET 2.0:

Get Attachment Example:

MantisItemAttachmentFullDetail mifd = new MantisItemAttachmentFullDetail();
System.Web.UI.HtmlControls.HtmlInputFile fileUpload; //assuming this control is on the ASP.NET page

mifd.AttStream = fileUpload.PostedFile.InputStream; //required System.IO.InputStream
mifd.ContentType = fileUpload.PostedFile.ContentType; //required string
mifd.FileCRC = 0; //this can just be zero
mifd.FileLength = fileUpload.PostedFile.ContentLength; //Required long
mifd.Description = strDescription; //optional string
mifd.FileName = strFilename; //required string - filename only, not the full path
mItem.Attachments = new MantisItemAttachmentFullDetail[] {mifd};


The line mifd.AttStream = fileUpload.PostedFile.InputStream; //required does not work - I cannot seem to pass any System.IO.Streams to the property AttStream.

Has anyone at sourcegear actually tried this code out?

mskrobul
Posts: 490
Joined: Wed Jan 14, 2004 10:22 am
Location: SourceGear
Contact:

Post by mskrobul » Mon Jul 17, 2006 9:03 am

The example code is pretty much the exact code Dragnet uses to add attachments so we have tried it. We haven't tried it with VB.NET 2.0, but it does work with in VS.NET 2003 (we use C#).

Are you getting compiler errors or runtime errors?
Mary Jo Skrobul
SourceGear

mshe
Posts: 38
Joined: Tue Nov 29, 2005 4:18 pm

Post by mshe » Mon Jul 17, 2006 9:20 am

I tried in both VS.NET 2003 and 2005 :(

The line fails:

mifd.AttStream = fileUpload.PostedFile.InputStream; //required System.IO.InputStream

mifd.AttStream does not take a System.IO.InputStream parameter - rather ... it takes a DragNetClient(WS namespace).DragNet.Stream...

It seems VS.NET generates the wrong type for this parameter?

How does SourceGear create their web service stub so that the proper parameter can be passed in (what data type does it expect? A .NET IO.Stream)?
Attachments
Reference.vb.txt
(202.59 KiB) Downloaded 1348 times

mskrobul
Posts: 490
Joined: Wed Jan 14, 2004 10:22 am
Location: SourceGear
Contact:

Post by mskrobul » Mon Jul 17, 2006 11:52 am

OK, Dragnet doesn't go through the webservice so that is why the Dragnet attachment code works and yours doesn't.

We will need to look into adding attachments via the webservice a bit further. We may need a new web service method to do it.
Mary Jo Skrobul
SourceGear

Locked