免费1级做爰网站,wordpress数据库批量替换,免费浏览网站的软件,厅网站集约化建设构建一个简单的WCF服务。以Web服务类似的步骤由IIS进行宿主服务。建立的步骤#xff1a;1 新建3.5网站2 添加WCF服务#xff0c;自动生成契约接口与实现#xff0c;这里改动一下#xff0c;添加个字串参数#xff1a;[ServiceContract]public interface IFirstService{[Op…构建一个简单的WCF服务。 以Web服务类似的步骤由IIS进行宿主服务。建立的步骤 1 新建3.5网站 2 添加WCF服务自动生成契约接口与实现这里改动一下添加个字串参数 [ServiceContract] public interface IFirstService { [OperationContract] void DoWork(string strContent); } 服务中的方法什么都不用做。 public class FirstService : IFirstService { public void DoWork(string strContent) { } } 在添加WCF服务时会自动在配置文件中添加必要的章节例如绑定和元数据发布。 system.serviceModel behaviors serviceBehaviors behavior nameFirstServiceBehavior serviceMetadata httpGetEnabledtrue / serviceDebug includeExceptionDetailInFaultsfalse / /behavior /serviceBehaviors /behaviors services service behaviorConfigurationFirstServiceBehavior nameFirstService endpoint address bindingbasicHttpBinding contractIFirstService identity dns valuelocalhost / /identity /endpoint endpoint addressmex bindingmexHttpBinding contractIMetadataExchange / /service /services /system.serviceModel 这里把绑定改一下改为basicHttpBinding。 然后在测试端新建立类库项目由发布的元数据生成代理然后进行服务请求 [Test] public void Test() { FirstInstance.FirstServiceClient client New FirstInstance.FirstServiceClient(); client.DoWork(this is a test!); } 现在看一下消息包的情况 这是客户端请求的信息 s:Envelope xmlns:shttp://schemas.xmlsoap.org/soap/envelope/ s:Body DoWork xmlnshttp://tempuri.org/ strContentthis is a test!/strContent /DoWork /s:Body /s:Envelope 这是服务端回应的信息 s:Envelope xmlns:shttp://schemas.xmlsoap.org/soap/envelope/ s:Body DoWorkResponse xmlnshttp://tempuri.org// /s:Body /s:Envelope 对于BasicHttpBinding来说它通过http来发送soap1.1的消息。这个绑定用于配置和公开能够与基于asmx的web service和客户端进行通信的终结点以及符合ws-i basic profile 1.1标准的其它服务。 通过设置WCF绑定的消息编码格式来设置传输过程中所使用的编码 basicHttpBinding binding namefirstBinding messageEncodingText /binding /basicHttpBinding 现设置BasicHttp绑定的消息编码为文本当传输二进制附件时会怎么用base64编码 s:Envelope xmlns:shttp://schemas.xmlsoap.org/soap/envelope/ s:Body SaveImage xmlnswww.self001.com bbGMDggAOw/bb /SaveImage /s:Body /s:Envelope 其中附件部分我省略了大部分只留一小段。 当使用MTOM编码格式时 --uuid:deef670a-dfd7-4a71-8d89-face6ac975ddid1 Content-ID: http://tempuri.org/0 Content-Transfer-Encoding: 8bit Content-Type: application/xopxml;charsetutf-8;typetext/xml s:Envelope xmlns:shttp://schemas.xmlsoap.org/soap/envelope/ s:Body SaveImage xmlnswww.self001.com bb xop:Include hrefcid:http%3A%2F%2Ftempuri.org%2F1%2F634057273450156250 xmlns:xophttp://www.w3.org/2004/08/xop/include/ /bb /SaveImage /s:Body /s:Envelope --uuid:deef670a-dfd7-4a71-8d89-face6ac975ddid1 Content-ID: http://tempuri.org/1/634057273450156250 Content-Transfer-Encoding: binary Content-Type: application/octet-stream GIF89ad……省略 --uuid:deef670a-dfd7-4a71-8d89-face6ac975ddid1-- 这与WSE3中使用的MTOM是相同的。转载于:https://www.cnblogs.com/jams742003/archive/2010/04/01/1702277.html