2012-05-14 31 views
1

更新:我不知道這是否有助於任何診斷這個問題,但在WSDL具有終點爲:不能打正由Visual Studio中發佈的WCF Web服務

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

哪是錯誤的,我手動試圖改變終點,除去在年底額外位,它仍然會返回一個404

/更新

我使用WCF Web服務上的工作,WH我運行VS2010調試器我收到以下錯誤消息:

目標程序集不包含服務類型。您可能需要調整此程序集的代碼訪問安全性策略。

這個我在網上找到的解決方案說,我應該添加[ServiceContract]到界面,但它已經在那裏。

我也看到有人說我必須從csproj文件中刪除標記,但這樣做會使項目成爲類庫而不是Web服務。

但我的瀏覽器打開一個目錄列表,如果我嘗試,我可以通過點擊.svc文件,然後單擊鏈接而.SVC?WSDL

上導航到由容器生成的WSDL和命中從應用程序或從WCF服務測試我得到一個異常與404的服務,我cbbled一起測試應用程序,這裏是它給了我異常:

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中內置的網絡服務器中託管,則會出現類似問題。

回答

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> 

服務元素中的名稱值和端點元素中的合同值應該完全限定。

+0

這是我清理我的Web.config以刪除對客戶端的引用的結果,服務名稱和端點合同都有名稱空間。抱歉。 –

+0

你在IIS上託管?你的項目中是否有.svc文件。你的意思是配置中的服務名稱和端點合同被指定爲完全限定名稱 – Rajesh

+0

我已經嘗試在IIS和Cassini(Visual Studio)中託管我有一個實現了[ServiceContract]的.svc文件我要去嘗試重新加載一個乾淨的解決方案的代碼,看看是否可行... –

相關問題