[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

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?

2 Answers

Sean Campbell

1/8/2003 12:16:00 AM

0

If you use WSE with 1.1/2003 you'll find that it works just fine.

And working with DIME is a bit easier.

Sean Campbell
3 Leaf


"Tim Johnson" <Tim.Johnson@MisysHealthCare.com> wrote in message
news:539b01c2b667$c1a24880$8bf82ecf@TK2MSFTNGXA05...
> 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?
>


(Yan Liu [MS])

1/8/2003 9:38:00 AM

0

Hi Tim,

I found out the following article that seems to be talking about what you
wanted to achieve:
http://www.codeproject.com/useritems/Remoti...

I hope this helps!

Regards,
Yan Liu
This posting is provided "AS IS" with no warranties, and confers no rights.