SoapIncludeAttributeとは? わかりやすく解説

SoapIncludeAttribute クラス

XmlSerializer がオブジェクトエンコード済みSOAP XML としてシリアル化または逆シリアル化するときに、型を認識できるようにします。

名前空間: System.Xml.Serialization
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct
 Or AttributeTargets.Method Or AttributeTargets.Interface,
 AllowMultiple:=True)> _
Public Class SoapIncludeAttribute
    Inherits Attribute
Dim instance As SoapIncludeAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Method|AttributeTargets.Interface,
 AllowMultiple=true)] 
public class SoapIncludeAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Method|AttributeTargets::Interface,
 AllowMultiple=true)] 
public ref class SoapIncludeAttribute : public
 Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Method|AttributeTargets.Interface,
 AllowMultiple=true) */ 
public class SoapIncludeAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Method|AttributeTargets.Interface,
 AllowMultiple=true) 
public class SoapIncludeAttribute extends
 Attribute
解説解説

SoapIncludeAttribute クラスは、XmlSerializerオブジェクトエンコード済み SOAP XML としてシリアル化または逆シリアル化する方法制御する一連の属性のうちの 1 つです。結果として生成される XML は、W3C (World Wide Web Consortium) (www.w3.org) のドキュメントSimple Object Access Protocol (SOAP) 1.1』のセクション 5 に準拠します。類似する属性の完全な一覧については、「エンコード済み SOAP シリアル化制御する属性」を参照してください

オブジェクトエンコード済み SOAP メッセージとしてシリアル化するには、SoapReflectionImporter クラスの ImportTypeMapping メソッド作成された XmlTypeMapping を使用してXmlSerializer構築する必要があります

SoapIncludeAttribute適用するときには派生クラスType指定しますXmlSerializer は、基本クラス派生クラス両方を含むオブジェクトシリアル化する場合は、両方オブジェクト型認識できます

Web サービス記述言語 (WSDL: Web Services Description Language) で記述されサービス説明ドキュメント派生クラス含め場合は、SoapIncludeAttribute使用します。たとえば、メソッドObject返す場合は、そのメソッドSoapIncludeAttribute適用し実際に返される必要がある型を指定します

WSDL詳細については、W3C (World Wide Web Consortium) (www.w3.org) の仕様Web Services Description Language (WSDL) 1.1』を参照してください

属性使用方法については、「属性使用したメタデータ拡張」を参照してください

使用例使用例

SoapIncludeAttributeXML Web サービス メソッドに 2 回適用する例を次に示します。このメソッドは、オブジェクト型 Vehicle (基本クラス) を返しますSoapIncludeAttribute適用されているため、このメソッドVehicle クラスから派生したクラスインスタンス返すことができます

<%@ WebService Language="VB" Class="Test"
 %>
 
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Services.Description
Imports System.Xml
Imports System.Xml.Schema
Imports System.Xml.Serialization
Imports System.Data
 
Public Class Test : 
Inherits WebService 
   <WebMethod()> Public Function EchoString(
 _
   <XmlElement(DataType:="string")> ByVal
 strval As String) _
   As <XmlElement("MyTime",
 DataType:="time")> DateTime
      Return DateTime.Now
   End Function

 
   <WebMethod(), SoapRpcMethod, SoapInclude(GetType(Car)),
 _
   SoapInclude(GetType(Bike))> _
   Public Function Vehicle (licenseNumber As
 string ) As Vehicle

      If licenseNumber = "0" Then
         Dim v As Vehicle  = new
 Car()
         v.licenseNumber = licenseNumber
         return v

      ElseIf licenseNumber = "1"
 Then
          Dim v As Vehicle  = new
 Bike()
          v.licenseNumber = licenseNumber
          return v
      
      else 
         return Nothing
      End If
   End Function
End Class

<XmlRoot("NewVehicle")> _
public MustInherit Class
 Vehicle 
    public licenseNumber As String
 
    public make As DateTime 
End Class
 
public class Car 
   Inherits Vehicle 
End Class
 
public Class Bike 
   Inherits Vehicle 
End Class
   
<%@ WebService Language="C#" Class="Test" %>
 
using System;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Services.Description;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Data;
 
public class Test : WebService {
   [WebMethod()]
   [return:XmlElement("MyTime", DataType="time")]
   public DateTime EchoString([XmlElement(DataType="string")]
 
   string strval) {
        return DateTime.Now;
   }
 
   [WebMethod()]
   [SoapRpcMethod]
   [SoapInclude(typeof(Car)), SoapInclude(typeof(Bike))]
   public Vehicle Vehicle(string licenseNumber)
 {
      if (licenseNumber == "0") {
         Vehicle v = new Car();
         v.licenseNumber = licenseNumber;
         return v;
      }
      else if (licenseNumber == "1")
 {
          Vehicle v = new Bike();
          v.licenseNumber = licenseNumber;
          return v;
      }
      else {
         return null;
      }
   }
}
[XmlRoot("NewVehicle")] 
public abstract class Vehicle {
    public string licenseNumber;
    public DateTime make;
}
 
public class Car : Vehicle {
}
 
public class Bike : Vehicle {
}
   
<%@ WebService Language="VJ#" Class="Test" %>
import System.*;
import System.Web.Services.*;
import System.Web.Services.Protocols.*;
import System.Web.Services.Description.*;
import System.Xml.*;
import System.Xml.Schema.*;
import System.Xml.Serialization.*;
import System.Data.*;

public class Test extends WebService
{
    /** @attribute WebMethod()
     */
    public DateTime EchoString(
        /** @attribute XmlElement(DataType = "string")
         */
        String strval)
    {
        return DateTime.get_Now();
    } //EchoString

    /** @attribute WebMethod()
     */
    /** @attribute SoapRpcMethod()
     */
    /** @attribute SoapInclude(Car.class)
        @attribute SoapInclude(Bike.class)
     */
    public Vehicle Vehicle(String licenseNumber)
    {
        if (licenseNumber.Equals("0")) {
            Vehicle v = new Car();
            v.licenseNumber = licenseNumber;
            return v;
        }
        else {
            if (licenseNumber.Equals("1")) {
                Vehicle v = new Bike();
                v.licenseNumber = licenseNumber;
                return v;
            }
            else {
                return null;
            }
        }
    } //Vehicle
} //Test

/** @attribute XmlRoot("NewVehicle")
 */
abstract public class Vehicle
{
    public String licenseNumber;
    public DateTime make;
} //Vehicle

public class Car extends Vehicle
{
} //Car

public class Bike extends Vehicle
{
} //Bike
継承階層継承階層
System.Object
   System.Attribute
    System.Xml.Serialization.SoapIncludeAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SoapIncludeAttribute メンバ
System.Xml.Serialization 名前空間

SoapIncludeAttribute コンストラクタ

型を指定して、SoapIncludeAttribute クラス新しインスタンス初期化します。

名前空間: System.Xml.Serialization
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

Dim type As Type

Dim instance As New SoapIncludeAttribute(type)
public SoapIncludeAttribute (
    Type type
)
public:
SoapIncludeAttribute (
    Type^ type
)
public SoapIncludeAttribute (
    Type type
)
public function SoapIncludeAttribute (
    type : Type
)

パラメータ

type

含めオブジェクトの型。

解説解説
使用例使用例

SoapIncludeAttributeXML Web サービス メソッドに 2 回適用する例を次に示します。このメソッドは、オブジェクト型 Vehicle (基本クラス) を返しますSoapIncludeAttribute適用されているため、このメソッドVehicle クラスから派生したクラスインスタンス返すことができます

<%@ WebService Language="VB" Class="Test"
 %>
 
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Services.Description
Imports System.Xml
Imports System.Xml.Schema
Imports System.Xml.Serialization
Imports System.Data
 
Public Class Test : 
Inherits WebService 
   <WebMethod()> Public Function EchoString(
 _
   <XmlElement(DataType:="string")> ByVal
 strval As String) _
   As <XmlElement("MyTime",
 DataType:="time")> DateTime
      Return DateTime.Now
   End Function

 
   <WebMethod(), SoapRpcMethod, SoapInclude(GetType(Car)),
 _
   SoapInclude(GetType(Bike))> _
   Public Function Vehicle (licenseNumber As
 string ) As Vehicle

      If licenseNumber = "0" Then
         Dim v As Vehicle  = new
 Car()
         v.licenseNumber = licenseNumber
         return v

      ElseIf licenseNumber = "1"
 Then
          Dim v As Vehicle  = new
 Bike()
          v.licenseNumber = licenseNumber
          return v
      
      else 
         return Nothing
      End If
   End Function
End Class

<XmlRoot("NewVehicle")> _
public MustInherit Class
 Vehicle 
    public licenseNumber As String
 
    public make As DateTime 
End Class
 
public class Car 
   Inherits Vehicle 
End Class
 
public Class Bike 
   Inherits Vehicle 
End Class
   
<%@ WebService Language="C#" Class="Test" %>
 
using System;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Services.Description;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Data;
 
public class Test : WebService {
   [WebMethod()]
   [return:XmlElement("MyTime", DataType="time")]
   public DateTime EchoString([XmlElement(DataType="string")]
 
   string strval) {
        return DateTime.Now;
   }
 
   [WebMethod()]
   [SoapRpcMethod]
   [SoapInclude(typeof(Car)), SoapInclude(typeof(Bike))]
   public Vehicle Vehicle(string licenseNumber)
 {
      if (licenseNumber == "0") {
         Vehicle v = new Car();
         v.licenseNumber = licenseNumber;
         return v;
      }
      else if (licenseNumber == "1")
 {
          Vehicle v = new Bike();
          v.licenseNumber = licenseNumber;
          return v;
      }
      else {
         return null;
      }
   }
}
[XmlRoot("NewVehicle")] 
public abstract class Vehicle {
    public string licenseNumber;
    public DateTime make;
}
 
public class Car : Vehicle {
}
 
public class Bike : Vehicle {
}
   
<%@ WebService Language="VJ#" Class="Test" %>
import System.*;
import System.Web.Services.*;
import System.Web.Services.Protocols.*;
import System.Web.Services.Description.*;
import System.Xml.*;
import System.Xml.Schema.*;
import System.Xml.Serialization.*;
import System.Data.*;

public class Test extends WebService
{
    /** @attribute WebMethod()
     */
    public DateTime EchoString(
        /** @attribute XmlElement(DataType = "string")
         */
        String strval)
    {
        return DateTime.get_Now();
    } //EchoString

    /** @attribute WebMethod()
     */
    /** @attribute SoapRpcMethod()
     */
    /** @attribute SoapInclude(Car.class)
        @attribute SoapInclude(Bike.class)
     */
    public Vehicle Vehicle(String licenseNumber)
    {
        if (licenseNumber.Equals("0")) {
            Vehicle v = new Car();
            v.licenseNumber = licenseNumber;
            return v;
        }
        else {
            if (licenseNumber.Equals("1")) {
                Vehicle v = new Bike();
                v.licenseNumber = licenseNumber;
                return v;
            }
            else {
                return null;
            }
        }
    } //Vehicle
} //Test

/** @attribute XmlRoot("NewVehicle")
 */
abstract public class Vehicle
{
    public String licenseNumber;
    public DateTime make;
} //Vehicle

public class Car extends Vehicle
{
} //Car

public class Bike extends Vehicle
{
} //Bike
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SoapIncludeAttribute クラス
SoapIncludeAttribute メンバ
System.Xml.Serialization 名前空間

SoapIncludeAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ .NET Compact Framework によるサポート TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。 ( Attribute から継承されます。)
参照参照

関連項目

SoapIncludeAttribute クラス
System.Xml.Serialization 名前空間

SoapIncludeAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスハッシュ コード返します。 ( Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラス既定値かどうか示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

SoapIncludeAttribute クラス
System.Xml.Serialization 名前空間

SoapIncludeAttribute メンバ

XmlSerializer がオブジェクトエンコード済みSOAP XML としてシリアル化または逆シリアル化するときに、型を認識できるようにします。

SoapIncludeAttribute データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド SoapIncludeAttribute 型を指定して、SoapIncludeAttribute クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ .NET Compact Framework によるサポート TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。(Attribute から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスハッシュ コード返します。 (Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラス既定値かどうか示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

SoapIncludeAttribute クラス
System.Xml.Serialization 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からSoapIncludeAttributeを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSoapIncludeAttributeを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSoapIncludeAttribute を検索

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

辞書ショートカット

すべての辞書の索引

「SoapIncludeAttribute」の関連用語

SoapIncludeAttributeのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS