internal override void Write(HttpResponse response, Stream outputStream, object returnValue) { Encoding encoding = new UTF8Encoding(false); response.ContentType = ContentType.Compose("text/xml", encoding); xmlSerializer.Serialize(new StreamWriter(outputStream, encoding), returnValue); }
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); } }
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); }
internal override bool WriteException(Exception e, Stream outputStream) { Response.Clear(); Response.ClearHeaders(); Response.ContentType = ContentType.Compose("text/plain", Encoding.UTF8); Response.StatusCode = (int)HttpStatusCode.InternalServerError; Response.StatusDescription = HttpWorkerRequest.GetStatusDescription(Response.StatusCode); StreamWriter writer = new StreamWriter(outputStream, new UTF8Encoding(false)); writer.WriteLine(GenerateFaultString(e, true)); writer.Flush(); return(true); }
internal override void WriteReturns(object[] returnValues, Stream outputStream) { string id = Request.QueryString["schema"]; Encoding encoding = new UTF8Encoding(false); if (id != null) { XmlSchema schema = serverType.GetSchema(id); if (schema == null) { throw new InvalidOperationException(Res.GetString(Res.WebSchemaNotFound)); } Response.ContentType = ContentType.Compose("text/xml", encoding); schema.Write(new StreamWriter(outputStream, encoding)); return; } id = Request.QueryString["wsdl"]; if (id != null) { ServiceDescription description = serverType.GetServiceDescription(id); if (description == null) { throw new InvalidOperationException(Res.GetString(Res.ServiceDescriptionWasNotFound0)); } Response.ContentType = ContentType.Compose("text/xml", encoding); description.Write(new StreamWriter(outputStream, encoding)); return; } string queryString = Request.QueryString[null]; if (queryString != null && string.Compare(queryString, "wsdl", true, CultureInfo.InvariantCulture) == 0) { Response.ContentType = ContentType.Compose("text/xml", encoding); serverType.Description.Write(new StreamWriter(outputStream, encoding)); return; } if (queryString != null && string.Compare(queryString, "disco", true, CultureInfo.InvariantCulture) == 0) { Response.ContentType = ContentType.Compose("text/xml", encoding); serverType.Disco.Write(new StreamWriter(outputStream, encoding)); return; } throw new InvalidOperationException(Res.GetString(Res.internalError0)); }
internal override void WriteReturns(object[] returnValues, Stream outputStream) { string id = base.Request.QueryString["schema"]; Encoding encoding = new UTF8Encoding(false); if (id != null) { XmlSchema schema = this.serverType.GetSchema(id); if (schema == null) { throw new InvalidOperationException(Res.GetString("WebSchemaNotFound")); } base.Response.ContentType = ContentType.Compose("text/xml", encoding); schema.Write(new StreamWriter(outputStream, encoding)); } else { id = base.Request.QueryString["wsdl"]; if (id != null) { ServiceDescription serviceDescription = this.serverType.GetServiceDescription(id); if (serviceDescription == null) { throw new InvalidOperationException(Res.GetString("ServiceDescriptionWasNotFound0")); } base.Response.ContentType = ContentType.Compose("text/xml", encoding); serviceDescription.Write(new StreamWriter(outputStream, encoding)); } else { string strA = base.Request.QueryString[null]; if ((strA != null) && (string.Compare(strA, "wsdl", StringComparison.OrdinalIgnoreCase) == 0)) { base.Response.ContentType = ContentType.Compose("text/xml", encoding); this.serverType.Description.Write(new StreamWriter(outputStream, encoding)); } else { if ((strA == null) || (string.Compare(strA, "disco", StringComparison.OrdinalIgnoreCase) != 0)) { throw new InvalidOperationException(Res.GetString("internalError0")); } base.Response.ContentType = ContentType.Compose("text/xml", encoding); this.serverType.Disco.Write(new StreamWriter(outputStream, encoding)); } } } }
internal override void Write(HttpResponse response, Stream outputStream, object returnValue) { Encoding encoding = new UTF8Encoding(false); response.ContentType = ContentType.Compose("text/xml", encoding); StreamWriter writer = new StreamWriter(outputStream, encoding); TraceMethod caller = Tracing.On ? new TraceMethod(this, "Write", new object[0]) : null; if (Tracing.On) { Tracing.Enter(Tracing.TraceId("TraceWriteResponse"), caller, new TraceMethod(this.xmlSerializer, "Serialize", new object[] { writer, returnValue })); } this.xmlSerializer.Serialize((TextWriter)writer, returnValue); if (Tracing.On) { Tracing.Exit(Tracing.TraceId("TraceWriteResponse"), caller); } }
internal override bool WriteException(Exception e, Stream outputStream) { Response.Clear(); Response.ClearHeaders(); Response.ContentType = ContentType.Compose("text/plain", Encoding.UTF8); SetHttpResponseStatusCode(Response, (int)HttpStatusCode.InternalServerError); Response.StatusDescription = HttpWorkerRequest.GetStatusDescription(Response.StatusCode); StreamWriter writer = new StreamWriter(outputStream, new UTF8Encoding(false)); if (System.Web.Services.Configuration.WebServicesSection.Current.Diagnostics.SuppressReturningExceptions) { writer.WriteLine(Res.GetString(Res.WebSuppressedExceptionMessage)); } else { writer.WriteLine(GenerateFaultString(e, true)); } writer.Flush(); return(true); }
internal override bool WriteException(Exception e, Stream outputStream) { base.Response.Clear(); base.Response.ClearHeaders(); base.Response.ContentType = ContentType.Compose("text/plain", Encoding.UTF8); ServerProtocol.SetHttpResponseStatusCode(base.Response, 500); base.Response.StatusDescription = HttpWorkerRequest.GetStatusDescription(base.Response.StatusCode); StreamWriter writer = new StreamWriter(outputStream, new UTF8Encoding(false)); if (WebServicesSection.Current.Diagnostics.SuppressReturningExceptions) { writer.WriteLine(Res.GetString("WebSuppressedExceptionMessage")); } else { writer.WriteLine(base.GenerateFaultString(e, true)); } writer.Flush(); return(true); }
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); }
internal override void WriteReturns(object[] returnValues, Stream outputStream) { if (!this.serverMethod.oneWay) { bool isEncoded = this.serverMethod.use == SoapBindingUse.Encoded; SoapHeaderHandling.EnsureHeadersUnderstood(this.message.Headers); this.message.Headers.Clear(); SoapHeaderHandling.GetHeaderMembers(this.message.Headers, this.Target, this.serverMethod.outHeaderMappings, SoapHeaderDirection.Out, false); if (this.message.allExtensions != null) { this.message.SetExtensionStream(new SoapExtensionStream()); } this.message.InitExtensionStreamChain(this.message.allExtensions); this.message.SetStage(SoapMessageStage.BeforeSerialize); this.message.ContentType = ContentType.Compose(this.helper.HttpContentType, Encoding.UTF8); this.message.SetParameterValues(returnValues); this.message.RunExtensions(this.message.allExtensions, true); this.message.SetStream(outputStream); base.Response.ContentType = this.message.ContentType; if ((this.message.ContentEncoding != null) && (this.message.ContentEncoding.Length > 0)) { base.Response.AppendHeader("Content-Encoding", this.message.ContentEncoding); } XmlWriter writerForMessage = this.GetWriterForMessage(this.message, 0x400); if (writerForMessage == null) { throw new InvalidOperationException(System.Web.Services.Res.GetString("WebNullWriterForMessage")); } writerForMessage.WriteStartDocument(); writerForMessage.WriteStartElement("soap", "Envelope", this.helper.EnvelopeNs); writerForMessage.WriteAttributeString("xmlns", "soap", null, this.helper.EnvelopeNs); if (isEncoded) { writerForMessage.WriteAttributeString("xmlns", "soapenc", null, this.helper.EncodingNs); writerForMessage.WriteAttributeString("xmlns", "tns", null, this.serverType.serviceNamespace); writerForMessage.WriteAttributeString("xmlns", "types", null, SoapReflector.GetEncodedNamespace(this.serverType.serviceNamespace, this.serverType.serviceDefaultIsEncoded)); } if (this.serverMethod.rpc && (this.version == SoapProtocolVersion.Soap12)) { writerForMessage.WriteAttributeString("xmlns", "rpc", null, "http://www.w3.org/2003/05/soap-rpc"); } writerForMessage.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance"); writerForMessage.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema"); SoapHeaderHandling.WriteHeaders(writerForMessage, this.serverMethod.outHeaderSerializer, this.message.Headers, this.serverMethod.outHeaderMappings, SoapHeaderDirection.Out, isEncoded, this.serverType.serviceNamespace, this.serverType.serviceDefaultIsEncoded, this.helper.EnvelopeNs); writerForMessage.WriteStartElement("Body", this.helper.EnvelopeNs); if (isEncoded && (this.version != SoapProtocolVersion.Soap12)) { writerForMessage.WriteAttributeString("soap", "encodingStyle", null, this.helper.EncodingNs); } TraceMethod caller = Tracing.On ? new TraceMethod(this, "WriteReturns", new object[0]) : null; if (Tracing.On) { object[] args = new object[4]; args[0] = writerForMessage; args[1] = returnValues; args[3] = isEncoded ? this.helper.EncodingNs : null; Tracing.Enter(Tracing.TraceId("TraceWriteResponse"), caller, new TraceMethod(this.serverMethod.returnSerializer, "Serialize", args)); } this.serverMethod.returnSerializer.Serialize(writerForMessage, returnValues, null, isEncoded ? this.helper.EncodingNs : null); if (Tracing.On) { Tracing.Exit(Tracing.TraceId("TraceWriteResponse"), caller); } writerForMessage.WriteEndElement(); writerForMessage.WriteEndElement(); writerForMessage.Flush(); this.message.SetStage(SoapMessageStage.AfterSerialize); this.message.RunExtensions(this.message.allExtensions, true); } }
internal override bool WriteException(Exception e, Stream outputStream) { SoapException exception; if (this.message == null) { return(false); } this.message.Headers.Clear(); if ((this.serverMethod != null) && (this.Target != null)) { SoapHeaderHandling.GetHeaderMembers(this.message.Headers, this.Target, this.serverMethod.outHeaderMappings, SoapHeaderDirection.Fault, false); } if (e is SoapException) { exception = (SoapException)e; } else if (((this.serverMethod != null) && this.serverMethod.rpc) && ((this.helper.Version == SoapProtocolVersion.Soap12) && (e is ArgumentException))) { exception = SoapException.Create(this.Version, System.Web.Services.Res.GetString("WebRequestUnableToProcess"), new XmlQualifiedName("Client", "http://schemas.xmlsoap.org/soap/envelope/"), null, null, null, new SoapFaultSubCode(Soap12FaultCodes.RpcBadArgumentsFaultCode), e); } else { exception = SoapException.Create(this.Version, System.Web.Services.Res.GetString("WebRequestUnableToProcess"), new XmlQualifiedName("Server", "http://schemas.xmlsoap.org/soap/envelope/"), e); } if (SoapException.IsVersionMismatchFaultCode(exception.Code) && this.IsSupported(WebServiceProtocols.HttpSoap12)) { SoapUnknownHeader header = this.CreateUpgradeHeader(); if (header != null) { this.Message.Headers.Add(header); } } base.Response.ClearHeaders(); base.Response.Clear(); HttpStatusCode statusCode = this.helper.SetResponseErrorCode(base.Response, exception); bool flag = false; SoapExtensionStream extensionStream = new SoapExtensionStream(); if (this.message.allExtensions != null) { this.message.SetExtensionStream(extensionStream); } try { this.message.InitExtensionStreamChain(this.message.allExtensions); } catch (Exception exception2) { if (((exception2 is ThreadAbortException) || (exception2 is StackOverflowException)) || (exception2 is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "WriteException", exception2); } flag = true; } this.message.SetStage(SoapMessageStage.BeforeSerialize); this.message.ContentType = ContentType.Compose(this.helper.HttpContentType, Encoding.UTF8); this.message.Exception = exception; if (!flag) { try { this.message.RunExtensions(this.message.allExtensions, false); } catch (Exception exception3) { if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "WriteException", exception3); } flag = true; } } this.message.SetStream(outputStream); base.Response.ContentType = this.message.ContentType; if ((this.message.ContentEncoding != null) && (this.message.ContentEncoding.Length > 0)) { base.Response.AppendHeader("Content-Encoding", this.message.ContentEncoding); } XmlWriter writerForMessage = this.GetWriterForMessage(this.message, 0x200); if (writerForMessage == null) { throw new InvalidOperationException(System.Web.Services.Res.GetString("WebNullWriterForMessage")); } this.helper.WriteFault(writerForMessage, this.message.Exception, statusCode); if (!flag) { SoapException exception4 = null; try { this.message.SetStage(SoapMessageStage.AfterSerialize); this.message.RunExtensions(this.message.allExtensions, false); } catch (Exception exception5) { if (((exception5 is ThreadAbortException) || (exception5 is StackOverflowException)) || (exception5 is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "WriteException", exception5); } if (!extensionStream.HasWritten) { exception4 = SoapException.Create(this.Version, System.Web.Services.Res.GetString("WebExtensionError"), new XmlQualifiedName("Server", "http://schemas.xmlsoap.org/soap/envelope/"), exception5); } } if (exception4 != null) { base.Response.ContentType = ContentType.Compose("text/plain", Encoding.UTF8); StreamWriter writer2 = new StreamWriter(outputStream, new UTF8Encoding(false)); writer2.WriteLine(base.GenerateFaultString(this.message.Exception)); writer2.Flush(); } } return(true); }
internal override bool WriteException(Exception e, Stream outputStream) { if (message == null) { return(false); } message.Headers.Clear(); if (serverMethod != null) { SoapHeaderHandling.GetHeaderMembers(message.Headers, this.Target, serverMethod.outHeaderMappings, SoapHeaderDirection.Fault, false); } SoapException soapException; if (e is SoapException) { soapException = (SoapException)e; } else if (serverMethod != null && serverMethod.rpc && helper.Version == SoapProtocolVersion.Soap12 && e is ArgumentException) { // special case to handle soap 1.2 rpc "BadArguments" fault soapException = new SoapException(Res.GetString(Res.WebRequestUnableToProcess), new XmlQualifiedName(Soap.ClientCode, Soap.Namespace), null, null, null, new SoapFaultSubcode(Soap12FaultCodes.RpcBadArgumentsFaultCode), e); } else { soapException = new SoapException(Res.GetString(Res.WebRequestUnableToProcess), new XmlQualifiedName(Soap.ServerCode, Soap.Namespace), e); } if (SoapException.IsVersionMismatchFaultCode(soapException.Code)) { if (IsSupported(ProtocolsEnum.HttpSoap12)) { SoapUnknownHeader unknownHeader = CreateUpgradeHeader(); if (unknownHeader != null) { Message.Headers.Add(unknownHeader); } } } Response.ClearHeaders(); Response.Clear(); helper.SetResponseErrorCode(Response, soapException); bool disableExtensions = false; if (message.allExtensions != null) { message.SetExtensionStream(new SoapExtensionStream()); } try { message.InitExtensionStreamChain(message.allExtensions); } catch (Exception) { disableExtensions = true; } message.SetStage(SoapMessageStage.BeforeSerialize); message.ContentType = ContentType.Compose(helper.HttpContentType, Encoding.UTF8); message.SetException(soapException); if (!disableExtensions) { try { message.RunExtensions(message.allExtensions); } catch (Exception) { disableExtensions = true; } } message.SetStream(outputStream); Response.ContentType = message.ContentType; if (message.ContentEncoding != null && message.ContentEncoding.Length > 0) { Response.AppendHeader(ContentType.ContentEncoding, message.ContentEncoding); } bool isEncoded = serverMethod != null && serverMethod.use == SoapBindingUse.Encoded; StreamWriter sw = new StreamWriter(message.Stream, new UTF8Encoding(false), 128); XmlTextWriter writer = isEncoded && message.Headers.Count > 0 ? new XmlSpecialTextWriter(sw, helper.Version) : new XmlTextWriter(sw); writer.Formatting = Formatting.Indented; // CONSIDER, don't format to save space writer.Indentation = 2; // CONSIDER, don't indent to save space helper.WriteFault(writer, soapException); if (!disableExtensions) { try { message.SetStage(SoapMessageStage.AfterSerialize); message.RunExtensions(message.allExtensions); } catch (Exception) { // it's too late to do anything about this -- we've already written to the stream } } return(true); }
internal override void WriteReturns(object[] returnValues, Stream outputStream) { if (serverMethod.oneWay) { return; } bool isEncoded = serverMethod.use == SoapBindingUse.Encoded; SoapHeaderHandling.EnsureHeadersUnderstood(message.Headers); message.Headers.Clear(); SoapHeaderHandling.GetHeaderMembers(message.Headers, this.Target, serverMethod.outHeaderMappings, SoapHeaderDirection.Out, false); if (message.allExtensions != null) { message.SetExtensionStream(new SoapExtensionStream()); } message.InitExtensionStreamChain(message.allExtensions); message.SetStage(SoapMessageStage.BeforeSerialize); message.ContentType = ContentType.Compose(helper.HttpContentType, Encoding.UTF8); message.SetParameterValues(returnValues); message.RunExtensions(message.allExtensions); message.SetStream(outputStream); Response.ContentType = message.ContentType; if (message.ContentEncoding != null && message.ContentEncoding.Length > 0) { Response.AppendHeader(ContentType.ContentEncoding, message.ContentEncoding); } StreamWriter sw = new StreamWriter(message.Stream, new UTF8Encoding(false), 128); XmlTextWriter writer = isEncoded && message.Headers.Count > 0 ? new XmlSpecialTextWriter(sw, helper.Version) : new XmlTextWriter(sw); writer.WriteStartDocument(); writer.WriteStartElement("soap", Soap.Envelope, helper.EnvelopeNs); writer.WriteAttributeString("xmlns", "soap", null, helper.EnvelopeNs); if (isEncoded) { writer.WriteAttributeString("xmlns", "soapenc", null, helper.EncodingNs); writer.WriteAttributeString("xmlns", "tns", null, serverType.serviceNamespace); writer.WriteAttributeString("xmlns", "types", null, SoapReflector.GetEncodedNamespace(serverType.serviceNamespace, serverType.serviceDefaultIsEncoded)); } if (serverMethod.rpc && version == SoapProtocolVersion.Soap12) { writer.WriteAttributeString("xmlns", "rpc", null, Soap12.RpcNamespace); } writer.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace); writer.WriteAttributeString("xmlns", "xsd", null, XmlSchema.Namespace); SoapHeaderHandling.WriteHeaders(writer, serverMethod.outHeaderSerializer, message.Headers, serverMethod.outHeaderMappings, SoapHeaderDirection.Out, isEncoded, serverType.serviceNamespace, serverType.serviceDefaultIsEncoded, helper.EnvelopeNs); writer.WriteStartElement(Soap.Body, helper.EnvelopeNs); if (isEncoded) { writer.WriteAttributeString("soap", Soap.EncodingStyle, null, helper.EncodingNs); } // SOAP12: not using encodingStyle //serverMethod.returnSerializer.Serialize(writer, returnValues, null, isEncoded ? helper.EncodingNs : null); serverMethod.returnSerializer.Serialize(writer, returnValues, null); writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); message.SetStage(SoapMessageStage.AfterSerialize); message.RunExtensions(message.allExtensions); }
/// <include file='doc\HtmlFormParameterWriter.uex' path='docs/doc[@for="HtmlFormParameterWriter.InitializeRequest"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public override void InitializeRequest(WebRequest request, object[] values) { request.ContentType = ContentType.Compose(HtmlFormParameterReader.MimeType, RequestEncoding); }
public override void InitializeRequest(WebRequest request, object[] values) { request.ContentType = ContentType.Compose("application/x-www-form-urlencoded", this.RequestEncoding); }