Json   发布时间:2022-04-22  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使用JSONP over SSL的WCF服务大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我们有一个SSL配置的网站,托管WCF服务.服务的绑定具有crossDomainScriptAccessEnabled =“true”,并且使用JSON序列化通信.

当我们从http请求此服务时,它返回JSONP,但是当使用httpS请求它时它只返回JSON.我需要以任何一种方式使用JSONP,请帮忙.

目前的配置是这样的

<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>
如果您使用此配置会发生什么:
<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>

问题是,如果要通过httphttpS调用服务,则必须提供两个端点 – 一个用于http,一个用于https.

大佬总结

以上是大佬教程为你收集整理的使用JSONP over SSL的WCF服务全部内容,希望文章能够帮你解决使用JSONP over SSL的WCF服务所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。