示例#1
0
        private SoapClientMessage BeforeSerialize(WebRequest request, string methodName, object[] parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            SoapClientMethod method = this.clientType.GetMethod(methodName);

            if (method == null)
            {
                throw new ArgumentException(System.Web.Services.Res.GetString("WebInvalidMethodName", new object[1]
                {
                    (object)methodName
                }));
            }
            else
            {
                SoapExtension[]   soapExtensionArray = SoapMessage.InitializeExtensions((SoapReflectedExtension[])SoapHttpClientProtocol.CombineExtensionsHelper((Array)this.clientType.HighPriExtensions, (Array)method.extensions, (Array)this.clientType.LowPriExtensions, typeof(SoapReflectedExtension)), (object[])SoapHttpClientProtocol.CombineExtensionsHelper((Array)this.clientType.HighPriExtensionInitializers, (Array)method.extensionInitializers, (Array)this.clientType.LowPriExtensionInitializers, typeof(object)));
                SoapClientMessage soapClientMessage  = new SoapClientMessage(this, method, this.Url);
                soapClientMessage.initializedExtensions = soapExtensionArray;
                if (soapExtensionArray != null)
                {
                    soapClientMessage.SetExtensionStream(new SoapExtensionStream());
                }
                soapClientMessage.InitExtensionStreamChain(soapClientMessage.initializedExtensions);
                string action = UrlEncoder.EscapeString(method.action, Encoding.UTF8);
                soapClientMessage.SetStage(SoapMessageStage.BeforeSerialize);
                if (this.version == SoapProtocolVersion.Soap12)
                {
                    soapClientMessage.ContentType = ContentType.Compose("application/soap+xml", this.RequestEncoding != null ? this.RequestEncoding : Encoding.UTF8, action);
                }
                else
                {
                    soapClientMessage.ContentType = ContentType.Compose("text/xml", this.RequestEncoding != null ? this.RequestEncoding : Encoding.UTF8);
                }
                soapClientMessage.SetParameterValues(parameters);
                SoapHeaderHandling.GetHeaderMembers(soapClientMessage.Headers, (object)this, method.inHeaderMappings, SoapHeaderDirection.In, true);
                soapClientMessage.RunExtensions(soapClientMessage.initializedExtensions, true);
                request.ContentType = soapClientMessage.ContentType;
                if (soapClientMessage.ContentEncoding != null && soapClientMessage.ContentEncoding.Length > 0)
                {
                    ((NameValueCollection)request.Headers)["Content-Encoding"] = soapClientMessage.ContentEncoding;
                }
                request.Method = "POST";
                if (this.version != SoapProtocolVersion.Soap12 && ((NameValueCollection)request.Headers)["SOAPAction"] == null)
                {
                    StringBuilder stringBuilder = new StringBuilder(action.Length + 2);
                    stringBuilder.Append('"');
                    stringBuilder.Append(action);
                    stringBuilder.Append('"');
                    ((NameValueCollection)request.Headers).Add("SOAPAction", ((object)stringBuilder).ToString());
                }
                return(soapClientMessage);
            }
        }
示例#2
0
        private SoapClientMessage BeforeSerialize(WebRequest request, string methodName, object[] parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            SoapClientMethod method = this.clientType.GetMethod(methodName);

            if (method == null)
            {
                throw new ArgumentException(System.Web.Services.Res.GetString("WebInvalidMethodName", new object[] { methodName }));
            }
            SoapReflectedExtension[] reflectedExtensions = (SoapReflectedExtension[])CombineExtensionsHelper(this.clientType.HighPriExtensions, method.extensions, this.clientType.LowPriExtensions, typeof(SoapReflectedExtension));
            object[]          extensionInitializers      = (object[])CombineExtensionsHelper(this.clientType.HighPriExtensionInitializers, method.extensionInitializers, this.clientType.LowPriExtensionInitializers, typeof(object));
            SoapExtension[]   extensionArray2            = SoapMessage.InitializeExtensions(reflectedExtensions, extensionInitializers);
            SoapClientMessage message = new SoapClientMessage(this, method, base.Url)
            {
                initializedExtensions = extensionArray2
            };

            if (extensionArray2 != null)
            {
                message.SetExtensionStream(new SoapExtensionStream());
            }
            message.InitExtensionStreamChain(message.initializedExtensions);
            string action = UrlEncoder.EscapeString(method.action, Encoding.UTF8);

            message.SetStage(SoapMessageStage.BeforeSerialize);
            if (this.version == SoapProtocolVersion.Soap12)
            {
                message.ContentType = ContentType.Compose("application/soap+xml", (base.RequestEncoding != null) ? base.RequestEncoding : Encoding.UTF8, action);
            }
            else
            {
                message.ContentType = ContentType.Compose("text/xml", (base.RequestEncoding != null) ? base.RequestEncoding : Encoding.UTF8);
            }
            message.SetParameterValues(parameters);
            SoapHeaderHandling.GetHeaderMembers(message.Headers, this, method.inHeaderMappings, SoapHeaderDirection.In, true);
            message.RunExtensions(message.initializedExtensions, true);
            request.ContentType = message.ContentType;
            if ((message.ContentEncoding != null) && (message.ContentEncoding.Length > 0))
            {
                request.Headers["Content-Encoding"] = message.ContentEncoding;
            }
            request.Method = "POST";
            if ((this.version != SoapProtocolVersion.Soap12) && (request.Headers["SOAPAction"] == null))
            {
                StringBuilder builder = new StringBuilder(action.Length + 2);
                builder.Append('"');
                builder.Append(action);
                builder.Append('"');
                request.Headers.Add("SOAPAction", builder.ToString());
            }
            return(message);
        }
 private SoapClientMessage BeforeSerialize(WebRequest request, string methodName, object[] parameters)
 {
     if (parameters == null)
     {
         throw new ArgumentNullException("parameters");
     }
     SoapClientMethod method = this.clientType.GetMethod(methodName);
     if (method == null)
     {
         throw new ArgumentException(System.Web.Services.Res.GetString("WebInvalidMethodName", new object[] { methodName }));
     }
     SoapReflectedExtension[] reflectedExtensions = (SoapReflectedExtension[]) CombineExtensionsHelper(this.clientType.HighPriExtensions, method.extensions, this.clientType.LowPriExtensions, typeof(SoapReflectedExtension));
     object[] extensionInitializers = (object[]) CombineExtensionsHelper(this.clientType.HighPriExtensionInitializers, method.extensionInitializers, this.clientType.LowPriExtensionInitializers, typeof(object));
     SoapExtension[] extensionArray2 = SoapMessage.InitializeExtensions(reflectedExtensions, extensionInitializers);
     SoapClientMessage message = new SoapClientMessage(this, method, base.Url) {
         initializedExtensions = extensionArray2
     };
     if (extensionArray2 != null)
     {
         message.SetExtensionStream(new SoapExtensionStream());
     }
     message.InitExtensionStreamChain(message.initializedExtensions);
     string action = UrlEncoder.EscapeString(method.action, Encoding.UTF8);
     message.SetStage(SoapMessageStage.BeforeSerialize);
     if (this.version == SoapProtocolVersion.Soap12)
     {
         message.ContentType = ContentType.Compose("application/soap+xml", (base.RequestEncoding != null) ? base.RequestEncoding : Encoding.UTF8, action);
     }
     else
     {
         message.ContentType = ContentType.Compose("text/xml", (base.RequestEncoding != null) ? base.RequestEncoding : Encoding.UTF8);
     }
     message.SetParameterValues(parameters);
     SoapHeaderHandling.GetHeaderMembers(message.Headers, this, method.inHeaderMappings, SoapHeaderDirection.In, true);
     message.RunExtensions(message.initializedExtensions, true);
     request.ContentType = message.ContentType;
     if ((message.ContentEncoding != null) && (message.ContentEncoding.Length > 0))
     {
         request.Headers["Content-Encoding"] = message.ContentEncoding;
     }
     request.Method = "POST";
     if ((this.version != SoapProtocolVersion.Soap12) && (request.Headers["SOAPAction"] == null))
     {
         StringBuilder builder = new StringBuilder(action.Length + 2);
         builder.Append('"');
         builder.Append(action);
         builder.Append('"');
         request.Headers.Add("SOAPAction", builder.ToString());
     }
     return message;
 }
        SoapClientMessage BeforeSerialize(WebRequest request, string methodName, object[] parameters) {
            if (parameters == null) throw new ArgumentNullException("parameters");
            SoapClientMethod method = clientType.GetMethod(methodName);
            if (method == null) throw new ArgumentException(Res.GetString(Res.WebInvalidMethodName, methodName));            

            // Run BeforeSerialize extension pass. Extensions are not allowed
            // to write into the stream during this pass.
            SoapReflectedExtension[] allExtensions = (SoapReflectedExtension[])CombineExtensionsHelper(clientType.HighPriExtensions, method.extensions, clientType.LowPriExtensions, typeof(SoapReflectedExtension));
            object[] allExtensionInitializers = (object[])CombineExtensionsHelper(clientType.HighPriExtensionInitializers, method.extensionInitializers, clientType.LowPriExtensionInitializers, typeof(object));
            SoapExtension[] initializedExtensions = SoapMessage.InitializeExtensions(allExtensions, allExtensionInitializers);
            SoapClientMessage message = new SoapClientMessage(this, method, Url);
            message.initializedExtensions = initializedExtensions;
            if (initializedExtensions != null)
                message.SetExtensionStream(new SoapExtensionStream());
            message.InitExtensionStreamChain(message.initializedExtensions);            

            string soapAction = UrlEncoder.EscapeString(method.action, Encoding.UTF8);
            message.SetStage(SoapMessageStage.BeforeSerialize);
            if (this.version == SoapProtocolVersion.Soap12)
                message.ContentType = ContentType.Compose(ContentType.ApplicationSoap, RequestEncoding != null ? RequestEncoding : Encoding.UTF8, soapAction);
            else
                message.ContentType = ContentType.Compose(ContentType.TextXml, RequestEncoding != null ? RequestEncoding : Encoding.UTF8);
            message.SetParameterValues(parameters);
            SoapHeaderHandling.GetHeaderMembers(message.Headers, this, method.inHeaderMappings, SoapHeaderDirection.In, true);
            message.RunExtensions(message.initializedExtensions, true);

            // Last chance to set request headers            
            request.ContentType = message.ContentType;
            if (message.ContentEncoding != null && message.ContentEncoding.Length > 0)
                request.Headers[ContentType.ContentEncoding] = message.ContentEncoding;

            request.Method = "POST";
            if (this.version != SoapProtocolVersion.Soap12 && request.Headers[Soap.Action] == null) {
                StringBuilder actionStringBuilder = new StringBuilder(soapAction.Length + 2);            
                actionStringBuilder.Append('"');
                actionStringBuilder.Append(soapAction);
                actionStringBuilder.Append('"');
                request.Headers.Add(Soap.Action, actionStringBuilder.ToString());                
            }

            return message;
        }
示例#5
0
        SoapClientMessage BeforeSerialize(WebRequest request, string methodName, object[] parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            SoapClientMethod method = clientType.GetMethod(methodName);

            if (method == null)
            {
                throw new ArgumentException(Res.GetString(Res.WebInvalidMethodName, methodName));
            }

            // Run BeforeSerialize extension pass. Extensions are not allowed
            // to write into the stream during this pass.
            SoapReflectedExtension[] allExtensions     = (SoapReflectedExtension[])CombineExtensionsHelper(clientType.HighPriExtensions, method.extensions, clientType.LowPriExtensions, typeof(SoapReflectedExtension));
            object[]          allExtensionInitializers = (object[])CombineExtensionsHelper(clientType.HighPriExtensionInitializers, method.extensionInitializers, clientType.LowPriExtensionInitializers, typeof(object));
            SoapExtension[]   initializedExtensions    = SoapMessage.InitializeExtensions(allExtensions, allExtensionInitializers);
            SoapClientMessage message = new SoapClientMessage(this, method, Url);

            message.initializedExtensions = initializedExtensions;
            if (initializedExtensions != null)
            {
                message.SetExtensionStream(new SoapExtensionStream());
            }
            message.InitExtensionStreamChain(message.initializedExtensions);

            string soapAction = UrlEncoder.EscapeString(method.action, Encoding.UTF8);

            message.SetStage(SoapMessageStage.BeforeSerialize);
            if (this.version == SoapProtocolVersion.Soap12)
            {
                message.ContentType = ContentType.Compose(ContentType.ApplicationSoap, RequestEncoding != null ? RequestEncoding : Encoding.UTF8, soapAction);
            }
            else
            {
                message.ContentType = ContentType.Compose(ContentType.TextXml, RequestEncoding != null ? RequestEncoding : Encoding.UTF8);
            }
            message.SetParameterValues(parameters);
            SoapHeaderHandling.GetHeaderMembers(message.Headers, this, method.inHeaderMappings, SoapHeaderDirection.In, true);
            message.RunExtensions(message.initializedExtensions);

            // Last chance to set request headers
            request.ContentType = message.ContentType;
            if (message.ContentEncoding != null && message.ContentEncoding.Length > 0)
            {
                request.Headers[ContentType.ContentEncoding] = message.ContentEncoding;
            }

            request.Method = "POST";
            if (this.version != SoapProtocolVersion.Soap12 && request.Headers[Soap.Action] == null)
            {
                StringBuilder actionStringBuilder = new StringBuilder(soapAction.Length + 2);
                actionStringBuilder.Append('"');
                actionStringBuilder.Append(soapAction);
                actionStringBuilder.Append('"');
                request.Headers.Add(Soap.Action, actionStringBuilder.ToString());
            }

            return(message);
        }
 private SoapClientMessage BeforeSerialize(WebRequest request, string methodName, object[] parameters)
 {
   if (parameters == null)
     throw new ArgumentNullException("parameters");
   SoapClientMethod method = this.clientType.GetMethod(methodName);
   if (method == null)
   {
     throw new ArgumentException(System.Web.Services.Res.GetString("WebInvalidMethodName", new object[1]
     {
       (object) methodName
     }));
   }
   else
   {
     SoapExtension[] soapExtensionArray = SoapMessage.InitializeExtensions((SoapReflectedExtension[]) SoapHttpClientProtocol.CombineExtensionsHelper((Array) this.clientType.HighPriExtensions, (Array) method.extensions, (Array) this.clientType.LowPriExtensions, typeof (SoapReflectedExtension)), (object[]) SoapHttpClientProtocol.CombineExtensionsHelper((Array) this.clientType.HighPriExtensionInitializers, (Array) method.extensionInitializers, (Array) this.clientType.LowPriExtensionInitializers, typeof (object)));
     SoapClientMessage soapClientMessage = new SoapClientMessage(this, method, this.Url);
     soapClientMessage.initializedExtensions = soapExtensionArray;
     if (soapExtensionArray != null)
       soapClientMessage.SetExtensionStream(new SoapExtensionStream());
     soapClientMessage.InitExtensionStreamChain(soapClientMessage.initializedExtensions);
     string action = UrlEncoder.EscapeString(method.action, Encoding.UTF8);
     soapClientMessage.SetStage(SoapMessageStage.BeforeSerialize);
     if (this.version == SoapProtocolVersion.Soap12)
       soapClientMessage.ContentType = ContentType.Compose("application/soap+xml", this.RequestEncoding != null ? this.RequestEncoding : Encoding.UTF8, action);
     else
       soapClientMessage.ContentType = ContentType.Compose("text/xml", this.RequestEncoding != null ? this.RequestEncoding : Encoding.UTF8);
     soapClientMessage.SetParameterValues(parameters);
     SoapHeaderHandling.GetHeaderMembers(soapClientMessage.Headers, (object) this, method.inHeaderMappings, SoapHeaderDirection.In, true);
     soapClientMessage.RunExtensions(soapClientMessage.initializedExtensions, true);
     request.ContentType = soapClientMessage.ContentType;
     if (soapClientMessage.ContentEncoding != null && soapClientMessage.ContentEncoding.Length > 0)
       ((NameValueCollection) request.Headers)["Content-Encoding"] = soapClientMessage.ContentEncoding;
     request.Method = "POST";
     if (this.version != SoapProtocolVersion.Soap12 && ((NameValueCollection) request.Headers)["SOAPAction"] == null)
     {
       StringBuilder stringBuilder = new StringBuilder(action.Length + 2);
       stringBuilder.Append('"');
       stringBuilder.Append(action);
       stringBuilder.Append('"');
       ((NameValueCollection) request.Headers).Add("SOAPAction", ((object) stringBuilder).ToString());
     }
     return soapClientMessage;
   }
 }