0

HTTP エンドポイントのみを公開する WCF サービスがあります。私の App.config は次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<configuration>  
  <system.diagnostics>
      <sources>
            <source name="System.ServiceModel" 
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
               <add name="traceListener" 
                   type="System.Diagnostics.XmlWriterTraceListener" 
                   initializeData= "C:\Users\Developer\Documents\ProjectName\Servicelog.svclog" />
            </listeners>
         </source>
      </sources>
   </system.diagnostics>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
    <services>
      <service name="Project.ServiceOne">
        <endpoint address="http://localhost/Project/ServiceOne" binding="webHttpBinding" contract="Project.IServiceOne"/>
      </service>
      <service name="Project.ServiceTwo">
        <endpoint address="http://localhost/Project/ServiceTwo" binding="webHttpBinding" contract="Project.IServiceTwo"/>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
   <httpProtocol>
     <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept"/>
     </customHeaders>
   </httpProtocol>
  </system.webServer>
  <startup>
    <supportedRuntime version="v2.0.50727" />
  </startup>
</configuration>

IIS 7.5 (Windows 7 x64 - Express ではなく完全なプログラムと機能) を既定の Web サイトである Project アプリケーションに実行しています。

.svc ファイルを参照すると、MEX エンドポイントが有効になっていないことがわかりますが、これは問題ありません。に投稿しようとすると問題が発生しhttp://localhost/Project/ServiceOne/ServiceMethodます。このメソッドは Service コントラクトと実装に存在し、インターフェイスで WebInvoke として装飾されていますが、POST すると HTTP 404 のみが返されます。テスト メソッドを GET でデコレートして参照すると、MapRequestHandler によって 404 が返されます。

App.config ファイルの何が問題になっていますか? これらのエンドポイントを機能させるにはどうすればよいですか?

要求に応じて、インターフェイス:

[ServiceContract]
public interface IServiceOne
{
    [OperationContract]
    [WebInvoke(Method = "GET",
       RequestFormat = WebMessageFormat.Json,
       ResponseFormat = WebMessageFormat.Json,
       UriTemplate = "MyMethod")]
    List<String> MyMethod();
}
4

1 に答える 1

0

適切な動作をセットアップする必要があります。

<services>
  <service name="Project.ServiceOne" behaviorConfiguration="serviceBehavior">
    <endpoint address="" binding="webHttpBinding" contract="Project.IServiceOne" behaviorConfiguration="webBehaviour"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
    <host>
      <baseAddresses>
        <add baseaddress="http://localhost/Project/ServiceOne">
      </baseAddresses>
    </host>
  </service>
  <service name="Project.ServiceTwo" behaviorConfiguration="serviceBehavior">
    <endpoint address="" binding="webHttpBinding" contract="Project.IServiceTwo" behaviorConfiguration="webBehaviour"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
    <host>
      <baseAddresses>
        <add baseaddress="http://localhost/Project/ServiceTwo">
      </baseAddresses>
    </host>
  </service>    
</services>
<behaviors>
    <serviceBehaviors>
        <behavior name="serviceBehavior">         
          <serviceMetadata httpGetEnabled="true"/>        
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
    </serviceBehaviors>
    <endpointBehaviors>
        <behavior name="webBehaviour">
          <webHttp/>
        </behavior>
    </endpointBehaviors>
</behaviors>
于 2013-10-03T22:26:03.180 に答える