A HTTP/SOAP/XML server.
Inheritance: HTTPServer
コード例 #1
0
ファイル: ASOAPServer.cs プロジェクト: bpaziaud/Hermod
        /// <summary>
        /// Use the given HTTP server for the HTTP/SOAP/XML Server API.
        /// </summary>
        /// <param name="SOAPServer">A SOAP server.</param>
        /// <param name="URIPrefix">An optional URI prefix for the SOAP URI templates.</param>
        public ASOAPServer(SOAPServer SOAPServer,
                           String URIPrefix = DefaultURIPrefix)
        {
            #region Initial checks

            if (SOAPServer == null)
            {
                throw new ArgumentNullException(nameof(SOAPServer), "The given SOAP server must not be null!");
            }

            if (URIPrefix == null)
            {
                URIPrefix = DefaultURIPrefix;
            }
            else
            {
                URIPrefix = URIPrefix.Trim();
            }

            if (URIPrefix.Length > 0 && !URIPrefix.StartsWith("/", StringComparison.Ordinal))
            {
                URIPrefix = "/" + URIPrefix;
            }

            #endregion

            this.SOAPServer = SOAPServer;
            this.URIPrefix  = URIPrefix;
            this.DNSClient  = SOAPServer.DNSClient;

#pragma warning disable RECS0021
            RegisterURITemplates();
#pragma warning restore RECS0021
        }
コード例 #2
0
ファイル: ASOAPServer.cs プロジェクト: bpaziaud/Hermod
        private void RegisterRootService()
        {
            SOAPServer.AddMethodCallback(HTTPHostname.Any,
                                         HTTPMethod.GET,

                                         new String[] {
                "/",
                URIPrefix + "/"
            },

                                         new HTTPContentType[] {
                HTTPContentType.TEXT_UTF8,
                HTTPContentType.HTML_UTF8
            },

                                         HTTPDelegate: Request => {
                return(Task.FromResult(
                           new HTTPResponseBuilder(Request)
                {
                    HTTPStatusCode = HTTPStatusCode.BadGateway,
                    ContentType = HTTPContentType.TEXT_UTF8,
                    Content = ("Welcome at " + DefaultHTTPServerName + Environment.NewLine +
                               "This is a HTTP/SOAP/XML endpoint!" + Environment.NewLine + Environment.NewLine +
                               "Defined endpoints: " + Environment.NewLine + Environment.NewLine +
                               SOAPServer.
                               SOAPDispatchers.
                               Select(group => " - " + group.Key + Environment.NewLine +
                                      "   " + group.SelectMany(dispatcher => dispatcher.SOAPDispatches).
                                      Select(dispatch => dispatch.Description).
                                      AggregateWith(", ")
                                      ).AggregateWith(Environment.NewLine + Environment.NewLine)
                               ).ToUTF8Bytes(),
                    Connection = "close"
                }.AsImmutable()));
            },

                                         AllowReplacement: URIReplacement.Allow);
        }
コード例 #3
0
ファイル: ASOAPServer.cs プロジェクト: bpaziaud/Hermod
 /// <summary>
 /// Stop the SOAP API.
 /// </summary>
 /// <param name="Message">An optional shutdown message.</param>
 /// <param name="Wait">Wait for a clean shutdown of the API.</param>
 public virtual void Shutdown(String Message = null,
                              Boolean Wait   = true)
 {
     SOAPServer.Shutdown(Message, Wait);
 }
コード例 #4
0
ファイル: ASOAPServer.cs プロジェクト: bpaziaud/Hermod
 /// <summary>
 /// Start the SOAP API.
 /// </summary>
 public virtual void Start()
 {
     SOAPServer.Start();
 }
コード例 #5
0
ファイル: ASOAPServer.cs プロジェクト: Vanaheimr/Hermod
        /// <summary>
        /// Use the given HTTP server for the HTTP/SOAP/XML Server API.
        /// </summary>
        /// <param name="SOAPServer">A SOAP server.</param>
        /// <param name="URIPrefix">An optional URI prefix for the SOAP URI templates.</param>
        public ASOAPServer(SOAPServer  SOAPServer,
                           String      URIPrefix  = DefaultURIPrefix)
        {
            #region Initial checks

            if (SOAPServer == null)
                throw new ArgumentNullException(nameof(SOAPServer),  "The given SOAP server must not be null!");

            if (URIPrefix == null)
                URIPrefix = DefaultURIPrefix;
            else
                URIPrefix = URIPrefix.Trim();

            if (URIPrefix.Length > 0 && !URIPrefix.StartsWith("/", StringComparison.Ordinal))
                URIPrefix = "/" + URIPrefix;

            #endregion

            this.SOAPServer  = SOAPServer;
            this.URIPrefix   = URIPrefix;
            this.DNSClient   = SOAPServer.DNSClient;

            #pragma warning disable RECS0021
            RegisterURITemplates();
            #pragma warning restore RECS0021
        }