SoapIncludeAttribute コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SoapIncludeAttribute コンストラクタの意味・解説 

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



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

辞書ショートカット

すべての辞書の索引

「SoapIncludeAttribute コンストラクタ」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS