English 中文(简体)
需要帮助,让青年在SSL上工作
原标题:Need help getting getJSON to work over SSL

我有服务

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public Customer GetCustomer(string customerNumber)
{
    return _service.GetCustomer(customerNumber);
}

我用j Query从网页上打电话

    var customerNumber =  123456 ;
    $.getJSON( /JsonServices/B2BServiceJson.svc/GetCustomer , { customerNumber: customerNumber }, customerSelected);

下面是呼唤正义者的呼声:

// 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 -->

This worked fine until I enabled SSL on my servers. Now the getJSON call succeeds but returns null. Please help me get this working over SSL. Thanks

我的环境是:Net 3.5, IIS 7

最佳回答

这是我结束的工作,它非常完美。

  <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>
问题回答

我提议使用:

<serviceMetadata httpsGetEnabled="true"/>

以及一个具有约束力的网站:

 <endpoint address="mex" 
           binding="mexHttpsBinding" 
           contract="IMetadataExchange"/>

页: 1 模式配置。

<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>

有几个工作要做:

  1. Check for errors, either on the web server, jquery ( by adding an error function to the Ajax call parameter list), maybe try a http watcher to see what response is coming back from the server.
  2. Is the page itself accessed via ssl?
  3. Is the certificate you have used on the server trusted by the browser? In an Ajax call you can t manually accept a certitude with trust warnings so this may explain what is taking place.




相关问题
ssl on login form?

I have SSL on my website....when the user logs in from a http page the form action is sent to https page, would this still secure the posted data? Or would it be better to have the form and the page ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Why can t I find the truststore for an SSL handshake?

I m using the Spring RESTTemplate on the client side to make calls to a REST endpoint. The client in this case is a Spring app and Tomcat is the servlet container. I m running into issues making a ...

To add more parameter for my http header for SSL/TLS

As far as I understand, https is http plus SSL/TLS. What do I need to do if I want to add 3 more parameters for the header? I found a file inside Mozilla s NSS - ssl3ext.c, but I don t understand it ...

Why am I getting handshake_failure with Java SSL cert?

I m trying to use Hudson (which uses SVNKit) to access a Subversion repository that requires a client certificate to access it. I can access the same repository using the same client certificate via ...

热门标签