コード例 #1
0
        internal SoapExtension CreateInstance(object initializer)
        {
            SoapExtension extension = (SoapExtension)Activator.CreateInstance(this.type);

            extension.Initialize(initializer);
            return(extension);
        }
コード例 #2
0
        protected object[] Invoke(string method_name, object[] parameters)
        {
            SoapMethodStubInfo msi = (SoapMethodStubInfo)type_info.GetMethod(method_name);

            SoapClientMessage message = new SoapClientMessage(this, msi, Url, parameters);

            message.CollectHeaders(this, message.MethodStubInfo.Headers, SoapHeaderDirection.In);

            SoapExtension[] extensions = SoapExtension.CreateExtensionChain(type_info.SoapExtensions[0], msi.SoapExtensions, type_info.SoapExtensions[1]);

            WebResponse response;

            try
            {
                WebRequest request = GetRequestForMessage(uri, message);
                SendRequest(request.GetRequestStream(), message, extensions);
                response = GetWebResponse(request);
            }
            catch (WebException ex)
            {
                response = ex.Response;
                HttpWebResponse http_response = response as HttpWebResponse;
                if (http_response == null || http_response.StatusCode != HttpStatusCode.InternalServerError)
                {
                    throw ex;
                }
            }

            try {
                return(ReceiveResponse(response, message, extensions));
            }
            finally {
                response.Close();
            }
        }
コード例 #3
0
ファイル: SoapExtension.cs プロジェクト: Skycweb/mono-skycweb
        internal static SoapExtensionRuntimeConfig[][] GetTypeExtensions(Type serviceType)
        {
            if (globalExtensions == null)
            {
                InitializeGlobalExtensions();
            }

            SoapExtensionRuntimeConfig[][] exts = new SoapExtensionRuntimeConfig[2][];

            for (int group = 0; group < 2; group++)
            {
                ArrayList globList = globalExtensions[group];
                if (globList == null)
                {
                    continue;
                }
                exts [group] = new SoapExtensionRuntimeConfig [globList.Count];
                for (int n = 0; n < globList.Count; n++)
                {
                    SoapExtensionTypeElement   econf    = (SoapExtensionTypeElement)globList [n];
                    SoapExtensionRuntimeConfig typeconf = new SoapExtensionRuntimeConfig();
                    typeconf.Type = econf.Type;
                    SoapExtension ext = (SoapExtension)Activator.CreateInstance(econf.Type);
                    typeconf.InitializationInfo = ext.GetInitializer(serviceType);
                    exts [group][n]             = typeconf;
                }
            }
            return(exts);
        }
コード例 #4
0
        protected IAsyncResult BeginInvoke(string methodName, object[] parameters, AsyncCallback callback, object asyncState)
        {
            SoapMethodStubInfo msi = (SoapMethodStubInfo)type_info.GetMethod(methodName);

            SoapWebClientAsyncResult ainfo = null;

            try
            {
                SoapClientMessage message = new SoapClientMessage(this, msi, Url, parameters);
                message.CollectHeaders(this, message.MethodStubInfo.Headers, SoapHeaderDirection.In);

                WebRequest request = GetRequestForMessage(uri, message);

                ainfo            = new SoapWebClientAsyncResult(request, callback, asyncState);
                ainfo.Message    = message;
                ainfo.Extensions = SoapExtension.CreateExtensionChain(type_info.SoapExtensions[0], msi.SoapExtensions, type_info.SoapExtensions[1]);

                ainfo.Request.BeginGetRequestStream(new AsyncCallback(AsyncGetRequestStreamDone), ainfo);
                RegisterMapping(asyncState, ainfo);
            }
            catch (Exception ex)
            {
                if (ainfo != null)
                {
                    ainfo.SetCompleted(null, ex, false);
                }
            }

            return(ainfo);
        }
コード例 #5
0
ファイル: SoapExtension.cs プロジェクト: Profit0004/mono
		internal static SoapExtension[] CreateExtensionChain (SoapExtensionRuntimeConfig[] extensionConfigs)
		{
			if (extensionConfigs == null) return null;
			SoapExtension[] res = new SoapExtension [extensionConfigs.Length];
			CreateExtensionChain (extensionConfigs, res, 0);
			return res;
		}
コード例 #6
0
        public SoapTypeStubInfo(LogicalTypeInfo logicalTypeInfo)
            : base(logicalTypeInfo)
        {
            xmlImporter  = new XmlReflectionImporter();
            soapImporter = new SoapReflectionImporter();

            if (typeof(SoapHttpClientProtocol).IsAssignableFrom(Type))
            {
                if (Bindings.Count == 0 || ((BindingInfo)Bindings[0]).WebServiceBindingAttribute == null)
                {
                    throw new InvalidOperationException("WebServiceBindingAttribute is required on proxy class '" + Type + "'.");
                }
                if (Bindings.Count > 1)
                {
                    throw new InvalidOperationException("Only one WebServiceBinding attribute may be specified on type '" + Type + "'.");
                }
            }

            object [] o = Type.GetCustomAttributes(typeof(SoapDocumentServiceAttribute), false);
            if (o.Length == 1)
            {
                SoapDocumentServiceAttribute a = (SoapDocumentServiceAttribute)o [0];

                ParameterStyle   = a.ParameterStyle;
                SoapBindingStyle = SoapBindingStyle.Document;
            }
            else
            {
                o = Type.GetCustomAttributes(typeof(SoapRpcServiceAttribute), false);
                if (o.Length == 1)
                {
                    SoapRpcServiceAttribute srs = (SoapRpcServiceAttribute)o [0];

                    ParameterStyle   = SoapParameterStyle.Wrapped;
                    SoapBindingStyle = SoapBindingStyle.Rpc;
                }
                else
                {
                    ParameterStyle   = SoapParameterStyle.Wrapped;
                    SoapBindingStyle = SoapBindingStyle.Document;
                }
            }

            if (ParameterStyle == SoapParameterStyle.Default)
            {
                ParameterStyle = SoapParameterStyle.Wrapped;
            }

            xmlImporter.IncludeTypes(Type);
            soapImporter.IncludeTypes(Type);

#if MONOTOUCH
            SoapExtensions = new SoapExtensionRuntimeConfig [2][];
#else
            SoapExtensions = SoapExtension.GetTypeExtensions(Type);
#endif
        }
コード例 #7
0
ファイル: SoapExtension.cs プロジェクト: Skycweb/mono-skycweb
 internal static SoapExtension[] CreateExtensionChain(SoapExtensionRuntimeConfig[] extensionConfigs)
 {
     if (extensionConfigs == null)
     {
         return(null);
     }
     SoapExtension[] res = new SoapExtension [extensionConfigs.Length];
     CreateExtensionChain(extensionConfigs, res, 0);
     return(res);
 }
コード例 #8
0
ファイル: SoapExtension.cs プロジェクト: Skycweb/mono-skycweb
 static int CreateExtensionChain(SoapExtensionRuntimeConfig[] extensionConfigs, SoapExtension[] destArray, int pos)
 {
     for (int n = 0; n < extensionConfigs.Length; n++)
     {
         SoapExtensionRuntimeConfig econf = extensionConfigs [n];
         SoapExtension ext = (SoapExtension)Activator.CreateInstance(econf.Type);
         ext.Initialize(econf.InitializationInfo);
         destArray [pos++] = ext;
     }
     return(pos);
 }
コード例 #9
0
 internal static SoapExtension[] InitializeExtensions(SoapReflectedExtension[] reflectedExtensions, object[] extensionInitializers)
 {
     if (reflectedExtensions == null)
     {
         return((SoapExtension[])null);
     }
     SoapExtension[] soapExtensionArray = new SoapExtension[reflectedExtensions.Length];
     for (int index = 0; index < soapExtensionArray.Length; ++index)
     {
         soapExtensionArray[index] = reflectedExtensions[index].CreateInstance(extensionInitializers[index]);
     }
     return(soapExtensionArray);
 }
コード例 #10
0
ファイル: SoapMessage.cs プロジェクト: dox0/DotNet471RS3
 internal static SoapExtension[] InitializeExtensions(SoapReflectedExtension[] reflectedExtensions, object[] extensionInitializers)
 {
     if (reflectedExtensions == null)
     {
         return(null);
     }
     SoapExtension[] extensions = new SoapExtension[reflectedExtensions.Length];
     for (int i = 0; i < extensions.Length; i++)
     {
         extensions[i] = reflectedExtensions[i].CreateInstance(extensionInitializers[i]);
     }
     return(extensions);
 }
コード例 #11
0
ファイル: SoapExtension.cs プロジェクト: Profit0004/mono
		internal static SoapExtension[] CreateExtensionChain (SoapExtensionRuntimeConfig[] hiPrioExts, SoapExtensionRuntimeConfig[] medPrioExts, SoapExtensionRuntimeConfig[] lowPrioExts)
		{
			int len = 0;
			if (hiPrioExts != null) len += hiPrioExts.Length;
			if (medPrioExts != null) len += medPrioExts.Length;
			if (lowPrioExts != null) len += lowPrioExts.Length;
			if (len == 0) return null;

			SoapExtension[] res = new SoapExtension [len];
			int pos = 0;
			if (hiPrioExts != null) pos = CreateExtensionChain (hiPrioExts, res, pos);
			if (medPrioExts != null) pos = CreateExtensionChain (medPrioExts, res, pos);
			if (lowPrioExts != null) pos = CreateExtensionChain (lowPrioExts, res, pos);
			return res;
		}
コード例 #12
0
ファイル: SoapExtension.cs プロジェクト: Skycweb/mono-skycweb
        internal static SoapExtensionRuntimeConfig[] GetMethodExtensions(LogicalMethodInfo method)
        {
            object[] ats = method.GetCustomAttributes(typeof(SoapExtensionAttribute));
            SoapExtensionRuntimeConfig[] exts = new SoapExtensionRuntimeConfig [ats.Length];
            int[] priorities = new int[ats.Length];

            for (int n = 0; n < ats.Length; n++)
            {
                SoapExtensionAttribute     at    = (SoapExtensionAttribute)ats[n];
                SoapExtensionRuntimeConfig econf = new SoapExtensionRuntimeConfig();
                econf.Type     = at.ExtensionType;
                priorities [n] = at.Priority;
                SoapExtension ext = (SoapExtension)Activator.CreateInstance(econf.Type);
                econf.InitializationInfo = ext.GetInitializer(method, at);
                exts [n] = econf;
            }
            Array.Sort(priorities, exts);
            return(exts);
        }
コード例 #13
0
        private static Array CombineExtensionsHelper(Array array1, Array array2, Type elementType)
        {
            if (array1 == null)
            {
                return(array2);
            }
            if (array2 == null)
            {
                return(array1);
            }
            int length = array1.Length + array2.Length;

            if (length == 0)
            {
                return(null);
            }
            Array result = null;

            if (elementType == typeof(SoapReflectedExtension))
            {
                result = new SoapReflectedExtension[length];
            }
            else if (elementType == typeof(SoapExtension))
            {
                result = new SoapExtension[length];
            }
            else if (elementType == typeof(object))
            {
                result = new object[length];
            }
            else
            {
                throw new ArgumentException(Res.GetString(Res.ElementTypeMustBeObjectOrSoapExtensionOrSoapReflectedException), "elementType");
            }

            Array.Copy(array1, 0, result, 0, array1.Length);
            Array.Copy(array2, 0, result, array1.Length, array2.Length);
            return(result);
        }
コード例 #14
0
ファイル: SoapExtension.cs プロジェクト: Skycweb/mono-skycweb
        internal static SoapExtension[] CreateExtensionChain(SoapExtensionRuntimeConfig[] hiPrioExts, SoapExtensionRuntimeConfig[] medPrioExts, SoapExtensionRuntimeConfig[] lowPrioExts)
        {
            int len = 0;

            if (hiPrioExts != null)
            {
                len += hiPrioExts.Length;
            }
            if (medPrioExts != null)
            {
                len += medPrioExts.Length;
            }
            if (lowPrioExts != null)
            {
                len += lowPrioExts.Length;
            }
            if (len == 0)
            {
                return(null);
            }

            SoapExtension[] res = new SoapExtension [len];
            int             pos = 0;

            if (hiPrioExts != null)
            {
                pos = CreateExtensionChain(hiPrioExts, res, pos);
            }
            if (medPrioExts != null)
            {
                pos = CreateExtensionChain(medPrioExts, res, pos);
            }
            if (lowPrioExts != null)
            {
                pos = CreateExtensionChain(lowPrioExts, res, pos);
            }
            return(res);
        }
コード例 #15
0
        private static Array CombineExtensionsHelper(Array array1, Array array2, Type elementType)
        {
            if (array1 == null)
            {
                return(array2);
            }
            if (array2 == null)
            {
                return(array1);
            }
            int num = array1.Length + array2.Length;

            if (num == 0)
            {
                return(null);
            }
            Array destinationArray = null;

            if (elementType == typeof(SoapReflectedExtension))
            {
                destinationArray = new SoapReflectedExtension[num];
            }
            else if (elementType == typeof(SoapExtension))
            {
                destinationArray = new SoapExtension[num];
            }
            else
            {
                if (elementType != typeof(object))
                {
                    throw new ArgumentException(System.Web.Services.Res.GetString("ElementTypeMustBeObjectOrSoapExtensionOrSoapReflectedException"), "elementType");
                }
                destinationArray = new object[num];
            }
            Array.Copy(array1, 0, destinationArray, 0, array1.Length);
            Array.Copy(array2, 0, destinationArray, array1.Length, array2.Length);
            return(destinationArray);
        }
コード例 #16
0
        void SendRequest(Stream s, SoapClientMessage message, SoapExtension[] extensions)
        {
            using (s) {
                if (extensions != null)
                {
                    s = SoapExtension.ExecuteChainStream(extensions, s);
                    message.SetStage(SoapMessageStage.BeforeSerialize);
                    SoapExtension.ExecuteProcessMessage(extensions, message, s, true);
                }

                XmlTextWriter xtw = WebServiceHelper.CreateXmlWriter(s);
                WebServiceHelper.WriteSoapMessage(xtw, message.MethodStubInfo, SoapHeaderDirection.In, message.Parameters, message.Headers, message.IsSoap12);

                if (extensions != null)
                {
                    message.SetStage(SoapMessageStage.AfterSerialize);
                    SoapExtension.ExecuteProcessMessage(extensions, message, s, true);
                }

                xtw.Flush();
                xtw.Close();
            }
        }
コード例 #17
0
 private static Array CombineExtensionsHelper(Array array1, Array array2, Type elementType) {
     if (array1 == null) return array2;
     if (array2 == null) return array1;
     int length = array1.Length + array2.Length;
     if (length == 0)
         return null;
     Array result = null;
     if (elementType == typeof(SoapReflectedExtension))
         result = new SoapReflectedExtension[length];
     else if (elementType == typeof(SoapExtension))
         result = new SoapExtension[length];
     else if (elementType == typeof(object))
         result  = new object[length];
     else 
         throw new ArgumentException(Res.GetString(Res.ElementTypeMustBeObjectOrSoapExtensionOrSoapReflectedException), "elementType");
     
     Array.Copy(array1, 0, result, 0, array1.Length);
     Array.Copy(array2, 0, result, array1.Length, array2.Length);
     return result;
 }
コード例 #18
0
		void SendRequest (Stream s, SoapClientMessage message, SoapExtension[] extensions)
		{
			using (s) {

				if (extensions != null) {
					s = SoapExtension.ExecuteChainStream (extensions, s);
					message.SetStage (SoapMessageStage.BeforeSerialize);
					SoapExtension.ExecuteProcessMessage (extensions, message, true);
				}

				XmlTextWriter xtw = WebServiceHelper.CreateXmlWriter (s);
				
				WebServiceHelper.WriteSoapMessage (xtw, type_info, message.MethodStubInfo.Use, message.MethodStubInfo.RequestSerializer, message.Parameters, message.Headers);

				if (extensions != null) {
					message.SetStage (SoapMessageStage.AfterSerialize);
					SoapExtension.ExecuteProcessMessage (extensions, message, true);
				}

				xtw.Flush ();
				xtw.Close ();
			 }
		}
コード例 #19
0
        void SerializeResponse(HttpResponse response, SoapServerMessage message)
        {
            SoapMethodStubInfo methodInfo = message.MethodStubInfo;

            if ((message.ContentEncoding != null) && (message.ContentEncoding.Length > 0))
            {
                response.AppendHeader("Content-Encoding", message.ContentEncoding);
            }

            response.ContentType = message.IsSoap12 ?
                                   "application/soap+xml; charset=utf-8" :
                                   "text/xml; charset=utf-8";
            if (message.Exception != null)
            {
                response.StatusCode = 500;
            }

            Stream responseStream = response.OutputStream;
            Stream outStream      = responseStream;
            bool   bufferResponse = (methodInfo == null || methodInfo.MethodAttribute.BufferResponse);

            response.BufferOutput = bufferResponse;

            try
            {
                // While serializing, process extensions in reverse order

                if (bufferResponse)
                {
                    outStream = SoapExtension.ExecuteChainStream(_extensionChainHighPrio, outStream);
                    outStream = SoapExtension.ExecuteChainStream(_extensionChainMedPrio, outStream);
                    outStream = SoapExtension.ExecuteChainStream(_extensionChainLowPrio, outStream);

                    message.SetStage(SoapMessageStage.BeforeSerialize);
                    SoapExtension.ExecuteProcessMessage(_extensionChainLowPrio, message, outStream, true);
                    SoapExtension.ExecuteProcessMessage(_extensionChainMedPrio, message, outStream, true);
                    SoapExtension.ExecuteProcessMessage(_extensionChainHighPrio, message, outStream, true);
                }

                XmlTextWriter xtw = WebServiceHelper.CreateXmlWriter(outStream);


                if (message.Exception == null)
                {
                    WebServiceHelper.WriteSoapMessage(xtw, methodInfo, SoapHeaderDirection.Out, message.OutParameters, message.Headers, message.IsSoap12);
                }
                else if (methodInfo != null)
                {
                    if (message.IsSoap12)
                    {
                        WebServiceHelper.WriteSoapMessage(xtw, methodInfo, SoapHeaderDirection.Fault, new Soap12Fault(message.Exception), message.Headers, message.IsSoap12);
                    }
                    else
                    {
                        WebServiceHelper.WriteSoapMessage(xtw, methodInfo, SoapHeaderDirection.Fault, new Fault(message.Exception), message.Headers, message.IsSoap12);
                    }
                }
                else
                {
                    if (message.IsSoap12)
                    {
                        WebServiceHelper.WriteSoapMessage(xtw, SoapBindingUse.Literal, Soap12Fault.Serializer, null, new Soap12Fault(message.Exception), null, message.IsSoap12);
                    }
                    else
                    {
                        WebServiceHelper.WriteSoapMessage(xtw, SoapBindingUse.Literal, Fault.Serializer, null, new Fault(message.Exception), null, message.IsSoap12);
                    }
                }

                if (bufferResponse)
                {
                    message.SetStage(SoapMessageStage.AfterSerialize);
                    SoapExtension.ExecuteProcessMessage(_extensionChainLowPrio, message, outStream, true);
                    SoapExtension.ExecuteProcessMessage(_extensionChainMedPrio, message, outStream, true);
                    SoapExtension.ExecuteProcessMessage(_extensionChainHighPrio, message, outStream, true);
                }

                xtw.Flush();
            }
            catch (Exception ex)
            {
                // If the response is buffered, we can discard the response and
                // serialize a new Fault message as response.
                if (bufferResponse)
                {
                    throw ex;
                }

                // If it is not buffered, we can't rollback what has been sent,
                // so we can only close the connection and return.
                responseStream.Close();
                return;
            }
        }
コード例 #20
0
 /// <devdoc>
 /// Allows derived classes to reorder or to replace intialized soap extensions prior to
 /// the system calling ChainStream or executing them in any stage.        
 /// </devdoc>
 protected virtual SoapExtension[] ModifyInitializedExtensions(PriorityGroup group, SoapExtension[] extensions)
 {
     return extensions;
 }
コード例 #21
0
ファイル: SoapExtension.cs プロジェクト: Profit0004/mono
		internal static void ExecuteProcessMessage(SoapExtension[] extensions, SoapMessage message, Stream stream, bool inverseOrder) 
		{
			if (extensions == null) return;

			message.InternalStream = stream;

			if (inverseOrder)
			{
				for (int n = extensions.Length-1; n >= 0; n--)
					extensions[n].ProcessMessage (message);
			}
			else
			{
				for (int n = 0; n < extensions.Length; n++)
					extensions[n].ProcessMessage (message);
			}
		}
コード例 #22
0
        internal object GetInitializer(Type serviceType)
        {
            SoapExtension extension = (SoapExtension)Activator.CreateInstance(this.type);

            return(extension.GetInitializer(serviceType));
        }
コード例 #23
0
ファイル: SoapMessage.cs プロジェクト: consumentor/Server
 internal void InitExtensionStreamChain(SoapExtension[] extensions)
 {
   if (extensions == null)
     return;
   for (int index = 0; index < extensions.Length; ++index)
     this.stream = extensions[index].ChainStream(this.stream);
 }
コード例 #24
0
ファイル: SoapMessage.cs プロジェクト: consumentor/Server
 internal void RunExtensions(SoapExtension[] extensions, bool throwOnException)
 {
   if (extensions == null)
     return;
   TraceMethod traceMethod1;
   if (!Tracing.On)
     traceMethod1 = (TraceMethod) null;
   else
     traceMethod1 = new TraceMethod((object) this, "RunExtensions", new object[2]
     {
       (object) extensions,
       (object) (bool) (throwOnException ? 1 : 0)
     });
   TraceMethod traceMethod2 = traceMethod1;
   if ((this.stage & (SoapMessageStage) 12) != (SoapMessageStage) 0)
   {
     for (int index = 0; index < extensions.Length; ++index)
     {
       if (Tracing.On)
         Tracing.Enter("SoapExtension", traceMethod2, new TraceMethod((object) extensions[index], "ProcessMessage", new object[1]
         {
           (object) this.stage
         }));
       extensions[index].ProcessMessage(this);
       if (Tracing.On)
         Tracing.Exit("SoapExtension", traceMethod2);
       if (this.Exception != null)
       {
         if (throwOnException)
           throw this.Exception;
         if (Tracing.On)
           Tracing.ExceptionIgnore(TraceEventType.Warning, traceMethod2, (Exception) this.Exception);
       }
     }
   }
   else
   {
     for (int index = extensions.Length - 1; index >= 0; --index)
     {
       if (Tracing.On)
         Tracing.Enter("SoapExtension", traceMethod2, new TraceMethod((object) extensions[index], "ProcessMessage", new object[1]
         {
           (object) this.stage
         }));
       extensions[index].ProcessMessage(this);
       if (Tracing.On)
         Tracing.Exit("SoapExtension", traceMethod2);
       if (this.Exception != null)
       {
         if (throwOnException)
           throw this.Exception;
         if (Tracing.On)
           Tracing.ExceptionIgnore(TraceEventType.Warning, traceMethod2, (Exception) this.Exception);
       }
     }
   }
 }
コード例 #25
0
        //
        // TODO:
        //    Handle other web responses (multi-output?)
        //
        object [] ReceiveResponse(WebResponse response, SoapClientMessage message, SoapExtension[] extensions)
        {
            SoapMethodStubInfo msi           = message.MethodStubInfo;
            HttpWebResponse    http_response = response as HttpWebResponse;

            if (http_response != null)
            {
                HttpStatusCode code = http_response.StatusCode;

                if (!(code == HttpStatusCode.Accepted || code == HttpStatusCode.OK || code == HttpStatusCode.InternalServerError))
                {
                    string msg = "The request failed with HTTP status {0}: {1}";
                    msg = String.Format(msg, (int)code, code);
                    throw new WebException(msg, null, WebExceptionStatus.ProtocolError, http_response);
                }
                if (message.OneWay && response.ContentLength <= 0 && (code == HttpStatusCode.Accepted || code == HttpStatusCode.OK))
                {
                    return(new object[0]);
                }
            }

            //
            // Remove optional encoding
            //
            string   ctype;
            Encoding encoding = WebServiceHelper.GetContentEncoding(response.ContentType, out ctype);

            ctype = ctype.ToLower(CultureInfo.InvariantCulture);
            if ((!message.IsSoap12 || ctype != "application/soap+xml") && ctype != "text/xml")
            {
                WebServiceHelper.InvalidOperation(
                    String.Format("Not supported Content-Type in the response: '{0}'", response.ContentType),
                    response, encoding);
            }

            message.ContentType     = ctype;
            message.ContentEncoding = encoding.WebName;

            Stream stream = response.GetResponseStream();

            if (extensions != null)
            {
                stream = SoapExtension.ExecuteChainStream(extensions, stream);
                message.SetStage(SoapMessageStage.BeforeDeserialize);
                SoapExtension.ExecuteProcessMessage(extensions, message, stream, false);
            }

            // Deserialize the response

            SoapHeaderCollection headers;
            object content;

            using (StreamReader reader = new StreamReader(stream, encoding, false)) {
                XmlTextReader xml_reader = new XmlTextReader(reader);

                WebServiceHelper.ReadSoapMessage(xml_reader, msi, SoapHeaderDirection.Out, message.IsSoap12, out content, out headers);
            }

            if (content is Soap12Fault)
            {
                SoapException ex = WebServiceHelper.Soap12FaultToSoapException((Soap12Fault)content);
                message.SetException(ex);
            }
            else
            if (content is Fault)
            {
                Fault         fault = (Fault)content;
                SoapException ex    = new SoapException(fault.faultstring, fault.faultcode, fault.faultactor, fault.detail);
                message.SetException(ex);
            }
            else
            {
                message.OutParameters = (object[])content;
            }

            message.SetHeaders(headers);
            message.UpdateHeaderValues(this, message.MethodStubInfo.Headers);

            if (extensions != null)
            {
                message.SetStage(SoapMessageStage.AfterDeserialize);
                SoapExtension.ExecuteProcessMessage(extensions, message, stream, false);
            }

            if (message.Exception == null)
            {
                return(message.OutParameters);
            }
            else
            {
                throw message.Exception;
            }
        }
コード例 #26
0
 internal void InitExtensionStreamChain(SoapExtension[] extensions)
 {
     if (extensions != null)
     {
         for (int i = 0; i < extensions.Length; i++)
         {
             this.stream = extensions[i].ChainStream(this.stream);
         }
     }
 }
コード例 #27
0
 internal void RunExtensions(SoapExtension[] extensions, bool throwOnException)
 {
     if (extensions != null)
     {
         TraceMethod caller = Tracing.On ? new TraceMethod(this, "RunExtensions", new object[] { extensions, throwOnException }) : null;
         if ((this.stage & (SoapMessageStage.AfterDeserialize | SoapMessageStage.BeforeDeserialize)) != ((SoapMessageStage) 0))
         {
             for (int i = 0; i < extensions.Length; i++)
             {
                 if (Tracing.On)
                 {
                     Tracing.Enter("SoapExtension", caller, new TraceMethod(extensions[i], "ProcessMessage", new object[] { this.stage }));
                 }
                 extensions[i].ProcessMessage(this);
                 if (Tracing.On)
                 {
                     Tracing.Exit("SoapExtension", caller);
                 }
                 if (this.Exception != null)
                 {
                     if (throwOnException)
                     {
                         throw this.Exception;
                     }
                     if (Tracing.On)
                     {
                         Tracing.ExceptionIgnore(TraceEventType.Warning, caller, this.Exception);
                     }
                 }
             }
         }
         else
         {
             for (int j = extensions.Length - 1; j >= 0; j--)
             {
                 if (Tracing.On)
                 {
                     Tracing.Enter("SoapExtension", caller, new TraceMethod(extensions[j], "ProcessMessage", new object[] { this.stage }));
                 }
                 extensions[j].ProcessMessage(this);
                 if (Tracing.On)
                 {
                     Tracing.Exit("SoapExtension", caller);
                 }
                 if (this.Exception != null)
                 {
                     if (throwOnException)
                     {
                         throw this.Exception;
                     }
                     if (Tracing.On)
                     {
                         Tracing.ExceptionIgnore(TraceEventType.Warning, caller, this.Exception);
                     }
                 }
             }
         }
     }
 }
コード例 #28
0
ファイル: SoapServerProtocol.cs プロジェクト: nobled/mono
		protected virtual SoapExtension [] ModifyInitializedExtensions (
			PriorityGroup group, SoapExtension [] extensions)
		{
			throw new NotImplementedException ();
		}
コード例 #29
0
ファイル: SoapMessage.cs プロジェクト: consumentor/Server
 internal static SoapExtension[] InitializeExtensions(SoapReflectedExtension[] reflectedExtensions, object[] extensionInitializers)
 {
   if (reflectedExtensions == null)
     return (SoapExtension[]) null;
   SoapExtension[] soapExtensionArray = new SoapExtension[reflectedExtensions.Length];
   for (int index = 0; index < soapExtensionArray.Length; ++index)
     soapExtensionArray[index] = reflectedExtensions[index].CreateInstance(extensionInitializers[index]);
   return soapExtensionArray;
 }
コード例 #30
0
        //
        // Constructor
        //
        public SoapMethodStubInfo(TypeStubInfo typeStub, LogicalMethodInfo source, object kind, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter)
            : base(typeStub, source)
        {
            SoapTypeStubInfo    parent      = (SoapTypeStubInfo)typeStub;
            XmlElementAttribute optional_ns = null;

            if (kind == null)
            {
                Use               = parent.LogicalType.BindingUse;
                RequestName       = "";
                RequestNamespace  = "";
                ResponseName      = "";
                ResponseNamespace = "";
                ParameterStyle    = parent.ParameterStyle;
                SoapBindingStyle  = parent.SoapBindingStyle;
                OneWay            = false;
// disabled (see bug #332150)
//#if NET_2_0
//				if (parent.Type != source.DeclaringType)
//					Binding = source.DeclaringType.Name + parent.ProtocolName;
//#endif
            }
            else if (kind is SoapDocumentMethodAttribute)
            {
                SoapDocumentMethodAttribute dma = (SoapDocumentMethodAttribute)kind;

                Use = dma.Use;
                if (Use == SoapBindingUse.Default)
                {
                    if (parent.SoapBindingStyle == SoapBindingStyle.Document)
                    {
                        Use = parent.LogicalType.BindingUse;
                    }
                    else
                    {
                        Use = SoapBindingUse.Literal;
                    }
                }

                Action            = dma.Action;
                Binding           = dma.Binding;
                RequestName       = dma.RequestElementName;
                RequestNamespace  = dma.RequestNamespace;
                ResponseName      = dma.ResponseElementName;
                ResponseNamespace = dma.ResponseNamespace;
                ParameterStyle    = dma.ParameterStyle;
                if (ParameterStyle == SoapParameterStyle.Default)
                {
                    ParameterStyle = parent.ParameterStyle;
                }
                OneWay           = dma.OneWay;
                SoapBindingStyle = SoapBindingStyle.Document;
            }
            else
            {
                SoapRpcMethodAttribute rma = (SoapRpcMethodAttribute)kind;
                Use = SoapBindingUse.Encoded;                   // RPC always use encoded

                Action = rma.Action;
                if (Action != null && Action.Length == 0)
                {
                    Action = null;
                }
                Binding = rma.Binding;

                // When using RPC, MS.NET seems to ignore RequestElementName and
                // MessageName, and it always uses the method name
                RequestName  = source.Name;
                ResponseName = source.Name + "Response";
//				RequestName = rma.RequestElementName;
//				ResponseName = rma.ResponseElementName;
                RequestNamespace  = rma.RequestNamespace;
                ResponseNamespace = rma.ResponseNamespace;
                ParameterStyle    = SoapParameterStyle.Wrapped;
                OneWay            = rma.OneWay;
                SoapBindingStyle  = SoapBindingStyle.Rpc;

                // For RPC calls, make all arguments be part of the empty namespace
                optional_ns           = new XmlElementAttribute();
                optional_ns.Namespace = "";
            }

            if (OneWay)
            {
                if (source.ReturnType != typeof(void))
                {
                    throw new Exception("OneWay methods should not have a return value.");
                }
                if (source.OutParameters.Length != 0)
                {
                    throw new Exception("OneWay methods should not have out/ref parameters.");
                }
            }

            BindingInfo binfo = parent.GetBinding(Binding);

            if (binfo == null)
            {
                throw new InvalidOperationException("Type '" + parent.Type + "' is missing WebServiceBinding attribute that defines a binding named '" + Binding + "'.");
            }

            string serviceNamespace = binfo.Namespace;

            if (RequestNamespace == "")
            {
                RequestNamespace = parent.LogicalType.GetWebServiceNamespace(serviceNamespace, Use);
            }
            if (ResponseNamespace == "")
            {
                ResponseNamespace = parent.LogicalType.GetWebServiceNamespace(serviceNamespace, Use);
            }
            if (RequestName == "")
            {
                RequestName = Name;
            }
            if (ResponseName == "")
            {
                ResponseName = Name + "Response";
            }
            if (Action == null)
            {
                Action = serviceNamespace.EndsWith("/") ? (serviceNamespace + Name) : (serviceNamespace + "/" + Name);
            }

            bool hasWrappingElem = (ParameterStyle == SoapParameterStyle.Wrapped);
            bool writeAccessors  = (SoapBindingStyle == SoapBindingStyle.Rpc);

            XmlReflectionMember [] in_members  = BuildRequestReflectionMembers(optional_ns);
            XmlReflectionMember [] out_members = BuildResponseReflectionMembers(optional_ns);

            if (Use == SoapBindingUse.Literal)
            {
                xmlImporter.IncludeTypes(source.CustomAttributeProvider);
                InputMembersMapping  = xmlImporter.ImportMembersMapping(RequestName, RequestNamespace, in_members, hasWrappingElem);
                OutputMembersMapping = xmlImporter.ImportMembersMapping(ResponseName, ResponseNamespace, out_members, hasWrappingElem);
            }
            else
            {
                soapImporter.IncludeTypes(source.CustomAttributeProvider);
                InputMembersMapping  = soapImporter.ImportMembersMapping(RequestName, RequestNamespace, in_members, hasWrappingElem, writeAccessors);
                OutputMembersMapping = soapImporter.ImportMembersMapping(ResponseName, ResponseNamespace, out_members, hasWrappingElem, writeAccessors);
            }

            requestSerializerId  = parent.RegisterSerializer(InputMembersMapping);
            responseSerializerId = parent.RegisterSerializer(OutputMembersMapping);

            object[]  o               = source.GetCustomAttributes(typeof(SoapHeaderAttribute));
            ArrayList allHeaderList   = new ArrayList(o.Length);
            ArrayList inHeaderList    = new ArrayList(o.Length);
            ArrayList outHeaderList   = new ArrayList(o.Length);
            ArrayList faultHeaderList = new ArrayList();

            SoapHeaderDirection unknownHeaderDirections = (SoapHeaderDirection)0;

            for (int i = 0; i < o.Length; i++)
            {
                SoapHeaderAttribute att  = (SoapHeaderAttribute)o[i];
                MemberInfo[]        mems = source.DeclaringType.GetMember(att.MemberName);
                if (mems.Length == 0)
                {
                    throw new InvalidOperationException("Member " + att.MemberName + " not found in class " + source.DeclaringType.FullName + ".");
                }

                HeaderInfo header = new HeaderInfo(mems[0], att);
                allHeaderList.Add(header);
                if (!header.Custom)
                {
                    if ((header.Direction & SoapHeaderDirection.In) != 0)
                    {
                        inHeaderList.Add(header);
                    }
                    if ((header.Direction & SoapHeaderDirection.Out) != 0)
                    {
                        outHeaderList.Add(header);
                    }
                    if ((header.Direction & SoapHeaderDirection.Fault) != 0)
                    {
                        faultHeaderList.Add(header);
                    }
                }
                else
                {
                    unknownHeaderDirections |= header.Direction;
                }
            }

            Headers = (HeaderInfo[])allHeaderList.ToArray(typeof(HeaderInfo));

            if (inHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.In) != 0)
            {
                InHeaders = (HeaderInfo[])inHeaderList.ToArray(typeof(HeaderInfo));
                XmlReflectionMember[] members = BuildHeadersReflectionMembers(InHeaders);

                if (Use == SoapBindingUse.Literal)
                {
                    InputHeaderMembersMapping = xmlImporter.ImportMembersMapping("", RequestNamespace, members, false);
                }
                else
                {
                    InputHeaderMembersMapping = soapImporter.ImportMembersMapping("", RequestNamespace, members, false, false);
                }

                requestHeadersSerializerId = parent.RegisterSerializer(InputHeaderMembersMapping);
            }

            if (outHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Out) != 0)
            {
                OutHeaders = (HeaderInfo[])outHeaderList.ToArray(typeof(HeaderInfo));
                XmlReflectionMember[] members = BuildHeadersReflectionMembers(OutHeaders);

                if (Use == SoapBindingUse.Literal)
                {
                    OutputHeaderMembersMapping = xmlImporter.ImportMembersMapping("", RequestNamespace, members, false);
                }
                else
                {
                    OutputHeaderMembersMapping = soapImporter.ImportMembersMapping("", RequestNamespace, members, false, false);
                }

                responseHeadersSerializerId = parent.RegisterSerializer(OutputHeaderMembersMapping);
            }

            if (faultHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Fault) != 0)
            {
                FaultHeaders = (HeaderInfo[])faultHeaderList.ToArray(typeof(HeaderInfo));
                XmlReflectionMember[] members = BuildHeadersReflectionMembers(FaultHeaders);

                if (Use == SoapBindingUse.Literal)
                {
                    FaultHeaderMembersMapping = xmlImporter.ImportMembersMapping("", RequestNamespace, members, false);
                }
                else
                {
                    FaultHeaderMembersMapping = soapImporter.ImportMembersMapping("", RequestNamespace, members, false, false);
                }

                faultHeadersSerializerId = parent.RegisterSerializer(FaultHeaderMembersMapping);
            }

            SoapExtensions = SoapExtension.GetMethodExtensions(source);
        }
コード例 #31
0
ファイル: helper.cs プロジェクト: sfsergey/knowledgetree
        public object[] ReceiveResponse(WebResponse response, SoapClientMessage message, SoapExtension[] extensions)
        {
            StreamReader sr = new StreamReader(response.GetResponseStream());
            String content = sr.ReadToEnd();
            System.Console.WriteLine(content);

            return null;
        }
コード例 #32
0
ファイル: SoapExtension.cs プロジェクト: Profit0004/mono
		internal static Stream ExecuteChainStream (SoapExtension[] extensions, Stream stream)
		{
			if (extensions == null) return stream;

			Stream newStream = stream;
			foreach (SoapExtension ext in extensions)
				newStream = ext.ChainStream (newStream);
			return newStream;
		}
コード例 #33
0
        SoapServerMessage DeserializeRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            Stream      stream  = request.InputStream;

            //using (stream)
            //{
            string   soapAction = null;
            string   ctype;
            Encoding encoding = WebServiceHelper.GetContentEncoding(request.ContentType, out ctype);

            if (ctype != "text/xml" && ctype != "application/soap+xml")
            {
                throw new WebException("Content is not XML: " + ctype);
            }

            object server = CreateServerInstance();

            SoapServerMessage message = new SoapServerMessage(request, server, stream);

            message.SetStage(SoapMessageStage.BeforeDeserialize);
            message.ContentType = ctype;
            object soapVer = context.Items ["WebServiceSoapVersion"];

            if (soapVer != null)
            {
                message.SetSoapVersion((SoapProtocolVersion)soapVer);
            }

            // If the routing style is SoapAction, then we can get the method information now
            // and set it to the SoapMessage

            if (_typeStubInfo.RoutingStyle == SoapServiceRoutingStyle.SoapAction)
            {
                string headerName = message.IsSoap12 ? "action" : "SOAPAction";
                soapAction = message.IsSoap12 ? WebServiceHelper.GetContextAction(request.ContentType) : request.Headers [headerName];
                if (soapAction == null)
                {
                    if (!message.IsSoap12)
                    {
                        throw new SoapException("Missing SOAPAction header", WebServiceHelper.ClientFaultCode(message.IsSoap12));
                    }
                }
                else
                {
                    methodInfo = _typeStubInfo.GetMethodForSoapAction(soapAction);
                    if (methodInfo == null)
                    {
                        throw new SoapException("Server did not recognize the value of HTTP header " + headerName + ": " + soapAction, WebServiceHelper.ClientFaultCode(message.IsSoap12));
                    }
                    message.MethodStubInfo = methodInfo;
                }
            }

            // Execute the high priority global extensions. Do not try to execute the medium and
            // low priority extensions because if the routing style is RequestElement we still
            // don't have method information

            _extensionChainHighPrio = SoapExtension.CreateExtensionChain(_typeStubInfo.SoapExtensions[0]);
            stream = SoapExtension.ExecuteChainStream(_extensionChainHighPrio, stream);
            SoapExtension.ExecuteProcessMessage(_extensionChainHighPrio, message, stream, false);

            // If the routing style is RequestElement, try to get the method name from the
            // stream processed by the high priority extensions

            if (_typeStubInfo.RoutingStyle == SoapServiceRoutingStyle.RequestElement || (message.IsSoap12 && soapAction == null))
            {
                MemoryStream mstream;
                byte[]       buffer = null;

                if (stream.CanSeek)
                {
                    buffer = new byte [stream.Length];
                    for (int n = 0; n < stream.Length;)
                    {
                        n += stream.Read(buffer, n, (int)stream.Length - n);
                    }
                    mstream = new MemoryStream(buffer);
                }
                else
                {
                    buffer  = new byte [500];
                    mstream = new MemoryStream();

                    int len;
                    while ((len = stream.Read(buffer, 0, 500)) > 0)
                    {
                        mstream.Write(buffer, 0, len);
                    }
                    mstream.Position = 0;
                    buffer           = mstream.ToArray();
                }

                soapAction = ReadActionFromRequestElement(new MemoryStream(buffer), encoding, message.IsSoap12);

                stream                 = mstream;
                methodInfo             = (SoapMethodStubInfo)_typeStubInfo.GetMethod(soapAction);
                message.MethodStubInfo = methodInfo;
            }

            // Whatever routing style we used, we should now have the method information.
            // We can now notify the remaining extensions

            if (methodInfo == null)
            {
                throw new SoapException("Method '" + soapAction + "' not defined in the web service '" + _typeStubInfo.LogicalType.WebServiceName + "'", WebServiceHelper.ClientFaultCode(message.IsSoap12));
            }

            _extensionChainMedPrio = SoapExtension.CreateExtensionChain(methodInfo.SoapExtensions);
            _extensionChainLowPrio = SoapExtension.CreateExtensionChain(_typeStubInfo.SoapExtensions[1]);

            stream = SoapExtension.ExecuteChainStream(_extensionChainMedPrio, stream);
            stream = SoapExtension.ExecuteChainStream(_extensionChainLowPrio, stream);
            SoapExtension.ExecuteProcessMessage(_extensionChainMedPrio, message, stream, false);
            SoapExtension.ExecuteProcessMessage(_extensionChainLowPrio, message, stream, false);

            // Deserialize the request

            StreamReader  reader    = new StreamReader(stream, encoding, false);
            XmlTextReader xmlReader = new XmlTextReader(reader);

            try
            {
                object content;
                SoapHeaderCollection headers;
                WebServiceHelper.ReadSoapMessage(xmlReader, methodInfo, SoapHeaderDirection.In, message.IsSoap12, out content, out headers);
                message.InParameters = (object [])content;
                message.SetHeaders(headers);
            }
            catch (Exception ex)
            {
                throw new SoapException("Could not deserialize Soap message", WebServiceHelper.ClientFaultCode(message.IsSoap12), ex);
            }

            // Notify the extensions after deserialization

            message.SetStage(SoapMessageStage.AfterDeserialize);
            SoapExtension.ExecuteProcessMessage(_extensionChainHighPrio, message, stream, false);
            SoapExtension.ExecuteProcessMessage(_extensionChainMedPrio, message, stream, false);
            SoapExtension.ExecuteProcessMessage(_extensionChainLowPrio, message, stream, false);

            return(message);
            //}
        }
コード例 #34
0
 internal static SoapExtension[] InitializeExtensions(SoapReflectedExtension[] reflectedExtensions, object[] extensionInitializers) {
     if (reflectedExtensions == null)
         return null;
     SoapExtension[] extensions = new SoapExtension[reflectedExtensions.Length];
     for (int i = 0; i < extensions.Length; i++) {
         extensions[i] = reflectedExtensions[i].CreateInstance(extensionInitializers[i]);
     }
     return extensions;
 }
コード例 #35
0
        internal object GetInitializer(LogicalMethodInfo methodInfo)
        {
            SoapExtension extension = (SoapExtension)Activator.CreateInstance(this.type);

            return(extension.GetInitializer(methodInfo, this.attribute));
        }
コード例 #36
0
ファイル: SoapExtension.cs プロジェクト: Profit0004/mono
		static int CreateExtensionChain (SoapExtensionRuntimeConfig[] extensionConfigs, SoapExtension[] destArray, int pos)
		{
			for (int n=0; n<extensionConfigs.Length; n++)
			{
				SoapExtensionRuntimeConfig econf = extensionConfigs [n];
				SoapExtension ext = (SoapExtension) Activator.CreateInstance (econf.Type);
				ext.Initialize (econf.InitializationInfo);
				destArray [pos++] = ext;
			}
			return pos;
		}
コード例 #37
0
 internal void InitExtensionStreamChain(SoapExtension[] extensions) {
     if (extensions == null)
         return;
     for (int i = 0; i < extensions.Length; i++) {
         stream = extensions[i].ChainStream(stream);
     }
 }
コード例 #38
0
		//
		// TODO:
		//    Handle other web responses (multi-output?)
		//    
		object [] ReceiveResponse (WebResponse response, SoapClientMessage message, SoapExtension[] extensions)
		{
			SoapMethodStubInfo msi = message.MethodStubInfo;
			HttpWebResponse http_response = response as HttpWebResponse;
			
			if (http_response != null)
			{
				HttpStatusCode code = http_response.StatusCode;
	
				if (!(code == HttpStatusCode.Accepted || code == HttpStatusCode.OK || code == HttpStatusCode.InternalServerError)) {
					string msg = "The request failed with HTTP status {0}: {1}";
					msg = String.Format (msg, (int) code, code);
					throw new WebException (msg, null, WebExceptionStatus.ProtocolError, http_response);
				}
				if (message.OneWay && response.ContentLength == 0 && (code == HttpStatusCode.Accepted || code == HttpStatusCode.OK)) {
					return new object[0];
				}
			}
			
			//
			// Remove optional encoding
			//
			string ctype;
			Encoding encoding = WebServiceHelper.GetContentEncoding (response.ContentType, out ctype);
			if (ctype != "text/xml")
				WebServiceHelper.InvalidOperation (
					"Content is not 'text/xml' but '" + response.ContentType + "'",
					response, encoding);

			message.ContentType = ctype;
			message.ContentEncoding = encoding.WebName;
			
			Stream stream = response.GetResponseStream ();

			if (extensions != null) {
				stream = SoapExtension.ExecuteChainStream (extensions, stream);
				message.SetStage (SoapMessageStage.BeforeDeserialize);
				SoapExtension.ExecuteProcessMessage (extensions, message, false);
			}
			
			// Deserialize the response

			SoapHeaderCollection headers;
			object content;

			using (StreamReader reader = new StreamReader (stream, encoding, false)) {
				XmlTextReader xml_reader = new XmlTextReader (reader);

				WebServiceHelper.ReadSoapMessage (xml_reader, type_info, msi.Use, msi.ResponseSerializer,
								out content, out headers);
			}

			
			if (content is Fault)
			{
				Fault fault = (Fault) content;
				SoapException ex = new SoapException (fault.faultstring, fault.faultcode, fault.faultactor, fault.detail);
				message.SetException (ex);
			}
			else
				message.OutParameters = (object[]) content;
			
			message.SetHeaders (headers);
			message.UpdateHeaderValues (this, message.MethodStubInfo.Headers);

			if (extensions != null) {
				message.SetStage (SoapMessageStage.AfterDeserialize);
				SoapExtension.ExecuteProcessMessage (extensions, message, false);
			}

			if (message.Exception == null)
				return message.OutParameters;
			else
				throw message.Exception;
		}
コード例 #39
0
        internal void RunExtensions(SoapExtension[] extensions, bool throwOnException) {
            if (extensions == null)
                return;

            TraceMethod caller = Tracing.On ? new TraceMethod(this, "RunExtensions", extensions, throwOnException) : null;

            // Higher priority extensions (earlier in the list) run earlier for deserialization stages,
            // and later for serialization stages
            if ((stage & (SoapMessageStage.BeforeDeserialize | SoapMessageStage.AfterDeserialize)) != 0) {
                for (int i = 0; i < extensions.Length; i++) {
                    if (Tracing.On) Tracing.Enter("SoapExtension", caller, new TraceMethod(extensions[i], "ProcessMessage", stage));
                    extensions[i].ProcessMessage(this);
                    if (Tracing.On) Tracing.Exit("SoapExtension", caller);
                    if (Exception != null) {
                        if (throwOnException)
                            throw Exception;
                        if (Tracing.On) Tracing.ExceptionIgnore(TraceEventType.Warning, caller, Exception);
                    }
                }
            }
            else {
                for (int i = extensions.Length - 1; i >= 0; i--) {
                    if (Tracing.On) Tracing.Enter("SoapExtension", caller, new TraceMethod(extensions[i], "ProcessMessage", stage));
                    extensions[i].ProcessMessage(this);
                    if (Tracing.On) Tracing.Exit("SoapExtension", caller);
                    if (Exception != null) {
                        if (throwOnException)
                            throw Exception;
                        if (Tracing.On) Tracing.ExceptionIgnore(TraceEventType.Warning, caller, Exception);
                    }
                }
            }
        }