SoapException.Code プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SoapException.Code プロパティの意味・解説 

SoapException.Code プロパティ

SOAP 違反コード種類取得します

名前空間: System.Web.Services.Protocols
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

Dim instance As SoapException
Dim value As XmlQualifiedName

value = instance.Code
public XmlQualifiedName Code { get; }
public:
property XmlQualifiedName^ Code {
    XmlQualifiedName^ get ();
}
/** @property */
public XmlQualifiedName get_Code ()
public function get Code
 () : XmlQualifiedName

プロパティ
発生した SOAP 違反コード指定する XmlQualifiedName。

解説解説

SoapException クラス新しインスタンス作成している場合だけ、Code プロパティ設定できます

SoapException クラスは、SOAP 経由XML Web サービス メソッド呼び出す XML Web サービス クライアント使用します呼び出しを行うクライアントSOAP使用するかどうかは、ASP.NET によって処理されます。このとき、XML Web サービス例外発生しますクライアントSOAP使用している場合ASP.NET はこの例外SoapExceptionラップし、Actor プロパティCode プロパティ設定します

SOAP プロトコル Version 1.1SOAP 違反コードとして利用できるコードの一覧次に示します

項目

説明

VersionMismatchFaultCode

SOAP エンベロープ無効な名前空間が見つかりました

MustUnderstandFaultCode

一部SOAP 要素は処理を省略できます。ただし、値が 1 の MustUnderstand 属性SOAP 要素マークされている場合は、その要素処理する必要があります要素を処理できなかった場合、この例外生成されます。

ClientFaultCode

クライアントによる呼び出し書式正しく設定されていませんでした。またはクライアントによる呼び出し適切な情報含まれていませんでした。たとえば、クライアント呼び出し適切な認証情報または支払い情報含まれていませんでした一般的に、この違反コードは、メッセージ再送信する前にその内容変更する必要があることを示します

ServerFaultCode

クライアントによる呼び出しサーバー処理しているときに、メッセージ内容以外の原因によりエラー発生しました。たとえば、ネットワーク障害のため、アップストリーム サーバー要求応答できなかった場合などです。通常、この種類の例外が発生した場合でも、クライアントによる呼び出しは後から成功しますXML Web サービスSoapException 以外の例外スローし、クライアントによる呼び出しSOAP使用している場合ASP.NET はこの例外SoapException変換しCode プロパティServerFaultCode設定して、これをクライアントスローます。

使用例使用例

0 での除算発生した場合例外スローする Math Web サービス メソッド呼び出す Web フォームの例を次に示します例外スローされると、この Web フォーム例外受け取りActor プロパティおよび Code プロパティを含む例外詳細を、HtmlTable コントロール出力します

<%@ Page Language="VB"%>
<html>
 <head>
 <script runat=server language="VB">
Sub Page_Load(o As Object,
 e As EventArgs)    
    Dim UsageCount As Integer
    ' Create a new instance of the proxy class.
    Dim math As New MyMath.Math()
    ' Make a call to the Math XML Web service, which throws an exception.
    Try
        math.Divide(3, 0)
    Catch err As System.Web.Services.Protocols.SoapException
        ' Populate our Table with the Exception details
        ErrorTable.Rows.Add(BuildNewRow("Fault Code Namespace",
 err.Code.Namespace))
        ErrorTable.Rows.Add(BuildNewRow("Fault Code Name",
 err.Code.Name))
        ErrorTable.Rows.Add(BuildNewRow("SOAP Actor that threw
 Exception", err.Actor))
        ErrorTable.Rows.Add(BuildNewRow("Error Message",
 err.Message))
        Return
    End Try
End Sub 'Page_Load


Function BuildNewRow(Cell1Text As String,
 Cell2Text As String) As
 HtmlTableRow
    Dim row As New HtmlTableRow()
    Dim cell1 As New HtmlTableCell()
    Dim cell2 As New HtmlTableCell()
    
    ' Set the contents of the two cells.
    cell1.Controls.Add(New LiteralControl(Cell1Text))
    ' Add the cells to the row.
    row.Cells.Add(cell1)
    
    cell2.Controls.Add(New LiteralControl(Cell2Text))
    
    ' Add the cells to the row.
    row.Cells.Add(cell2)
    Return row
End Function 'BuildNewRow
 </script>
 </head>
 <body>
     <table id="ErrorTable"
        CellPadding=5 
        CellSpacing=0 
        Border="1" 
        BorderColor="black" 
        runat="server" />
 </body>
<%@ Page Language="C#" %>
<html>
 <head>
 <script runat=server language="C#">
   void Page_Load(Object o, EventArgs e)
   {
     
   int UsageCount;
   // Create a new instance of the proxy class.
   MyMath.Math math = new MyMath.Math(); 
   // Make a call to the Math XML Web service, which throws an exception.
   try
       {
       math.Divide(3, 0);
       }
   catch (System.Web.Services.Protocols.SoapException error)
       {
       // Populate the table with the exception details.
       ErrorTable.Rows.Add(BuildNewRow("Fault Code Namespace", error.Code.Namespace));
       ErrorTable.Rows.Add(BuildNewRow("Fault Code Name", error.Code.Name));
        
       ErrorTable.Rows.Add(BuildNewRow("SOAP Actor that threw Exception",
 error.Actor));        
       ErrorTable.Rows.Add(BuildNewRow("Error Message", error.Message));
        
       return;
       }
   }
 
   HtmlTableRow BuildNewRow(string Cell1Text, string
 Cell2Text)
   {
       HtmlTableRow row = new HtmlTableRow();
       HtmlTableCell cell1 = new HtmlTableCell();
       HtmlTableCell cell2 = new HtmlTableCell();
         
       // Set the contents of the two cells.
       cell1.Controls.Add(new LiteralControl(Cell1Text));
       // Add the cells to the row.
       row.Cells.Add(cell1);
     
       cell2.Controls.Add(new LiteralControl(Cell2Text));
     
       // Add the cells to the row.
       row.Cells.Add(cell2);
       return row;
     }
 </script>
 </head>
 <body>
     <table id="ErrorTable"
        CellPadding=5 
        CellSpacing=0 
        Border="1" 
        BorderColor="black" 
        runat="server" />
 </body>

前述Web フォーム次の Math XML Web サービス使用するために、MyMath名前空間プロキシ クラス作成中指定されました。

<%@ WebService Language="VB" Class="Math"%>
Imports System.Web.Services
Imports System

Public Class Math
    Inherits WebService

    <WebMethod()> _
    Public Function Divide(dividend As
 Integer, divisor As Integer)
 As Single
        If divisor = 0 Then
            Throw New DivideByZeroException()
        End If 
        Return Convert.ToSingle(dividend / divisor)
    End Function 'Divide
End Class  'Math
<%@ WebService Language="C#" Class="Math"%>
 using System.Web.Services;
 using System;
 public class Math : WebService {
     [WebMethod]
     public float Divide(int
 dividend, int divisor) {
         if (divisor == 0)
             throw new DivideByZeroException();
 
         return dividend/divisor;
     }
  }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SoapException クラス
SoapException メンバ
System.Web.Services.Protocols 名前空間
XmlQualifiedName
Subcode
HtmlTable
SoapException.Actor プロパティ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SoapException.Code プロパティ」の関連用語

SoapException.Code プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SoapException.Code プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS