简体   繁体   中英

WCF - HTTPS/HTTP Hosting & Cosuming

I'm having an odd issue, I have hosted a WCF service on my local machine, I have enabled SSL on it & my service web.config looks like this;

<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" />

and my desktop app.config file looks like this;

<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>

Its throwing me following error;

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)

Also when I access service from browser its not giving me any error.

一个问题是您的服务和客户端对其端点使用不同的绑定(服务:webHttpBinding,客户端:basicHttpBinding)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM