我想用自簽名SSL設置WCF服務。沒有端點偵聽在https:// wserver:442/service1.svc
我可以瀏覽到HTTPS並顯示元數據,我可以創建服務參考。
但是它引發了異常:在https://wserver:442/service1.svc
沒有端點偵聽,可以接受該消息。
wserver是我的服務器的名稱,但我不使用它的任何地方,所以我不知道它從哪裏得到它?
我的服務器Webhost.config(其中我認爲問題可能出)是:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Binding1">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="AutoSenderWCFService.AutoSenderService">
<endpoint binding="wsHttpBinding" bindingConfiguration="Binding1"
contract="AutoSenderWCFService.IService1" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="AutoSenderWCFService.MyValidator, AutoSenderWCFService"/>
</serviceCredentials>
<!-- 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>
或者,也許我做了自我簽名的SSL錯誤?
我的客戶方就是:
private void button1_Click(object sender, EventArgs e)
{
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
client.ClientCredentials.UserName.UserName = "test";
client.ClientCredentials.UserName.Password = "testPassword";
ServiceReference1.Contact[] test = client.GetDrivers();
}
}
您的服務如何託管? 442端口是否正確? - HTTPS的默認值爲443.連接URL來自客戶端代理 - 這是它唯一可能來自的地方,因爲您沒有明確指定要連接的端點。 –
我已經有一臺服務器在443上運行HTTPS,所以我用了442. – michael
好的。爲了解決這個問題,我建議你在客戶端啓用WCF跟蹤並查看輸出。 –