本文整理匯總了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);
}
}
}