mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 03:51:19 -10:00
WebServiceHandlerFactory that generates the documentation page. * WebServiceHandlerFactory.cs: Moved the code that generates the doc page to SoapDocumentationHandler.cs. * HttpGetClientProtocol.cs, HttpGetWebServiceHandler.cs, HttpPostClientProtocol.cs, HttpPostWebServiceHandler.cs, HttpSimpleWebServiceHandler.cs, HttpSoapWebServiceHandler.cs, SoapHttpClientProtocol.cs: Changed parameters of GetTypeStub call. * HttpGetTypeStubInfo.cs, HttpPostTypeStubInfo.cs: Added ProtocolName property. Added check for valid parameters. * HttpSimpleTypeStubInfo.cs: Define return MimeFormatter in constructor. * Methods.cs: BindingInfo and related properties moved to base TypeStubInfo. Added properties for XmlImporter and SoapImporter. * TypeStubManager.cs: Added BindingInfo and related properties. Changed GetTypeStub method. Now it takes the name of the protocol for which to get the type stub info. * ValueCollectionParameterReader.cs: IsSupported should only return true for input primitive parameters or array of primitives. svn path=/trunk/mcs/; revision=18575
87 lines
2.2 KiB
C#
87 lines
2.2 KiB
C#
//
|
|
// System.Web.Services.Protocols.HttpSimpleWebServiceHandler.cs
|
|
//
|
|
// Author:
|
|
// Lluis Sanchez Gual ([email protected])
|
|
//
|
|
// Copyright (C) Ximian, Inc. 2003
|
|
//
|
|
|
|
using System;
|
|
using System.Reflection;
|
|
using System.IO;
|
|
using System.Web.Services;
|
|
|
|
namespace System.Web.Services.Protocols
|
|
{
|
|
internal class HttpSimpleWebServiceHandler: WebServiceHandler
|
|
{
|
|
HttpSimpleTypeStubInfo _typeInfo;
|
|
|
|
public HttpSimpleWebServiceHandler (Type type, string protocolName): base (type)
|
|
{
|
|
_typeInfo = (HttpSimpleTypeStubInfo) TypeStubManager.GetTypeStub (type, protocolName);
|
|
}
|
|
|
|
protected HttpSimpleTypeStubInfo TypeStub
|
|
{
|
|
get { return _typeInfo; }
|
|
}
|
|
|
|
public override void ProcessRequest (HttpContext context)
|
|
{
|
|
string name = context.Request.PathInfo;
|
|
if (name.StartsWith ("/")) name = name.Substring (1);
|
|
|
|
Stream respStream = null;
|
|
Exception error = null;
|
|
try
|
|
{
|
|
HttpSimpleMethodStubInfo method = (HttpSimpleMethodStubInfo) _typeInfo.GetMethod (name);
|
|
if (method == null) throw new InvalidOperationException ("Method " + name + " not defined in service " + ServiceType.Name);
|
|
|
|
MimeParameterReader parameterReader = (MimeParameterReader) method.ParameterReaderType.Create ();
|
|
object[] parameters = parameterReader.Read (context.Request);
|
|
|
|
MimeReturnWriter returnWriter = (MimeReturnWriter) method.ReturnWriterType.Create ();
|
|
object result = Invoke (method.MethodInfo, parameters);
|
|
respStream = context.Response.OutputStream;
|
|
returnWriter.Write (context.Response, respStream, result);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
error = ex;
|
|
}
|
|
|
|
if (error != null)
|
|
{
|
|
try
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
context.Response.StatusCode = 500;
|
|
context.Response.Write (error.Message);
|
|
}
|
|
catch {}
|
|
}
|
|
|
|
if (respStream != null)
|
|
respStream.Close ();
|
|
}
|
|
|
|
object Invoke (LogicalMethodInfo method, object[] parameters)
|
|
{
|
|
try
|
|
{
|
|
object server = CreateServerInstance ();
|
|
object[] res = method.Invoke (server, parameters);
|
|
if (!method.IsVoid) return res[0];
|
|
else return null;
|
|
}
|
|
catch (TargetInvocationException ex)
|
|
{
|
|
throw ex.InnerException;
|
|
}
|
|
}
|
|
}
|
|
}
|