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 名前空間


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

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

辞書ショートカット

すべての辞書の索引

「SoapIncludeAttribute クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS