SL 与 WCF 连接分为两种情况:
1.非跨域访问:
新建一个WCF项目,然后在WCF项目下加入sl,然后在sl里面加入WCF的客户端.
Binding binding = new BasicHttpBinding();
EndPointAddress endPoint = new EndPointAddress(http://localhost:2983/BlogService.asmx);
BlogClient client = new BlogClient(binding,endPoint);
这个时候需要注意的是要修改WCF项目的配置,把配置文件里改为
<endpoint address=/"/" binding=/"basicHttpBinding/" contract=/"WcfBlogSl.IBlog/" .....................
在这里把Binding的值由wsHttpBinding改为BasicHttpBinding
因为目前的Sl 2.0只支持BasicHttpBinding的WCF
2.跨域访问:
需要在WCF服务项目里加放crossdomain.xml