在WCF使用SOAP1.1
2010-10-18 23:10
846 查看
如果要在WCF中使用SOAP1.1.,使用basicHttpBinding可以很容易实现,basicHttpBinding默认使用SOAP1.1.。利用自带的例子配置binding为basicHttpBinding:
客户端引用WCF,代码:
利用tcpTrace截包,使用basicHttpBinding截包数据:
可以看出使用的是SOAP1.1(SOAP1.1有SOAPAction项,SOAP1.2没有,当然SOAP1.2和1.1还有其他的区别,具有请查看w3的文档)。
wsHttpBinding默认使用SOAP1.2(确切应该是Soap12WSAddressing10),修改配置文件:
使用wsHttpBinding截包数据:
wsHttpBinding默认是使用Message的传输方式。
basicHttpBinding默认是使用soap1.1,但是basicHttpBinding是明文传输的,wsHttpBinding可以实现加密传输,但soap是soap1.2;可以利用自定义绑定(customBinding)设置soap版本为soap1.1,并且使用加密等传输方式:
使用Soap11AddressBinding截包数据:
<?xmlversion="1.0"?>
<configuration>
<system.web>
<compilationdebug="true"targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behaviorname="WcfService1.Service1Behavior">
<serviceMetadatahttpGetEnabled="true"/>
<serviceDebugincludeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironmentmultipleSiteBindingsEnabled="true"/>
<services>
<servicebehaviorConfiguration="WcfService1.Service1Behavior"
name="WcfService1.Service1">
<endpointaddress=""binding="basicHttpBinding"
contract="WcfService1.IService1">
<identity>
<dnsvalue="localhost"/>
</identity>
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modulesrunAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
客户端引用WCF,代码:
staticvoidMain(string[]args)
{
localhost.Service1Clientclient=newlocalhost.Service1Client();
client.GetData(1);
}
利用tcpTrace截包,使用basicHttpBinding截包数据:
可以看出使用的是SOAP1.1(SOAP1.1有SOAPAction项,SOAP1.2没有,当然SOAP1.2和1.1还有其他的区别,具有请查看w3的文档)。
wsHttpBinding默认使用SOAP1.2(确切应该是Soap12WSAddressing10),修改配置文件:
<?xmlversion="1.0"?>
<configuration>
<system.web>
<compilationdebug="true"targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behaviorname="WcfService1.Service1Behavior">
<serviceMetadatahttpGetEnabled="true"/>
<serviceDebugincludeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironmentmultipleSiteBindingsEnabled="true"/>
<services>
<servicebehaviorConfiguration="WcfService1.Service1Behavior"
name="WcfService1.Service1">
<endpointaddress=""binding="wsHttpBinding"
contract="WcfService1.IService1">
<identity>
<dnsvalue="localhost"/>
</identity>
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modulesrunAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
使用wsHttpBinding截包数据:
wsHttpBinding默认是使用Message的传输方式。
basicHttpBinding默认是使用soap1.1,但是basicHttpBinding是明文传输的,wsHttpBinding可以实现加密传输,但soap是soap1.2;可以利用自定义绑定(customBinding)设置soap版本为soap1.1,并且使用加密等传输方式:
<?xmlversion="1.0"?>
<configuration>
<system.web>
<compilationdebug="true"targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behaviorname="WcfService1.Service1Behavior">
<serviceMetadatahttpGetEnabled="true"/>
<serviceDebugincludeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironmentmultipleSiteBindingsEnabled="true"/>
<services>
<servicebehaviorConfiguration="WcfService1.Service1Behavior"
name="WcfService1.Service1">
<endpointaddress=""binding="customBinding"bindingConfiguration="Soap11AddressingBinding"
contract="WcfService1.IService1">
<identity>
<dnsvalue="localhost"/>
</identity>
</endpoint>
</service>
</services>
<bindings>
<customBinding>
<bindingname="Soap11AddressingBinding">
<textMessageEncodingmessageVersion="Soap11WSAddressing10"/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modulesrunAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
使用Soap11AddressBinding截包数据:
相关文章推荐
- 深入探索SOAP1.1--使用SAAJ1.2.1(转)
- 在WCF中使用Ninject轻量级IOC框架 之 SOAP风格服务
- cxf生成endpoint,使用soap1.1和soap1.2
- Socket使用SOAP调用WCF
- 深入探索SOAP1.1--使用SAAJ1.2.1
- 深入探索SOAP1.1--使用SAAJ1.2.1(转)
- webservice使用的soap协议由soap1.1改成soap1.2
- 深入探索SOAP1.1--使用SAAJ1.2.1
- WCF服务中的方法使用httpwebquest时网站无法响应HTTP/1.1_Server Too Busy
- 使用wireshark抓取wcf生成的soap消息
- iOS-90-调用后台接口(WCF,soap访问方式,接口后缀.svc形式),使用WSDL2objc工具才能搞定
- 在WCF中使用Ninject轻量级IOC框架 之 SOAP风格服务
- 使用HttpClient工具类测试WebService接口(soap)
- WebService大讲堂之Axis2(10):使用soapmonitor模块监视soap请求与响应消息
- 在 WCF 中使用高效的 BinaryFormatter 序列化
- 不要在WCF service中使用TypedDataset或DataTable作为数据传输载体
- C# .NET 0配置使用Wcf
- 打包一个使用SOAP应用的客户端需要什么?
- Java使用soap调用qq在线状态
- 使用WCF实现SOA面向服务编程—— 架构设计