//\r
// Author:\r
// Tim Coleman (tim@timcoleman.com)\r
+// Lluis Sanchez Gual (lluis@ximian.com)\r
//\r
// Copyright (C) Tim Coleman, 2002\r
//\r
+// TODO:\r
+// Need to set the stream variable from the outside, or the constructor.\r
+//\r
\r
using System.IO;\r
using System.Web.Services;\r
\r
#region Fields\r
\r
- string contentType = "text/xml";\r
+ string content_type = "text/xml";\r
SoapException exception = null;\r
- SoapHeaderCollection headers = null;\r
+ SoapHeaderCollection headers;\r
SoapMessageStage stage;\r
-\r
+ Stream stream;\r
+ object[] inParameters;\r
+ object[] outParameters;\r
+ \r
#endregion // Fields\r
\r
+ #region Constructors\r
+\r
+ internal SoapMessage ()\r
+ {\r
+ headers = new SoapHeaderCollection ();\r
+ }\r
+\r
+ internal SoapMessage (Stream stream)\r
+ {\r
+ this.stream = stream;\r
+ }\r
+\r
+ internal SoapMessage (Stream stream, SoapException exception)\r
+ {\r
+ this.exception = exception;\r
+ this.stream = stream;\r
+ headers = new SoapHeaderCollection ();\r
+ }\r
+\r
+ #endregion\r
+\r
#region Properties\r
\r
- public abstract string Action {\r
+ internal object[] InParameters \r
+ {\r
+ get { return inParameters; }\r
+ set { inParameters = value; }\r
+ }\r
+\r
+ internal object[] OutParameters \r
+ {\r
+ get { return outParameters; }\r
+ set { outParameters = value; }\r
+ }\r
+\r
+ public abstract string Action \r
+ {\r
get;\r
}\r
\r
public string ContentType {\r
- get { return contentType; }\r
- set { contentType = value; }\r
+ get { return content_type; }\r
+ set { content_type = value; }\r
}\r
\r
public SoapException Exception {\r
get { return stage; }\r
}\r
\r
+ internal void SetStage (SoapMessageStage stage)\r
+ {\r
+ this.stage = stage;\r
+ }\r
+ \r
public Stream Stream {\r
- [MonoTODO]\r
- get { throw new NotImplementedException (); }\r
+ get {\r
+ return stream;\r
+ }\r
}\r
\r
public abstract string Url {\r
throw new InvalidOperationException ("The current SoapMessageStage is not the asserted stage or stages.");\r
}\r
\r
- [MonoTODO]\r
public object GetInParameterValue (int index) \r
{\r
- throw new NotImplementedException ();\r
+ return inParameters [index];\r
}\r
\r
- [MonoTODO]\r
public object GetOutParameterValue (int index) \r
{\r
- throw new NotImplementedException ();\r
+ if (MethodInfo.IsVoid) return outParameters [index];\r
+ else return outParameters [index + 1];\r
}\r
\r
- [MonoTODO]\r
public object GetReturnValue ()\r
{\r
- throw new NotImplementedException ();\r
+ if (!MethodInfo.IsVoid && exception == null) return outParameters [0];\r
+ else return null;\r
+ }\r
+\r
+ internal void SetHeaders (SoapHeaderCollection headers)\r
+ {\r
+ this.headers = headers;\r
+ }\r
+\r
+ internal void SetException (SoapException ex)\r
+ {\r
+ exception = ex;\r
+ }\r
+\r
+ internal void CollectHeaders (object target, HeaderInfo[] headers, SoapHeaderDirection direction)\r
+ {\r
+ Headers.Clear ();\r
+ foreach (HeaderInfo hi in headers) \r
+ {\r
+ if ((hi.Direction & direction) != 0) \r
+ {\r
+ SoapHeader headerVal = hi.GetHeaderValue (target) as SoapHeader;\r
+ if (headerVal != null)\r
+ Headers.Add (headerVal);\r
+ }\r
+ }\r
+ }\r
+\r
+ internal void UpdateHeaderValues (object target, HeaderInfo[] headersInfo)\r
+ {\r
+ foreach (SoapHeader header in Headers)\r
+ {\r
+ HeaderInfo hinfo = FindHeader (headersInfo, header.GetType ());\r
+ if (hinfo != null)\r
+ hinfo.SetHeaderValue (target, header);\r
+ else\r
+ if (header.MustUnderstand)\r
+ throw new SoapHeaderException ("Unknown header", SoapException.MustUnderstandFaultCode);\r
+ header.DidUnderstand = false;\r
+ }\r
+ }\r
+\r
+ HeaderInfo FindHeader (HeaderInfo[] headersInfo, Type headerType)\r
+ {\r
+ foreach (HeaderInfo headerInfo in headersInfo)
+ if (headerInfo.HeaderType == headerType) return headerInfo;
+ return null;
}\r
\r
#endregion // Methods\r
}\r
-}\r
+}