**** Merged from MCS ****
[mono-project.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Messaging / SoapSender.cs
blob485c021051004a0b2cea6f0e812e0ecea3c478cb
1 //
2 // Microsoft.Web.Services.Messaging.SoapSender
3 //
4 // Author: Todd Berman <tberman@gentoo.org>
5 //
6 // (C) 2003 Todd Berman
8 using System;
9 using System.Web;
10 using Microsoft.Web.Services;
11 using Microsoft.Web.Services.Addressing;
12 using Microsoft.Web.Services.Configuration;
14 namespace Microsoft.Web.Services.Messaging {
16 public class SoapSender : SoapPort
19 private EndpointReference _destination = null;
20 private ISoapTransport _transport = null;
22 public SoapSender () : base ()
26 public SoapSender (EndpointReference dest) : base ()
28 if(dest == null) {
29 throw new ArgumentNullException ("destination");
31 Destination = dest;
34 public SoapSender (Uri destination) : this (new EndpointReference (destination))
38 protected override void FilterMessage (SoapEnvelope env)
40 if(env == null) {
41 throw new ArgumentNullException ("envelope");
43 Pipeline.ProcessOutputMessage (env);
46 public void Send (SoapEnvelope env)
48 if(env == null) {
49 throw new ArgumentNullException ("envelope");
51 if(env.Context.Action == null) {
52 throw new ArgumentException ("Action not set");
54 if(env.Processed == true || env.Context.Processed == true) {
55 throw new ArgumentException ("Attempting to re-process an envelope");
58 if(_destination == null) {
59 throw new ArgumentException ("Destination is not set, cant send");
61 if(_transport == null) {
62 throw new ArgumentException ("Transport is not set, cant send");
65 env.Context.SetTo(_destination.Address);
67 FilterMessage (env);
69 _transport.Send (env, _destination);
72 [MonoTODO]
73 public IAsyncResult BeginSend (SoapEnvelope env, AsyncCallback callback, object state)
75 throw new NotImplementedException ();
78 [MonoTODO]
79 public void EndSend (IAsyncResult result)
81 throw new NotImplementedException ();
84 public ISoapTransport Transport {
85 get { return _transport; }
88 public EndpointReference Destination {
89 get { return _destination; }
90 set {
91 if(value == null || value.Address == null || value.Address.Value == null) {
92 throw new ArgumentNullException ("destination");
94 ISoapTransport trans = WebServicesConfiguration.MessagingConfiguration.GetTransport (value.Address.Value.Scheme);
95 if(trans == null) {
96 throw new ArgumentException ("Transport " + value.Address.Value.Scheme + " is not supported");
98 _destination = value;
99 _transport = trans;