15

Ajax Call:

   $.ajax({
        type: "POST",
        url: "http://SomeService/ServiceName.svc/GetSearchResults",
        data: JSON.stringify({ parameters: serviceParameters }),
        contentType: "application/json; charset=utf-8",
        dataType: "XML",
        success: function (response) {
            $("#xmlText").text(response.xml);
        },
        error: function (msg) {
            alert(msg.toString);
        }
    })

WCF Interface:

[OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Json,
                    UriTemplate = "GetSearchResults")]
        XElement GetSearchResults(inputParameters parameters);

        [OperationContract]
        [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate = "getFile")]
        Stream GetFile(DocInfo info);

Web.config:

 <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <customErrors mode="Off"/>
  </system.web>

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

 <system.serviceModel>
   <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
   </serviceHostingEnvironment>
   <standardEndpoints>
     <webHttpEndpoint>
       <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
     </webHttpEndpoint>
   </standardEndpoints>
 </system.serviceModel>

The service is hosted on IIS6.

When I call the service I get the following error message:

500 System.ServiceModel.ServiceActivationException

I can call the GetFile method and get the response stream but I get the error message when calling GetSearchResults.

Any help will be appreciated.

4

3 回答 3

16

由于下面提到的原因,我遇到了这个错误

内存门检查失败,因为可用内存(258187264 字节)小于总内存的 5%。因此,该服务将无法用于传入请求。要解决此问题,请减少机器上的负载或调整 serviceHostingEnvironment 配置元素上的 minFreeMemoryPercentageToActivateService 的值。

于 2013-08-23T05:52:55.470 回答
8

非常感谢您鼓舞人心的回复和评论。

我实际上遇到了同样的错误,但故事不同:

起初,我收到“404(未找到)”服务器错误,这是因为我没有用于“HTTPS”的传输,而我已经有用于“HTTP”的传输。

<httpsTransport>我在我的元素中添加了一个<binding>,所以它看起来像这样:

<bindings>
  <customBinding>
    <binding name="CustomBinding_ITheService">
      <httpTransport keepAliveEnabled="True" transferMode="Streamed" authenticationScheme="None" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" manualAddressing="true" />
      <httpsTransport keepAliveEnabled="True" transferMode="Streamed" authenticationScheme="None" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" manualAddressing="true" />
    </binding>
  </customBinding>
</bindings>

然后我得到了500 System.ServiceModel.ServiceActivationException错误。但是,我浏览了“事件查看器 > Windows 日志 > 应用程序”,发现“对于同一个绑定,不能多次定义传输”。因此,我决定为“HTTPS”传输添加一个带有新绑定的附加端点。

最后,我的配置如下所示:

<services>
  <service name="TheService" behaviorConfiguration="WebHttpBehavior_ITheService">
    <endpoint binding="customBinding" bindingConfiguration="CustomBinding_ITheService" contract="ITheService" behaviorConfiguration="EndPointBehavior_ITheService" />
    <endpoint binding="customBinding" bindingConfiguration="CustomBinding_ITheService_Secured" contract="ITheService" behaviorConfiguration="EndPointBehavior_ITheService" />
  </service>
</services>

<bindings>
  <customBinding>
    <binding name="CustomBinding_ITheService">
      <httpTransport keepAliveEnabled="True" transferMode="Streamed" authenticationScheme="None" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" manualAddressing="true" />
    </binding>
    <binding name="CustomBinding_ITheService_Secured">
      <httpsTransport keepAliveEnabled="True" transferMode="Streamed" authenticationScheme="None" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" manualAddressing="true" />
    </binding>
  </customBinding>
</bindings>

然后每件事都按正确的方式进行并完美运行。

如果您在 Visual Studio 上开发并使用 IIS-Express“ Cassini ”,请记住在网站项目的属性中启用 SSL 选项,这会告诉 IIS-Express 为您之前添加到绑定的 HTTPS 传输准备一个基本 URL .

于 2017-07-26T12:59:56.277 回答
1

添加站点绑定转到 IIS => 然后默认网站 => 右键单击​​该 => 编辑绑定 => 单击添加按钮 => 在此处添加 HTTPS 绑定

详细信息在显示的屏幕截图中

于 2021-05-19T08:43:31.530 回答