我有服务
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public Customer GetCustomer(string customerNumber)
{
return _service.GetCustomer(customerNumber);
}
我使用jQuery从网页调用
var customerNumber = '123456';
$.getJSON('/JsonServices/B2BServiceJson.svc/GetCustomer', { customerNumber: customerNumber }, customerSelected);
以下是getJSON调用的回调:
// HELP! result is null when SSL is enabled
function customerSelected(result) {
var customer = result.GetCustomerResult;
var email = customer.Email;
// other stuff
}
这是配置
<system.serviceModel>
<services>
<service name="B2B.JsonServices.B2BServiceJson">
<endpoint address="" binding="webHttpBinding" contract="B2B.JsonServices.B2BServiceJson"
behaviorConfiguration="ajaxBehavior" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="ajaxBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<!-- other stuff -->
在我的服务器上启用SSL之前,此工作正常。现在getJSON调用成功但返回null。 请帮我解决这个问题。感谢
我的环境是.Net 3.5,IIS 7
答案 0 :(得分:1)
这就是我最终的结果,它完美无瑕。
<system.serviceModel>
<services>
<service name="B2B_lite.JsonServices.B2BLiteServiceJson">
<!-- SSL -->
<endpoint address="" binding="webHttpBinding" contract="B2B.JsonServices.B2BServiceJson"
bindingConfiguration="webHttpsBinding" behaviorConfiguration="restBehavior"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="restBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpsBinding" closeTimeout="00:00:20">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
答案 1 :(得分:0)
我建议使用:
<serviceMetadata httpsGetEnabled="true"/>
和https绑定:
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"/>
在您的serviceModel配置中。
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="Transport">
<transport clientCredentialType ="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service
behaviorConfiguration="App_WcfWebService.AppWebServiceBehavior"
name="App_WcfWebService.AppWebService">
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration ="wsHttpEndpointBinding"
contract="App_WcfWebService.IAppWebService">
</endpoint>
<endpoint
address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="App_WcfWebService.AppWebServiceBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentSessions="90" />
</behavior>
</serviceBehaviors>
</behaviors>
答案 2 :(得分:0)
要做的一些事情: