本文整理汇总了C#中System.Web.Services.Description.SoapHeaderBinding类的典型用法代码示例。如果您正苦于以下问题:C# SoapHeaderBinding类的具体用法?C# SoapHeaderBinding怎么用?C# SoapHeaderBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SoapHeaderBinding类属于System.Web.Services.Description命名空间,在下文中一共展示了SoapHeaderBinding类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Web.Services.Description;
using System.Collections;
using System.Xml;
public class MySampleClass
{
public static void Main()
{
ServiceDescription myServiceDescription =
ServiceDescription.Read("SoapHeaderBindingInput_cs.wsdl");
Binding myBinding = new Binding();
myBinding.Name = "MyWebServiceSoap";
myBinding.Type =new XmlQualifiedName("s0:MyWebServiceSoap");
SoapBinding mySoapBinding =new SoapBinding();
mySoapBinding.Transport="http://schemas.xmlsoap.org/soap/http";
mySoapBinding.Style=SoapBindingStyle.Document;
myBinding.Extensions.Add(mySoapBinding);
OperationBinding myOperationBinding = new OperationBinding();
myOperationBinding.Name = "Hello";
SoapOperationBinding mySoapOperationBinding =
new SoapOperationBinding();
mySoapOperationBinding.SoapAction = "http://tempuri.org/Hello";
mySoapOperationBinding.Style=SoapBindingStyle.Document;
myOperationBinding.Extensions.Add(mySoapOperationBinding);
// Create InputBinding for operation for the 'SOAP' protocol.
InputBinding myInputBinding = new InputBinding();
SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();
mySoapBodyBinding.Use = SoapBindingUse.Literal;
myInputBinding.Extensions.Add(mySoapBodyBinding);
SoapHeaderBinding mySoapHeaderBinding=new SoapHeaderBinding();
mySoapHeaderBinding.Message=new XmlQualifiedName("s0:HelloMyHeader");
mySoapHeaderBinding.Part="MyHeader";
mySoapHeaderBinding.Use=SoapBindingUse.Literal;
// Add mySoapHeaderBinding to 'myInputBinding' object.
myInputBinding.Extensions.Add(mySoapHeaderBinding);
// Create OutputBinding for operation for the 'SOAP' protocol.
OutputBinding myOutputBinding = new OutputBinding();
myOutputBinding.Extensions.Add(mySoapBodyBinding);
// Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'.
myOperationBinding.Input = myInputBinding;
myOperationBinding.Output = myOutputBinding;
myBinding.Operations.Add(myOperationBinding);
myServiceDescription.Bindings.Add(myBinding);
myServiceDescription.Write("SoapHeaderBindingOut_cs.wsdl");
Console.WriteLine("'SoapHeaderBindingOut_cs.wsdl' file is generated.");
Console.WriteLine("Proxy could be created using "
+"'wsdl SoapHeaderBindingOut_cs.wsdl'.");
}
}
开发者ID:.NET开发者,项目名称:System.Web.Services.Description,代码行数:57,代码来源:SoapHeaderBinding
注:本文中的System.Web.Services.Description.SoapHeaderBinding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论