zoukankan      html  css  js  c++  java
  • wcf实现跨域访问所需的配置文件

    在wcf跨域访问操作的时候,需要用户自定义文件、来明确访问用户的身份和非法用户登录,日记录文件如下:

    一、在WCF项目根目录下添加clientaccesspolicy.xml文件

    <?xml version="1.0" encoding="utf-8"?><access-policy>   <cross-domain-access>     <policy>       <allow-from http-request-headers="*">         <domain uri="*"/>       </allow-from>       <grant-to>         <resource path="/" include-subpaths="true"/>       </grant-to>     </policy>   </cross-domain-access></access-policy>

    二、在客户端应用项目中添加一个中介类ServerManager.cs

    publicclass ServerManager     {      

       privatestatic ServiceWcfClient servicePicture =new ServiceWcfClient();
           
    internalstatic ServiceWcfClient GetPox()       

      {        

         if (servicePicture.State == System.ServiceModel.CommunicationState.Created)          

       {          

           servicePicture.Endpoint.Address =new System.ServiceModel.EndpointAddress("http://localhost:52207/ServiceWcf.svc");                      return servicePicture;     

            }        

         else  

               {      

               return servicePicture;         

        }       

      }  

       }

    这样形成共同的契约、来确定访问用户的身份安全性

    三、实例化实体类的时候一般是这样:

    ServiceWcfClient clientWcf = new ServiceWcfClient();

            换成:ServiceWcfClient clientWcf = ServerManager.GetPox();

  • 相关阅读:
    SPU和SKU有什么区别
    Mave手动安装jar包
    maven国内镜像(国内oschina的maven服务器关了)
    用java代码将从数据库中取出的具有父子关系的数据转成json格式
    Oracle中的decode()函数
    Oracle中的instr()函数
    Oracle的nvl
    Oracle保留小数点后两位的几种方法
    【Python】djangorestframework 基于django框架的接口开发
    【MySQL】 GTID使用
  • 原文地址:https://www.cnblogs.com/zhijianliutang/p/2250584.html
Copyright © 2011-2022 走看看