【发布时间】:2017-03-07 21:26:31
【问题描述】:
我使用 asp.net vb 创建了一个 REST api,我试图通过安全连接 (https) 调用该 api,但出现错误
The resource cannot be found
我可以使用 (http) 调用任何方法,但使用 (https) 我不能。我可以使用(https)访问api(service.svc)的主页,但是功能有问题!下面是我的配置和函数头。
<system.serviceModel>
<services>
<service name="RESTAPI" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="customBinding" binding="customBinding" bindingConfiguration="basicConfig" contract="RESTAPI"/>
<endpoint address="" behaviorConfiguration="HerbalAPIAspNetAjaxBehavior"
binding="webHttpBinding" contract="HerbalAPI" />
<endpoint contract="RESTAPI" binding="mexHttpBinding" address="mex" />
</service>
</services>
<!-- **** Services ****-->
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="HerbalAPIAspNetAjaxBehavior">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="basicConfig">
<binaryMessageEncoding/>
<httpTransport transferMode="Streamed" maxReceivedMessageSize="67108864"/>
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
API 类
<ServiceContract(Namespace:="")>
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
Public Class RESTAPI
<OperationContract()>
<WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json)>
Public Function test(ByVal st As String) As JSONResultString
//any code
End Function
End Class
【问题讨论】:
-
您是否在本地机器上通过 HTTPS/HTTP 运行服务?
-
在本地机器 HTTP 和服务器 HTTPS 上(在服务器上测试)