1

私は単純な WCF サービスを持っています。IIS でホストされます。リモート クライアントはメタデータを取得し、プロキシ コードを生成できます。しかし、サービス呼び出しが行われると、サービスからの応答はありません。私の WCF サービス コードはヒットしません。その前に問題が発生します。これがスタックトレースです。どうすればこれを修正できますか? サービスはローカルで (つまり、サービスをホストしている同じマシンで) 動作します。認証等は行っておりません。

The open operation did not complete within the allotted timeout of 00:01:00. The
 time allotted to this operation may have been a portion of a longer timeout.

Server stack trace:
   at System.ServiceModel.Channels.ReliableRequestor.ThrowTimeoutException()
   at System.ServiceModel.Channels.ReliableRequestor.Request(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientReliableSession.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientReliableDuplexSessionChannel.OnOpen(Tim
eSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceMod
el.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeo
ut)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeS
pan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
Message methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

コメントに応じて構成ファイルを追加します。

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
      <serviceActivations>        
        <add relativeAddress="Service1.svc" service="WcfService1.Service1"/>
      </serviceActivations>
    </serviceHostingEnvironment>
    <services>      
      <service name="WcfService1.Service1">
        <host>
          <baseAddresses>
            <add baseAddress="http://mymachine.mydomain.com/Service1/" />            
          </baseAddresses>                    
        </host>
        <endpoint address="Service1"
                  binding ="customBinding"
                  bindingConfiguration="NetHttpBinding"
                  contract="WcfService1.IService1"/>
      </service>
    </services>
    <bindings>
      <!-- http://msdn.microsoft.com/en-us/library/vstudio/hh323713(v=vs.100).aspx
           You must add the binding elements in the following order: Transaction Flow, Reliable Session, Security,
           Composite Duplex, One-way, Stream Security, Message Encoding, and Transport.-->
      <customBinding>
        <binding name="NetHttpBinding">
          <reliableSession />          
          <compositeDuplex />
          <oneWay />
          <binaryMessageEncoding />          
          <httpTransport maxBufferSize="2147483647"  maxReceivedMessageSize="2147483647"  />
        </binding>
      </customBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

クライアントは静的 html ファイルにアクセスでき、メタデータ ページ wsdl もプロキシを作成できます。

編集:バインディングをbasicHttpBindingに変更すると、機能します。しかし、このカスタム バインディングで機能させる必要があります。

編集: 犯人は<compositeDuplex/>and<oneWay/>要素のようです。それらをバインディングから削除すると、機能します(今のところ、要素で機能しない理由-わかりません)。完全を期すために、どちらかのみを削除する<oneWay/><compositeDuplex/>(両方ではなく)、メタデータにアクセスしようとすると次のエラーが発生します。

Binding 'CustomBinding' doesn't support creating any channel types. This often indicates that the BindingElements in a CustomBinding have been stacked incorrectly or in the wrong order. A Transport is required at the bottom of the stack. The recommended order for BindingElements is: TransactionFlow, ReliableSession, Security, CompositeDuplex, OneWay, StreamSecurity, MessageEncoding, Transport. 

両方がバインディングに残っている場合、サービスはローカルで機能しますが、メソッドが呼び出されたときにリモート クライアントが応答を返すことはありません。

4

0 に答える 0