A HTTP/SOAP/XML server.
상속: HTTPServer
예제 #1
0
        /// <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
        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
 /// <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
 /// <summary>
 /// Start the SOAP API.
 /// </summary>
 public virtual void Start()
 {
     SOAPServer.Start();
 }
예제 #5
0
        /// <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
        }