* Methods.cs: Little fix in binding check.
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Protocols / SoapMessage.cs
index 26cca826cea4a8feea0b62a20d19faf16d23c1e2..499eba92aabe8549d6778d79dbcec587186a64db 100644 (file)
@@ -36,9 +36,8 @@ namespace System.Web.Services.Protocols {
                        headers = new SoapHeaderCollection ();\r
                }\r
 \r
-               internal SoapMessage (Stream stream, SoapHeaderCollection headers)\r
+               internal SoapMessage (Stream stream)\r
                {\r
-                       this.headers = headers;\r
                        this.stream = stream;\r
                }\r
 \r
@@ -136,10 +135,55 @@ namespace System.Web.Services.Protocols {
 \r
                public object GetReturnValue ()\r
                {\r
-                       if (MethodInfo.IsVoid) return null;\r
-                       else return outParameters [0];\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
+}