2015-05-12 40 views
0

我有一個.net客戶端,我正在使用WCF服務,並且能夠成功完成。但是當我嘗試在我們的產品上發佈時,我無法使用相同的服務。下面是我的web.config:WCF服務正在開發服務器上,但在生產上它不是正在開發

<system.serviceModel> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="MyBehavior"> 
     <useRequestHeadersForMetadataAddress></useRequestHeadersForMetadataAddress> 
     <serviceMetadata httpGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="false"/> 
     <serviceCredentials> 
     <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TestProject.Implementations.AuthenticateUser,TestProject"/> 
     <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/> 
     </serviceCredentials> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<services> 
    <service name="TestProject.Implementations.ServiceCustom" behaviorConfiguration="MyBehavior"> 
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="SampleServiceBinding" contract="TestProject.Interfaces.IServiceCustom"></endpoint> 
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"></endpoint> 
    </service> 
</services> 
<bindings> 
    <wsHttpBinding> 
    <binding name="SampleServiceBinding"> 
     <security mode ="Message"> 
     <message clientCredentialType="UserName"/> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

,也是我想讓我的服務啓用HTTPS。

我得到errormessage下面: 沒有端點收聽http://url.com可以接受消息。這通常是由不正確的地址或SOAP操作引起的。有關更多詳細信息,請參閱InnerException(如果存在)。

+0

「見InnerException,如果存在,獲取更多細節。「我們也可以看到嗎? –

+0

您的'web.config'不包含Web服務的地址。即使如此,這個錯誤也意味着你在你的代碼中改變了目標URL,也許使用一個配置值並以'url.com'作爲默認值。如果沒有發佈導致錯誤的*實際代碼*,則無法提供幫助 –

+0

從客戶端添加app.config或客戶端用於連接到服務的代碼。但我想問題是,您沒有爲服務於您的合同的端點指定地址。 –

回答

0

此錯誤清楚地表明您嘗試訪問的WCF服務沒有明確託管,或者您用於連接的地址未指向該服務,請確保在瀏覽器中使用該地址訪問該服務。

如果您能夠訪問該服務,請檢查您的客戶端應用程序web.config並找出該服務的終點詳細信息。如果端點網址不匹配,則可能會出現此錯誤。

+0

你解決了這個問題嗎?請添加評論你是如何解決這個問題的,以便有人可以從你的問題中學習。不要忘記投票或接受堆棧溢出成員提供的答案。如果答案不正確或不實用,您也可以對答案進行投票。 – BSG

+0

我修正了錯誤,下面是web配置代碼: –

0

我固定誤差和下方是web配置代碼:

<system.serviceModel> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="MyBehavior"> 
<useRequestHeadersForMetadataAddress></useRequestHeadersForMetadataAddress> 
     <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false"/> 
     <serviceCredentials> 
     <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TestProject.Implementations.AuthenticateUser,TestProject"/> 
     <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/> 
     </serviceCredentials> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<services> 
    <service name="TestProject.Implementations.Test" behaviorConfiguration="MyBehavior"> 
    <endpoint address="http://rul" binding="wsHttpBinding" bindingConfiguration="SampleServiceBinding" contract="TestProject.Interfaces.Test"></endpoint> 
<endpoint address="https:url" binding="wsHttpBinding" bindingConfiguration="SampleServiceBindingHttps" contract="TestProject.Interfaces.ITest"></endpoint> 
    <endpoint contract="IMetadataExchange" binding="mexHttpsBinding" address="mex"></endpoint> 
    </service> 
</services> 
<bindings> 
    <wsHttpBinding> 
    <binding name="SampleServiceBinding"> 
     <security mode="Message"> 
     <message clientCredentialType="UserName"/> 
     </security> 
    </binding> 
<binding name="SampleServiceBindingHttps"> 
    <security mode="TransportWithMessageCredential"> 
    <message clientCredentialType="UserName"/> 
    </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

我改變了安全模式爲TransportWithMessageCredential模式並改變一些配置樣結合=「mexHttpsBinding」

相關問題