SoapFaultBinding 类

定义

表示添加到 XML Web services 中的 FaultBinding 的扩展性元素。

public ref class SoapFaultBinding : System::Web::Services::Description::ServiceDescriptionFormatExtension
[System.Web.Services.Configuration.XmlFormatExtension("fault", "http://schemas.xmlsoap.org/wsdl/soap/", typeof(System.Web.Services.Description.FaultBinding))]
public class SoapFaultBinding : System.Web.Services.Description.ServiceDescriptionFormatExtension
[<System.Web.Services.Configuration.XmlFormatExtension("fault", "http://schemas.xmlsoap.org/wsdl/soap/", typeof(System.Web.Services.Description.FaultBinding))>]
type SoapFaultBinding = class
    inherit ServiceDescriptionFormatExtension
Public Class SoapFaultBinding
Inherits ServiceDescriptionFormatExtension
继承
派生
属性

示例

#using <System.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::Web::Services::Description;

int main()
{
   try
   {
      // Input wsdl file.
      String^ myInputWsdlFile = "SoapFaultBindingInput_cpp.wsdl";

      // Output wsdl file.
      String^ myOutputWsdlFile = "SoapFaultBindingOutput_cpp.wsdl";

      // Initialize an instance of a 'ServiceDescription' object.
      ServiceDescription^ myServiceDescription = ServiceDescription::Read( myInputWsdlFile );

      // Get a SOAP binding object with binding name S"MyService1Soap".
      Binding^ myBinding = myServiceDescription->Bindings[ "MyService1Soap" ];

      // Create a new instance of 'SoapFaultBinding' class.
      SoapFaultBinding^ mySoapFaultBinding = gcnew 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 = gcnew 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 : {0}", myOutputWsdlFile );
      Console::WriteLine( "Proxy could be created using command : wsdl {0}", myOutputWsdlFile );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Error occurred : {0}", e->Message );
   }
}
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);
      }
   }
}
Imports System.Web.Services.Description

Public Class MySoapFaultBindingSample
   
   Public Shared Sub Main()
      Try
         ' Input wsdl file.
         Dim myInputWsdlFile As String = "SoapFaultBindingInput_vb.wsdl"
         ' Output wsdl file.
         Dim myOutputWsdlFile As String = "SoapFaultBindingOutput_vb.wsdl"
         ' Initialize an instance of a 'ServiceDescription' object.
         Dim myServiceDescription As ServiceDescription = ServiceDescription.Read(myInputWsdlFile)
         ' Get a SOAP binding object with binding name "MyService1Soap". 
         Dim myBinding As Binding = myServiceDescription.Bindings("MyService1Soap")
         ' Create a new instance of 'SoapFaultBinding' class.
         Dim mySoapFaultBinding As 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'.
         Dim myFaultBinding As New FaultBinding()
         myFaultBinding.Name = "AddFaultbinding"
         myFaultBinding.Extensions.Add(mySoapFaultBinding)
         ' Get existing 'OperationBinding' object.
         Dim myOperationBinding As OperationBinding = 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 /language:VB " + myOutputWsdlFile)
      Catch e As Exception
         Console.WriteLine("Error occurred : " + e.Message.ToString())
      End Try
   End Sub
End Class

注解

此类指定返回的任何 SOAP 错误消息的内容。

有关为 XML Web 服务指定协议的详细信息,请参阅 XML Web Services Using ASP.NET。 有关 Web 服务描述语言 (WSDL) 的详细信息,请参阅 WSDL 规范。

构造函数

SoapFaultBinding()

初始化 SoapFaultBinding 类的实例。

属性

Encoding

获取或设置一个 URI,它表示用于对 SOAP 错误信息进行编码的编码样式。

Handled

获取或设置一个值,该值指示当导入扩展性元素时,导入进程是否使用 ServiceDescriptionFormatExtension

(继承自 ServiceDescriptionFormatExtension)
Name

获取或设置名称特性的值,该名称特性使 soap 错误和为指定操作定义的 wsdl 错误相关。

Namespace

获取或设置一个 URI,该 URI 表示 Encoding 属性未具体定义的内容编码规范的位置。

Parent

获取 ServiceDescriptionFormatExtension 的父级。

(继承自 ServiceDescriptionFormatExtension)
Required

获取或设置一个值,该值指示 ServiceDescriptionFormatExtension 是否是它所引用的操作所必需的。

(继承自 ServiceDescriptionFormatExtension)
Use

指定错误信息是使用由 Encoding 属性指定的规则进行编码,还是封装在具体的 XML 架构中。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于