Tim Johnson
1/7/2003 5:13:00 PM
I am trying to write a WEB Service, using Visual
Studio .NET 2003 Final Beta, that receives DIME
attachments.
1) Which is the best approach:
a) Use SOAPExtension
b) Install "Web Services Enhancements 1.0 (this was not
tested with .NET framework 1.1 which comes with VS .NET
2003). Use DimeWriter, DimeReader and Pipeline
If SOAPExtension is the way to go, then I need help with
writing a Client for my WEB Service.
I wrote a Windows Application Client using C#. Currently I
have a class that inherits from SOAPExtension -
TransferViaDime. My client has a WEB Reference to my WEB
Service, so as part of the WEB Method definition I added
[TransferViaDIME]. The following is the code I added to
my TransferViaDime class:
public override Stream ChainStream( Stream stream )
{
switch (stream.GetType().ToString())
{
case "System.Web.Services.Protocols.SoapExtensionStream":
oldStream = stream;
newStream = new MemoryStream();
return newStream;
default:
return stream;
}
}
public override void ProcessMessage(SoapMessage message)
.
.
case SoapMessageStage.AfterSerialize:
//newStream contains the SOAPEnvelope now
that the WEB Method has been serialized.
//We want to make the SOAPEnvelope the
first DIME record
setSOAPEnvelope();
newStream.Position = 0;
break;
private setSOAPEnvelope()
{
DimeRecord dr1 = new DimeRecord();
DimeRecord dr2 = new DimeRecord();
DimeGenerator dg = new DimeGenerator();
string DimeType = "text/xml";
string DimeID = "tim";
newStream.Position = 0;
FileStream fs = new FileStream("tim.txt",
FileMode.Open, FileAccess.Read);
// Use what is in tim.txt ("Hello World")
has our second DIME record
byte[] b2 = new byte[fs.Length];
fs.Read(b1, 0, (int)fs.Length);
// Put SOAPEnvelope into first DIME Record
byte[] b1 = new byte[newStream.Length];
newStream.Read(b2, 0, (int)
newStream.Length);
newStream.Position = 0;
dr1.DataType =
DimeRecord.DataFormatType.Media_Type;
dr1.DimeType = DimeType;
dr1.DimeData = b1;
dr2.DataType =
DimeRecord.DataFormatType.Media_Type;
dr2.DimeID = DimeID;
dr2.DimeData = b2;
dg.AddDimeRecord(dr1);
dg.AddDimeRecord(dr2);
//Put the newly created DIME records into
our SOAPEnvelope buffer
newStream = dg.GetStream();
newStream.Position = 0;
}
The problem: Nothing gets sent to my WEB Service. By
nothing I mean the SOAPEnvelope doesn't get sent. It
doesn't matter what I stick in newStream, the SOAPEnvelope
never gets sent.
What am I doing wrong?