SoapException クラスとは? わかりやすく解説

SoapException クラス

XML Web サービス メソッドSOAP 経由呼び出され例外発生したときにスローされる例外表します

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

<SerializableAttribute> _
Public Class SoapException
    Inherits SystemException
Dim instance As SoapException
[SerializableAttribute] 
public class SoapException : SystemException
[SerializableAttribute] 
public ref class SoapException : public
 SystemException
/** @attribute SerializableAttribute() */ 
public class SoapException extends SystemException
SerializableAttribute 
public class SoapException extends
 SystemException
解説解説

SoapException は、共通言語ランタイムまたは XML Web サービス メソッドいずれかによってスローされる場合あります共通言語ランタイムは、要求対す応答書式正しく設定されていない場合SoapExceptionスローすることがありますXML Web サービス メソッドは、XML Web サービス メソッド内で単に例外スローすることによって SoapException生成することがありますクライアントSOAP 経由メソッドアクセスした場合例外サーバーキャッチされ、新しSoapException 内にラップされますスローされる SoapException には、次のプロパティ値があります

クライアントによる呼び出しSOAP使用している場合XML Web サービス メソッドSoapExceptionスローすることがありますXML Web サービスSoapExceptionスローする場合は、その他の詳細情報ActorCode、および Detail の各プロパティ使用して追加できます別の種類の例外がスローされた場合は、XML Web サービス メソッドでこれらのプロパティ設定することはできません。

使用例使用例

SoapExceptionスローする例を次に示します。この例では、XML Web サービス メソッドDetail プロパティ設定します

<%@ WebService Language="VB" class="ThrowSoapException"%>

Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization
Imports System.Xml

Public Class ThrowSoapException
    Inherits WebService
    
    ' This XML Web service method generates a SOAP Client Fault code
 
    <WebMethod()> _
    Public Sub myThrow()
        
        ' Build the detail element of the SOAP fault.
        Dim doc As New System.Xml.XmlDocument()
        Dim node As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element,
 _
            SoapException.DetailElementName.Name, _
            SoapException.DetailElementName.Namespace)
 
        ' Build specific details for the SoapException.
        ' Add first child of detail XML element.
        Dim details As System.Xml.XmlNode =
 doc.CreateNode(XmlNodeType.Element, _
            "mySpecialInfo1", "http://tempuri.org/")

        ' Add second child of detail XML element with an attribute.
        Dim details2 As System.Xml.XmlNode
 = doc.CreateNode(XmlNodeType.Element, _
            "mySpecialInfo2", "http://tempuri.org/")
        Dim attr As XmlAttribute = doc.CreateAttribute("t",
 "attrName", _
            "http://tempuri.org/")
        attr.Value = "attrValue"
        details2.Attributes.Append(attr)

        ' Append the two child elements to the detail node.
        node.AppendChild(details)
        node.AppendChild(details2)
                
        'Throw the exception    
        Dim se As New SoapException("Fault
 occurred", SoapException.ClientFaultCode, _
                                    Context.Request.Url.AbsoluteUri, node)
        Throw se
        Return
    End Sub
End Class

<%@ WebService Language="C#" class="ThrowSoapException"%>

using System;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
using System.Xml;

public class ThrowSoapException : WebService
 
{
//    This XML Web service method generates a SOAP Client Fault code
 
    [WebMethod]
    public void myThrow(){

        // Build the detail element of the SOAP fault.
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        System.Xml.XmlNode node = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name,
 SoapException.DetailElementName.Namespace);


        // Build specific details for the SoapException.
        // Add first child of detail XML element.
        System.Xml.XmlNode details = doc.CreateNode(XmlNodeType.Element, "mySpecialInfo1",
 "http://tempuri.org/");
        System.Xml.XmlNode detailsChild = doc.CreateNode(XmlNodeType.Element, "childOfSpecialInfo",
 "http://tempuri.org/");
        details.AppendChild(detailsChild);

            
        // Add second child of detail XML element with an attribute.
        System.Xml.XmlNode details2 = doc.CreateNode(XmlNodeType.Element, "mySpecialInfo2",
 "http://tempuri.org/");
        XmlAttribute attr = doc.CreateAttribute("t", "attrName",
 "http://tempuri.org/");
        attr.Value = "attrValue";
        details2.Attributes.Append(attr);

        // Append the two child elements to the detail node.
        node.AppendChild(details);
        node.AppendChild(details2);

            
        //Throw the exception.    
        SoapException se = new SoapException("Fault occurred",
 SoapException.ClientFaultCode,Context.Request.Url.AbsoluteUri,node);

        throw se;
        return;    }
}

継承階層継承階層
System.Object
   System.Exception
     System.SystemException
      System.Web.Services.Protocols.SoapException
         System.Web.Services.Protocols.SoapHeaderException
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SoapException メンバ
System.Web.Services.Protocols 名前空間



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

辞書ショートカット

すべての辞書の索引

「SoapException クラス」の関連用語

SoapException クラスのお隣キーワード
検索ランキング

   

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



SoapException クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS