(转)webHttpBinding、basicHttpBinding和wsHttpBinding区别

(1)webHttpBinding与basicHttpBinding / wsHttpBinding的区别:

  • webHttpBinding is the REST-style binding, where you basically just hit a URL and get back a truckload of XML or JSON from the web service

  • basicHttpBinding and wsHttpBinding are two SOAP-based bindings which is quite different from REST. SOAP has the advantage of having WSDL and XSD to describe the service, its methods, and the data being passed around in great detail (REST doesn't have anything like that - yet). On the other hand, you can't just browse to a wsHttpBinding endpoint with your browser and look at XML - you have to use a SOAP client, e.g. the WcfTestClient or your own app

(2)basicHttpBinding与wsHttpBinding的区别

  • basicHttpBinding is the very basic binding - SOAP 1.1, not much in terms of security, not much else in terms of features - but compatible to just about any SOAP client out there --> great for interoperability, weak on features and security

  • wsHttpBinding is the full-blown binding, which supports a ton of WS-* features and standards - it has lots more security features, you can use sessionful connections, you can use reliable messaging, you can use transactional control, you can use streaming for large data - just a lot more stuff, but wsHttpBinding is also a lot *heavier" and adds a lot of overhead to your messages as they travel across the network











本文转自JF Zhu博客园博客,原文链接: http://www.cnblogs.com/jfzhu/p/4044403.html   ,如需转载请自行联系原作者







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 WCF 中接收 `uni.uploadFile` 文件,你可以按照以下步骤进行操作: 1. 首先,在 WCF 服务的契约中定义一个操作合同,用于接收文件。例如: ```csharp [ServiceContract] public interface IFileService { [OperationContract] void UploadFile(Stream fileData); } ``` 2. 在服务实现类中,实现该操作合同。在方法中,你可以使用 `Stream` 类型的参数接收文件数据。例如: ```csharp public class FileService : IFileService { public void UploadFile(Stream fileData) { // 处理文件数据 // 可以使用流操作、保存到磁盘、或者进行其他自定义操作 } } ``` 3. 在服务的配置文件中,配置绑定和终结点。你可以使用基于 HTTP 的绑定,如 `basicHttpBinding` 或 `webHttpBinding`。例如: ```xml <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IFileService" /> </basicHttpBinding> </bindings> <services> <service name="YourNamespace.FileService"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFileService" contract="YourNamespace.IFileService" /> </service> </services> </system.serviceModel> ``` 4. 在客户端调用代码中,引用服务契约并创建代理对象。然后,可以使用代理对象调用 `UploadFile` 方法并传递文件数据。例如: ```csharp using (var client = new FileServiceClient()) { using (var fileStream = File.OpenRead("path/to/file")) { client.UploadFile(fileStream); } } ``` 这样,你就可以在 WCF 中成功接收 `uni.uploadFile` 的文件数据。记得根据实际需求进行适当的异常处理和文件操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值