是否可以从HTTPS服务调用HTTP服务方法?

时间:2014-05-26 09:51:31

标签: wcf http https

我有2个WCF服务。

服务1托管为 HTTPS 。服务1呼叫服务2(仅 http )。

使用的绑定: basicHtpBinding

它会抛出错误“ 提供的URI方案'http'无效;预计'https' 。”

更新:

我从服务1呼叫服务2的代码:

    public bool CreateMethod(string message)
    {
        return Client.AnotherMethod(message);
    }  

服务1配置:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IObject"   closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://XX.xx.xx.xx:8001/Services.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IObject"
        contract="AppService.IObject" name="BasicHttpBinding_IObject" />
    </client>
    <services>
      <service behaviorConfiguration="ServiceBehaviour" name="WebService.IntegrationService">
        <endpoint address="" binding="basicHttpBinding" `enter code here`contract="WebService.IIntegrationService" bindingConfiguration="BasicHttpBinding_IObject" behaviorConfiguration="basicHttp"></endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="basicHttp">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>`
</configuration>

服务2配置:

<system.serviceModel>      
    <services>
      <service name="MY.Service">
        <endpoint address="" binding="basicHttpBinding" contract="App.IObject">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>        
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" />        
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

0 个答案:

没有答案