1

更新:これが誰かがこの問題を診断するのに役立つかどうかはわかりませんが、wsdlのエンドポイントは次のとおりです。

http://localhost:8523/Temp/WebService.svc/WebService.svc

これは間違っています。エンドポイントを手動で変更して、最後に余分なビットを削除しようとしましたが、それでも404が返されます。

/アップデート

WCFを使用してWebサービスを操作していますが、VS2010デバッガーを実行すると、次のエラーメッセージが表示されます。

ターゲットアセンブリにはサービスタイプが含まれていません。このアセンブリのコードアクセスセキュリティポリシーを調整する必要がある場合があります。

私がオンラインで見つけたこれに対する解決策は、インターフェースに[ServiceContract]を追加する必要があると言っていますが、それはすでに存在しています。

また、csprojファイルからタグを削除する必要があると言われることもありますが、これを行うと、プロジェクトがWebサービスではなくクラスライブラリになります。

しかし、ブラウザが開いてディレクトリリストが表示され、.svcファイルをクリックしてから.svc?wsdlへのリンクをクリックすると、コンテナによって生成されたwsdlに移動できます。

アプリケーションまたはWCFサービステスターからサービスをヒットしようとすると、404で例外が発生し、テストアプリをまとめました。これにより、例外が発生します。

Sending Message: Make Call: InteractionId [rt], Destination [ert], ExternalReferenceId [ert], userIdentifier [ert] attachedData [rt]
System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://localhost:8523/WebService.svc?wsdl that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)
   at System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Security.CommunicationObjectSecurityTokenProvider.Open(TimeSpan timeout)
   at System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout)
   at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan 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.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Sabio.Avaya.AACC.ProxyServiceLibary.IProxyService.MakeCall(MakeCallRequestData MakeCallRequestData)
   at Sabio.Avaya.AACC.ProxyServiceLibary.WSPipeProxyClient.MakeCall(MakeCallRequestData MakeCallRequestData) in C:\Users\me\Documents\Visual Studio 2010\Projects\WebService\RemoteClientLib\WSPipeProxyClient.cs:line 42
   at ClientLibTestUI.WcfTestApp.MPCWSButton_Click(Object sender, EventArgs e) in C:\Users\me\Documents\Visual Studio 2010\Projects\WebService\ClientLibTestUI\Form1.cs:line 97

これが私のWeb.configです。

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

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WebService" behaviorConfiguration="WebServiceBehaviour">
        <endpoint address="WebService.svc"
                  binding="wsHttpBinding"
                  bindingConfiguration="DefaultWSBinding"
                  name="WSEndPoint"
                  contract="IWebService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"
                  bindingConfiguration="mexHttpBinding"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/Temp/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="DefaultNetTcpBindingConfig"
                 maxConnections="5"
                 portSharingEnabled="true" >
          <security mode="None"/>
        </binding>

      </netTcpBinding>
      <wsHttpBinding>
        <binding name="DefaultWSBinding">
          <security mode="None"/>
        </binding>
      </wsHttpBinding>

      <mexHttpBinding>
        <binding name="mexHttpBinding"/>
      </mexHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServerServiceBehaviour">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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>
        <behavior name="MexBehaviour">
          <serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>

        </behavior>
        <behavior name="WebServiceBehaviour">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

誰かが私が間違っているかもしれないことを教えてもらえますか?IISでホストする場合、またはVS2010の組み込みWebサーバーでホストする場合にも、同様の問題が発生します。

4

1 に答える 1

0

設定のサービス タグが間違っています。以下のようになっているはずです。

<service name="namespace.WebService" behaviorConfiguration="WebServiceBehaviour">
        <endpoint address="WebService.svc"
                  binding="wsHttpBinding"
                  bindingConfiguration="DefaultWSBinding"
                  name="WSEndPoint"
                  contract="namespace.IWebService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"
                  bindingConfiguration="mexHttpBinding"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/Temp/"/>
          </baseAddresses>
        </host>
      </service>

service 要素の name 値と endpoint 要素の contract 値は、完全修飾されている必要があります。

于 2012-05-14T12:06:34.223 に答える