**** Merged from MCS ****
[mono-project.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Messaging / SoapTransport.cs
bloba9d8433ab01342df43951566159d931c6a0e90ec
1 //
2 // Microsoft.Web.Services.Messaging.SoapTransport.cs
3 //
4 // Author: Todd Berman <tberman@gentoo.org>
5 //
6 // (C) 2003 Todd Berman
8 using System;
9 using System.Net;
11 namespace Microsoft.Web.Services.Messaging
13 public abstract class SoapTransport
15 private SoapChannelCollection _channels;
16 private ICredentials _credentials;
17 private ISoapFormatter _formatter;
18 private int _timeout;
20 [MonoTODO("DimeFormatter is the default here, but not impl yet")]
21 protected SoapTransport () : base ()
23 _credentials = null;
24 _formatter = new SoapPlainFormatter ();
25 _channels = new SoapChannelCollection ();
26 _timeout = 120000;
29 public SoapChannelCollection Channels {
30 get { return _channels; }
33 public ICredentials Credentials {
34 get { return _credentials; }
35 set { _credentials = value; }
38 public ISoapFormatter Formatter {
39 get { return _formatter; }
40 set {
41 if(value == null) {
42 throw new ArgumentNullException ("formatter");
44 _formatter = value;
48 public int IdleTimeout {
49 get { return _timeout; }
50 set {
51 if(value < 0) {
52 throw new ArgumentNullException ("Timeout");
54 _timeout = value;
58 protected class SendAsyncResult : AsyncResult
60 private delegate void Send (SoapEnvelope env);
62 private SoapChannel _channel;
64 public SendAsyncResult (SoapChannel chan,
65 SoapEnvelope env,
66 AsyncCallback callback,
67 object state) : base (callback, state)
69 _channel = chan;
70 chan.BeginSend (env, new AsyncCallback (OnSendComplete), null);
73 public void OnSendComplete (IAsyncResult result)
75 try {
76 _channel.EndSend (result);
77 Complete (result.CompletedSynchronously);
78 } catch (Exception e) {
79 Complete (result.CompletedSynchronously, e);
83 public SoapChannel Channel {
84 get { return _channel; }