[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / System.Web.Services / System.Web.Services.Protocols / SoapMessage.cs
blob8fa269658ab8f7cc4b5378e887bdde20a692b325
1 //
2 // System.Web.Services.Protocols.SoapMessage.cs
3 //
4 // Author:
5 // Tim Coleman (tim@timcoleman.com)
6 // Lluis Sanchez Gual (lluis@ximian.com)
7 //
8 // Copyright (C) Tim Coleman, 2002
9 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using HeaderInfo = System.Web.Services.Protocols.SoapHeaderMapping;
34 using System.ComponentModel;
35 using System.IO;
36 using System.Web.Services;
38 namespace System.Web.Services.Protocols {
39 public abstract class SoapMessage {
41 #region Fields
43 string content_type = "text/xml";
44 string content_encoding;
45 SoapException exception = null;
46 SoapHeaderCollection headers;
47 SoapMessageStage stage;
48 Stream stream;
49 object[] inParameters;
50 object[] outParameters;
52 SoapProtocolVersion soapVersion;
54 #endregion // Fields
56 #region Constructors
58 internal SoapMessage ()
60 headers = new SoapHeaderCollection ();
63 internal SoapMessage (Stream stream, SoapException exception)
65 this.exception = exception;
66 this.stream = stream;
67 headers = new SoapHeaderCollection ();
70 #endregion
72 #region Properties
74 internal object[] InParameters
76 get { return inParameters; }
77 set { inParameters = value; }
80 internal object[] OutParameters
82 get { return outParameters; }
83 set { outParameters = value; }
86 public abstract string Action
88 get;
91 public string ContentType {
92 get { return content_type; }
93 set { content_type = value; }
96 public SoapException Exception {
97 get { return exception; }
98 set { exception = value; }
101 public SoapHeaderCollection Headers {
102 get { return headers; }
105 public abstract LogicalMethodInfo MethodInfo {
106 get;
109 public abstract bool OneWay {
110 get;
113 public SoapMessageStage Stage {
114 get { return stage; }
117 internal void SetStage (SoapMessageStage stage)
119 this.stage = stage;
122 public Stream Stream {
123 get {
124 return stream;
128 public abstract string Url {
129 get;
132 public string ContentEncoding
134 get { return content_encoding; }
135 set { content_encoding = value; }
138 internal bool IsSoap12 {
139 get {
140 return SoapVersion == SoapProtocolVersion.Soap12;
144 [System.Runtime.InteropServices.ComVisible(false)]
145 [DefaultValue (SoapProtocolVersion.Default)]
146 public virtual SoapProtocolVersion SoapVersion {
147 get { return soapVersion; }
150 internal Stream InternalStream
152 // for getter use public stream property
153 set {
154 stream = value;
158 #endregion Properties
160 #region Methods
162 protected abstract void EnsureInStage ();
163 protected abstract void EnsureOutStage ();
165 protected void EnsureStage (SoapMessageStage stage)
167 if ((((int) stage) & ((int) Stage)) == 0)
168 throw new InvalidOperationException ("The current SoapMessageStage is not the asserted stage or stages.");
171 public object GetInParameterValue (int index)
173 return inParameters [index];
176 public object GetOutParameterValue (int index)
178 if (MethodInfo.IsVoid) return outParameters [index];
179 else return outParameters [index + 1];
182 public object GetReturnValue ()
184 if (!MethodInfo.IsVoid && exception == null) return outParameters [0];
185 else return null;
188 internal void SetHeaders (SoapHeaderCollection headers)
190 this.headers = headers;
193 internal void SetException (SoapException ex)
195 exception = ex;
198 internal void CollectHeaders (object target, HeaderInfo[] headers, SoapHeaderDirection direction)
200 Headers.Clear ();
201 foreach (HeaderInfo hi in headers)
203 if ((hi.Direction & direction) != 0 && !hi.Custom)
205 SoapHeader headerVal = hi.GetHeaderValue (target) as SoapHeader;
206 if (headerVal != null)
207 Headers.Add (headerVal);
212 internal void UpdateHeaderValues (object target, HeaderInfo[] headersInfo)
214 foreach (SoapHeader header in Headers)
216 HeaderInfo hinfo = FindHeader (headersInfo, header.GetType ());
217 if (hinfo != null) {
218 hinfo.SetHeaderValue (target, header);
219 header.DidUnderstand = !hinfo.Custom;
224 HeaderInfo FindHeader (HeaderInfo[] headersInfo, Type headerType)
226 HeaderInfo unknownHeaderInfo = null;
228 foreach (HeaderInfo headerInfo in headersInfo) {
229 if (headerInfo.HeaderType == headerType)
230 return headerInfo;
231 else if (headerInfo.Custom)
232 unknownHeaderInfo = headerInfo;
234 return unknownHeaderInfo;
237 #endregion // Methods