0

我正在通过 HTTP 成功使用以下代码,但我想使用 SSL。当我将端点地址更改为 https 并在 web.config 中将安全模式修改为传输时,我收到错误消息:“提供的 URI 方案 'https' 无效;预期为 'http'。”

这是一个 VB.net 测试表格。

Imports WindowsApplication1.WCFService
Imports System.ServiceModel

Public Class Form1
Private WCFConnection As Service1Client 'Class reference from the ServiceReference

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    If WCFConnection Is Nothing Then

        WCFConnection = New Service1Client(New System.ServiceModel.BasicHttpBinding(), New EndpointAddress("https://www.mysite.com/Service1.svc?wsdl"))
    End If

    Dim NParray As String = WCFConnection.GetNP("8")
    TextBox1.Text = NParray



End Sub
End Class

然后这里是 web.config

<system.serviceModel>
    <bindings>
        <basicHttpBinding>

          <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01: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="Transport">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>

        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://www.mysite.com/Service1.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IService1" contract="WCFService.IService1"
            name="BasicHttpBinding_IService1" />
    </client>
</system.serviceModel>

<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
4

2 回答 2

1

我已经想通了。

这是我正在使用的 web.config

<?xml version="1.0"?>
<configuration>

<system.serviceModel>

  <behaviors>
    <serviceBehaviors>
      <behavior name="ServBehave">
        <serviceMetadata httpsGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <services>
    <service behaviorConfiguration="ServBehave" name="FILE_WCF.Srv">
      <endpoint address="" binding="customBinding" bindingConfiguration="custBind"
        contract="FILE_WCF.ISrv" />
    </service>
  </services>
  <bindings>

    <customBinding>
      <binding name="custBind">
        <binaryMessageEncoding></binaryMessageEncoding>
        <httpsTransport></httpsTransport>
      </binding>
    </customBinding>
  </bindings>

  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

</configuration>

这是 SVC 文件

<%@ ServiceHost Language="VB" Debug="true" Service="FILE_WCF.Srv" CodeBehind="FILE.svc.vb" %>
于 2012-06-19T16:16:03.737 回答
0

代替

security mode="None"

利用

security mode="None"
于 2012-05-16T14:16:49.773 回答