次の方法で共有


SoapHeaderException コンストラクタ (String, XmlQualifiedName)

SoapHeaderException クラスの新しいインスタンスを初期化します。

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

構文

'宣言
Public Sub New ( _
    message As String, _
    code As XmlQualifiedName _
)
'使用
Dim message As String
Dim code As XmlQualifiedName

Dim instance As New SoapHeaderException(message, code)
public SoapHeaderException (
    string message,
    XmlQualifiedName code
)
public:
SoapHeaderException (
    String^ message, 
    XmlQualifiedName^ code
)
public SoapHeaderException (
    String message, 
    XmlQualifiedName code
)
public function SoapHeaderException (
    message : String, 
    code : XmlQualifiedName
)
適用できません。

パラメータ

  • message
    例外が発生した理由を示すメッセージ。このパラメータは Message プロパティを設定します。
  • code
    発生したエラーの種類。このパラメータは Code プロパティを設定します。

使用例

<%@ WebService Language="VB" Class="MathSvc" %>

Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols

Public Class MySoapHeader
   Inherits SoapHeader
   Public number As Integer
End Class 'MySoapHeader

Public Class MathSvc
   Inherits WebService
   Public mySoapHeader As MySoapHeader

   <WebMethod(), SoapHeaderAttribute("mySoapHeader", _
      Direction := SoapHeaderDirection.In)>  _
   Public Function Add(xValue As Single, yValue As Single) As Single
      ' Throw an exception if the value received in the header is zero.
      If mySoapHeader.number = 0 Then
         Throw New SoapHeaderException( _
            "value received in the header is zero.", _
            SoapException.ClientFaultCode)
      End If
      Return xValue + yValue
   End Function 'Add
End Class 'MathSvc
<%@ WebService Language="C#" Class="MathSvc" %>

using System;
using System.Web.Services;
using System.Web.Services.Protocols;

public class MySoapHeader : SoapHeader
{
   public int number;
}

public class MathSvc : WebService {
    public MySoapHeader mySoapHeader;
    
    [WebMethod]
    [SoapHeaderAttribute("mySoapHeader", Direction=SoapHeaderDirection.In)]
    public float Add(float xValue, float yValue) 
    {
        // Throw an exception if the value received in the header is zero.
        if(mySoapHeader.number == 0)
            throw new SoapHeaderException(
               "value received in the header is zero.",
               SoapException.ClientFaultCode);
        return(xValue + yValue);
    }
}
<%@ WebService Language="VJ#" Class="MathSvc" %>

import System.*;
import System.Web.Services.*;
import System.Web.Services.Protocols.*;

public class MySoapHeader extends SoapHeader
{
    public int number;
} //MySoapHeader

public class MathSvc extends WebService
{
    public MySoapHeader mySoapHeader;

    /** @attribute WebMethod()
     */
    /** @attribute SoapHeaderAttribute("mySoapHeader", 
        Direction = SoapHeaderDirection.In)
    */
    public float Add(float xValue, float yValue) throws SoapHeaderException
    {
        // Throw an exception if the value received in the header is zero.
        if ( mySoapHeader.number == 0  ) {
            throw new SoapHeaderException("value received in the header is zero.", 
                SoapException.ClientFaultCode) ;
        }
        return xValue + yValue ;
    } //Add
} //MathSvc

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

.NET Compact Framework

サポート対象 : 2.0,1.0

参照

関連項目

SoapHeaderException クラス
SoapHeaderException メンバ
System.Web.Services.Protocols 名前空間