1

最近、C# (WCF Service Application) で Rest-Service を作成し始めました。目的は、apache2 + mod-mono + https + 基本認証を備えた Debian 7 システムで使用することです。すべてがhttpで機能していました。しかし、やりたいことはできます..httpsでは機能しません。「要求されたリッスン URI スキームは http である必要がありますが、https でした」というエラー メッセージが常に表示されます。そして何が悪いのか理解していません。Web のさまざまなブログやチュートリアルで説明されているように、すべてを行ったと思います。

httpsを正しく構成し、自己署名証明書などを作成しました。実際、https自体は正常に機能しています。しかし、サービスではありません。また、IIS-Express 7.5を搭載したWin7-Machineでhttpsを使用してサービスを使用しようとしましたが、これは魅力的でした。Linux/Mono/Apache に関するものでなければなりません。

以下は私の設定ファイルです。誰かが私を助けてくれることを願っています:(

毎日のあいさつ

Web.config

<?xml version="1.0"?>
<configuration>

<system.web>
  <compilation debug="true"
             targetFramework="4.0">
  </compilation>
  <customErrors mode="Off"/>
  <pages controlRenderingCompatibilityVersion="3.5"
       clientIDMode="AutoID"/>
</system.web>
<system.serviceModel>
<services>
  <service name="RestService.RestServiceImpl"
           behaviorConfiguration="ServiceBehaviour">

    <endpoint address=""
              binding="webHttpBinding"
              contract="RestService.IRestServiceImpl"
              bindingConfiguration="webHttpTransportSecurity"
              behaviorConfiguration="webHttpBindingBehavior" />

  </service>

</services>


<bindings>

  <webHttpBinding>
    <binding name="webHttpTransportSecurity">
      <security mode="Transport" />
    </binding>
  </webHttpBinding>

</bindings>


<behaviors>

  <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <serviceMetadata httpGetEnabled="false"
                       httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>

  <endpointBehaviors>
    <behavior name="webHttpBindingBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>

</behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

</system.serviceModel>

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
  </modules>
</system.webServer>

</configuration>

Apache のサイト構成

<IfModule mod_ssl.c>

<VirtualHost *:443>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

SSLEngine on
SSLCertificateFile    /etc/apache2/ssl/apache.pem
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
SSLOptions StrictRequire
SSLProtocol all -SSLv2

MonoServerPath wcs.mydomain.de "/usr/bin/mod-mono-server4"
MonoDebug wcs.mydomain.de true
MonoSetEnv wcs.mydomain.de  MONO_IOMAP=all
MonoAutoApplication  disabled
MonoApplications wcs.mydomain.de "/api:/var/www/wcs"

BrowserMatch "MSIE [2-6]" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

<Location /api>
    SSLRequireSSL
    Options FollowSymLinks

    Allow from all
    Order allow,deny

    MonoSetServerAlias wcs.mydomain.de
    SetHandler mono

    AuthType Basic
    AuthName "Authorization required"
    AuthUserFile /etc/apache2/htpasswd
    Require valid-user
</Location>
</VirtualHost>

編集

追加情報、誰かがそれを利用して私の過ちを見てくれることを願っています。

バージョン情報

Version information: Mono Runtime Version: 2.10.8.1 (Debian 2.10.8.1-8); ASP.NET Version: 4.0.30319.1

完全なスタックトレース

System.ArgumentException: Requested listen uri scheme must be http, but was https.
at System.ServiceModel.Channels.Http.HttpChannelListener`1[System.ServiceModel.Channels.IReply    Channel]..ctor (System.ServiceModel.Channels.HttpTransportBindingElement source,   System.ServiceModel.Channels.BindingContext context) [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener[IReplyChannel    ] (System.ServiceModel.Channels.BindingContext context) [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[IReplyChannel]      () [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.BindingElement.BuildChannelListener[IReplyChannel]     (System.ServiceModel.Channels.BindingContext context) [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.WebMessageEncodingBindingElement.BuildChannelListener[IReplyCh    annel] (System.ServiceModel.Channels.BindingContext context) [0x00000] in <filename      unknown>:0 
at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[IReplyChannel]      () [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.Binding.BuildChannelListener[IReplyChannel] (System.Uri      listenUriBaseAddress, System.String listenUriRelativeAddress, ListenUriMode listenUriMode,      System.ServiceModel.Channels.BindingParameterCollection parameters) [0x00000] in <filename      unknown>:0 
at System.ServiceModel.DispatcherBuilder.BuildListener      (System.ServiceModel.Description.ServiceEndpoint se,       System.ServiceModel.Channels.BindingParameterCollection pl) [0x00000] in <filename      unknown>:0 
at System.ServiceModel.DispatcherBuilder.BuildChannelDispatcher (System.Type      serviceType, System.ServiceModel.Description.ServiceEndpoint se,      System.ServiceModel.Channels.BindingParameterCollection commonParams) [0x00000] in      <filename unknown>:0 
at System.ServiceModel.ServiceHostBase.InitializeRuntime () [0x00000] in <filename      unknown>:0 
at System.ServiceModel.ServiceHostBase.OnOpen (TimeSpan timeout) [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.CommunicationObject.Open () [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.SvcHttpHandler.EnsureServiceHostCore () [0x00000] in  <filename unknown>:0 
at System.ServiceModel.Channels.SvcHttpHandler.EnsureServiceHost () [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.SvcHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0 
at System.Web.HttpApplication+<Pipeline>c__Iterator6.MoveNext () [0x00000] in <filename unknown>:0 
at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0 

IRestServiceImpl.cs

using System.ServiceModel;
using System.ServiceModel.Web;

namespace RestService
{

    [ServiceContract]
    public interface IRestServiceImpl
    {
        [OperationContract]
        [WebInvoke(Method = "GET",
            ResponseFormat = WebMessageFormat.Xml,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "info")]
        string Info();
    }
} 

RestServiceImpl.svc

<%@ ServiceHost Language="C#" Debug="true" Service="RestService.RestServiceImpl" CodeBehind="RestServiceImpl.svc.cs" %>

RestServiceImpl.svc.cs

namespace RestService
{
    public class RestServiceImpl : IRestServiceImpl
    {
        #region IRestServiceImpl Members

        public string Info()
        {
            return "This is the Rest-Service for a WCS";
        }

        #endregion
    }
}

mod_mono.conf

AddType application/x-asp-net .svc .aspx .ashx .asmx .ascx .asax .config
DirectoryIndex index.aspx
Include /etc/mono-server4/mono-server4-hosts.conf

編集-2

knocte が以下に提案するように、Mono 3 にアップグレードしましたが、それでも同じエラーが発生します。

System.ArgumentException - Requested listen uri scheme must be http, but was https.

バージョン情報

Version Information: 3.0.12 (master/574dbc8 Wed May 29 20:34:12 CEST 2013); ASP.NET Version: 4.0.30319.17020

スタックトレース

at System.ServiceModel.Channels.Http.HttpChannelListener`1[System.ServiceModel.Channels.IReplyChannel]..ctor (System.ServiceModel.Channels.HttpTransportBindingElement source, System.ServiceModel.Channels.BindingContext context) [0x00126] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpChannelListener.cs:71 
at System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener[IReplyChannel] (System.ServiceModel.Channels.BindingContext context) [0x00000] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs:246 
at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[IReplyChannel] () [0x00020] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingContext.cs:161 
at System.ServiceModel.Channels.BindingElement.BuildChannelListener[IReplyChannel] (System.ServiceModel.Channels.BindingContext context) [0x00011] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingElement.cs:63 
at System.ServiceModel.Channels.WebMessageEncodingBindingElement.BuildChannelListener[IReplyChannel] (System.ServiceModel.Channels.BindingContext context) [0x0001d] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel.Web/System.ServiceModel.Channels/WebMessageEncodingBindingElement.cs:126 
at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[IReplyChannel] () [0x00020] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingContext.cs:161 
at System.ServiceModel.Channels.Binding.BuildChannelListener[IReplyChannel] (System.Uri listenUriBaseAddress, System.String listenUriRelativeAddress, ListenUriMode listenUriMode, System.ServiceModel.Channels.BindingParameterCollection parameters) [0x00046] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Binding.cs:174 
at System.ServiceModel.DispatcherBuilder.BuildListener (System.ServiceModel.Description.ServiceEndpoint se, System.ServiceModel.Channels.BindingParameterCollection pl) [0x00038] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs:720 
at System.ServiceModel.DispatcherBuilder.BuildChannelDispatcher (System.Type serviceType, System.ServiceModel.Description.ServiceEndpoint se, System.ServiceModel.Channels.BindingParameterCollection commonParams) [0x0005e] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs:657 
at System.ServiceModel.ServiceHostBase.InitializeRuntime () [0x000ad] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs:460 
at System.ServiceModel.ServiceHostBase.OnOpen (TimeSpan timeout) [0x00006] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs:567 
at System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) [0x00006] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:170 
at System.ServiceModel.Channels.CommunicationObject.Open () [0x00000] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:164 
at System.ServiceModel.Channels.SvcHttpHandler.EnsureServiceHostCore () [0x00068] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs:138 
at System.ServiceModel.Channels.SvcHttpHandler.EnsureServiceHost () [0x00016] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs:117 
at System.ServiceModel.Channels.SvcHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] in /opt/mono-3.0/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs:75 
at System.Web.HttpApplication+<Pipeline>c__Iterator3.MoveNext () [0x00dd7] in /opt/mono-3.0/mono/mcs/class/System.Web/System.Web/HttpApplication.cs:1368 
at System.Web.HttpApplication.Tick () [0x00000] in /opt/mono-3.0/mono/mcs/class/System.Web/System.Web/HttpApplication.cs:932 
4

0 に答える 0