Dime doubt

  • Thread starter Thread starter Vai2000
  • Start date Start date
V

Vai2000

Thanks for all responses
Please advice!

Hi All, Clients are uploading large files to my Web Portal. I need to
validate these files using a WS. Problem is file sizes are in the range of
5-20MB!!!!

Q1. How do I send DIME attachments to the WebSvc from my Portal?


TIA
 
Thanks Rick, Problem is how do I send attachment to the WS? This is what I
am attempting.....
private void Button1_Click(object sender, System.EventArgs e)
{
// load the file
// send it as dime attachment
SoapContext soapContext = HttpSoapContext.ResponseContext;
DimeAttachment dimeAttachment = new DimeAttachment("plain/text",
(TypeFormatEnum)16, strFullPath);
dimeAttachment.Id = "uri:" + Guid.NewGuid().ToString();
soapContext.Attachments.Add(dimeAttachment);

/// >>>> how should I call WS ????
service1 svc=new service1();
svc.UploadDimAttach();
}



Whats the latest then...?

Richard said:
I did this about a year ago... You need WSE {Web Service Enhancements}
and you attach the DIME attachment to the httprequest - I forget the
specifics...
 
Thank you my friend!!

Richard said:
Told you it was a year ago --> I meant SOAPContext...

Anyway file size is not an issue. Max DIME record size is either 64K or
4gig {I forget which} and I do not believe there is a limit on num records
per DIME attachment. I also do not believe there is a limit on the number
of DIME attachments per message {I was doing 0-n attachments of 2-10 meg per
attachment with no troubles over a high bandwidth connection}. The only
issue with 5-20meg files is how long users want to wait while upload is in
progress... Other caveats:
1) You have to call a method on the service after you have attached
everything to the context because the method call is when files are loaded
and bytes move across the wire. As far as actually moving bytes, if I
recall DIME will load the file content into 1 or more records as needed...
2) You have to send the ids of your attachments along with the request so
that you can retrieve the attachment by id on the server side; anything can
be an id - string GUIDS or filenames are fine - so long as it is unique per
request.
Anyway, when you wish to send you must attach the file blob to the context
of your instantiated service as that context is what is packaged up and
shipped along with any requests to your service. Also you
SendBLOBToWS()
{
// instantiate WS
service1 svc=new service1();

// create attachment
DimeAttachment attachment = new DimeAttachment("application/octet-stream",
TypeFormatEnum.MediaType, strFullPath)
// assure a unique id for this attachment
attachment.id = <<whatever>>

// connect attachment to WS context
svc.RequestSoapContext.Attachments(attachment);

// piggy-back file blob on any request to WS
svc.CallAnyMethod(attachment.id);
}

-------------------------------------------------------

Server side is:

Service1.CallAnyMethod(string id)
{
DimeAttachment attachment = HttpSoapContext.RequestContext.Attachments[id];
...
int ch = 0;
while ((ch = attachment.Stream.ReadByte()) != -1)
{
...
}
...
}

--Richard

Vai2000 said:
Thanks Rick, Problem is how do I send attachment to the WS? This is what I
am attempting.....
private void Button1_Click(object sender, System.EventArgs e)
{
// load the file
// send it as dime attachment
SoapContext soapContext = HttpSoapContext.ResponseContext;
DimeAttachment dimeAttachment = new DimeAttachment("plain/text",
(TypeFormatEnum)16, strFullPath);
dimeAttachment.Id = "uri:" + Guid.NewGuid().ToString();
soapContext.Attachments.Add(dimeAttachment);

/// >>>> how should I call WS ????
service1 svc=new service1();
svc.UploadDimAttach();
}



Whats the latest then...?

Enhancements}
and you attach the DIME attachment to the httprequest - I forget the
specifics... range
of
 
Here are GetFile and PutFile methods I did for WSE awhile ago. hth.

[SoapMethod("http://abc.com/2004/07/GetFile")]
public long GetFile(string path)
{
try
{
SoapContext rescx = ResponseSoapContext.Current;
DimeAttachment dimeAttach = new DimeAttachment(
"application/file", TypeFormat.MediaType, path);
rescx.Attachments.Add(dimeAttach);
return dimeAttach.Stream.Length;
}
catch
{
return -1;
}
}

[SoapMethod("http://abc.com/2004/07/PutFile")]
public long PutFile(string path)
{
try
{
SoapContext ctx = RequestSoapContext.Current;
if (ctx == null)
return -1;
if ( path == null )
return -1;

// Check for one attachment.
if (ctx.Attachments.Count != 1 )
return -1;

Stream stream = ctx.Attachments[0].Stream;
long len = stream.Length;
WriteFileFromStream(stream, path);
return len;
}
catch
{
return -1;
}
}
 
Back
Top