本文整理汇总了C#中System.Web.Services.Description.SoapFaultBinding类的典型用法代码示例。如果您正苦于以下问题:C# SoapFaultBinding类的具体用法?C# SoapFaultBinding怎么用?C# SoapFaultBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SoapFaultBinding类属于System.Web.Services.Description命名空间,在下文中一共展示了SoapFaultBinding类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Web.Services.Description;
public class MySoapFaultBindingSample
{
public static void Main()
{
try
{
// Input wsdl file.
string myInputWsdlFile="SoapFaultBindingInput_cs.wsdl";
// Output wsdl file.
string myOutputWsdlFile="SoapFaultBindingOutput_cs.wsdl";
// Initialize an instance of a 'ServiceDescription' object.
ServiceDescription myServiceDescription =
ServiceDescription.Read(myInputWsdlFile);
// Get a SOAP binding object with binding name "MyService1Soap".
Binding myBinding=myServiceDescription.Bindings["MyService1Soap"];
// Create a new instance of 'SoapFaultBinding' class.
SoapFaultBinding mySoapFaultBinding=new SoapFaultBinding();
// Encode fault message using rules specified by 'Encoding' property.
mySoapFaultBinding.Use=SoapBindingUse.Encoded;
// Set the URI representing the encoding style.
mySoapFaultBinding.Encoding="http://tempuri.org/stockquote";
// Set the URI representing the location of the specification
// for encoding of content not defined by 'Encoding' property'.
mySoapFaultBinding.Namespace="http://tempuri.org/stockquote";
// Create a new instance of 'FaultBinding'.
FaultBinding myFaultBinding=new FaultBinding();
myFaultBinding.Name="AddFaultbinding";
myFaultBinding.Extensions.Add(mySoapFaultBinding);
// Get existing 'OperationBinding' object.
OperationBinding myOperationBinding=myBinding.Operations[0];
myOperationBinding.Faults.Add(myFaultBinding);
// Create a new wsdl file.
myServiceDescription.Write(myOutputWsdlFile);
Console.WriteLine("The new wsdl file created is :"
+myOutputWsdlFile);
Console.WriteLine("Proxy could be created using command : wsdl "
+ myOutputWsdlFile);
}
catch(Exception e)
{
Console.WriteLine("Error occurred : "+e.Message);
}
}
}