WCF - HTTPS/HTTP хостинг и Cosuming
У меня странная проблема, я разместил службу WCF на своем локальном компьютере, я включил на ней SSL и мой сервис web.config выглядит следующим образом;
<system.serviceModel>
<services>
<service behaviorConfiguration="PostingBehavior" name="IMedTabletHL7Service.Hl7Service">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="web" bindingConfiguration="PostingCapable" contract="IMedTabletHL7Service.IHL7Service">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp defaultBodyStyle="Wrapped" faultExceptionEnabled="true" helpEnabled="true"></webHttp>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="PostingBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Buffered" receiveTimeout="00:30:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<mexHttpsBinding>
<binding name="NewBinding0" />
</mexHttpsBinding>
<webHttpBinding>
<binding name="PostingCapable" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Buffered" receiveTimeout="00:30:00">
<security mode="Transport">
<transport proxyCredentialType="None" clientCredentialType="None"></transport>
</security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
и мой настольный файл app.config выглядит следующим образом;
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IHL7Service" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport proxyCredentialType="None" clientCredentialType="None"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost/IMedTabletHL7Service/Hl7Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHL7Service"
contract="HL7Webservice.IHL7Service" name="BasicHttpBinding_IHL7Service" />
</client>
Это бросает меня после ошибки;
System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at https://localhost/IMedTabletHL7Service/Hl7Service.svc 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`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Также, когда я получаю доступ к сервису из браузера, он не выдаёт мне никакой ошибки
1 ответ
Решение
Одна проблема заключается в том, что ваш сервис и ваш клиент используют разные привязки для своих конечных точек (service: webHttpBinding, client: basicHttpBinding).