开发者

WCF service with JSONP over SSL

开发者 https://www.devze.com 2023-02-14 23:26 出处:网络
We have a SSL configured website that hosts a WCF-service. The service\'s binding has crossDomainScriptAccessEnabled=\"true\" and communication is serialized using JSON.

We have a SSL configured website that hosts a WCF-service. The service's binding has crossDomainScriptAccessEnabled="true" and communication is serialized using JSON.

When we request this service from http it returns JSONP but when it is requested using HTTPS it returns just JSON. I need to have JSONP in either way, please help.

Current con开发者_StackOverflow社区figuration is like this:

<webHttpBinding>
        <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
</webHttpBinding>

<behaviors>
            <serviceBehaviors>
                <behavior name="JsonServiceBehaviors">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
            <endpointBehaviors><behavior name="webHttpBehavior">
                <webHttp />
            </behavior></endpointBehaviors>
</behaviors>

<services>
            <service name="Backend.CIService" behaviorConfiguration="JsonServiceBehaviors">
                <endpoint address="" binding="webHttpBinding" 
                          bindingConfiguration="webHttpBindingWithJsonP" contract="Backend.ICIService"
                          behaviorConfiguration="webHttpBehavior"/>
            </service></services>


What happens if you use this configuration:

<webHttpBinding>
  <binding name="jsonp" crossDomainScriptAccessEnabled="true" />
  <binding name="jsonpSsl" crossDomainScriptAccessEnabled="true">
    <security mode="Transport" />
  </binding>
</webHttpBinding>

<behaviors>
  <serviceBehaviors>
    <behavior name="JsonServiceBehaviors">
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="webHttpBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
</behaviors>

<services>
  <service name="Backend.CIService" behaviorConfiguration="JsonServiceBehaviors">
    <endpoint address="" binding="webHttpBinding" 
      bindingConfiguration="jsonp" contract="Backend.ICIService"
      behaviorConfiguration="webHttpBehavior"/>
    <endpoint address="" binding="webHttpBinding" 
      bindingConfiguration="jsonpSsl" contract="Backend.ICIService"
      behaviorConfiguration="webHttpBehavior"/>
  </service>
</services>

The problem is that if you want to call service over both HTTP and HTTPS you must provide two endpoints - one for HTTP and one for HTTPS.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号