Freigeben über


SoapHeaderException-Konstruktor (String, XmlQualifiedName, String)

Initialisiert eine neue Instanz der SoapHeaderException-Klasse.

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public Sub New ( _
    message As String, _
    code As XmlQualifiedName, _
    actor As String _
)
'Usage
Dim message As String
Dim code As XmlQualifiedName
Dim actor As String

Dim instance As New SoapHeaderException(message, code, actor)
public SoapHeaderException (
    string message,
    XmlQualifiedName code,
    string actor
)
public:
SoapHeaderException (
    String^ message, 
    XmlQualifiedName^ code, 
    String^ actor
)
public SoapHeaderException (
    String message, 
    XmlQualifiedName code, 
    String actor
)
public function SoapHeaderException (
    message : String, 
    code : XmlQualifiedName, 
    actor : String
)

Parameter

  • message
    Eine Meldung, die die Ursache für das Auftreten der Ausnahme angibt. Mit diesem Parameter wird die Message-Eigenschaft festgelegt.
  • code
    Der Typ des aufgetretenen Fehlers. Mit diesem Parameter wird die Code-Eigenschaft festgelegt.
  • actor
    Der Codeabschnitt, der die Ausnahme verursacht hat. In der Regel ist dies ein URL einer XML-Webdienstmethode. Mit diesem Parameter wird die Actor-Eigenschaft festgelegt.

Beispiel

<%@ 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, _
            "https://localhost/MathSvc_SoapHeaderException3.vb.asmx/Add")
      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,
               "https://localhost/MathSvc_SoapHeaderException3.cs.asmx/Add");
        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, 
                "https://localhost/MathSvc_SoapHeaderException3.cs.asmx/Add");
        }
        return xValue + yValue;
    } //Add
} //MathSvc

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

SoapHeaderException-Klasse
SoapHeaderException-Member
System.Web.Services.Protocols-Namespace