SoapHeaderDirection 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定 SoapHeader 的收件者是否為 XML Web Service、XML Web Service 用戶端或兩者都是。
此列舉支援其成員值的位元組合。
public enum class SoapHeaderDirection
[System.Flags]
public enum SoapHeaderDirection
[<System.Flags>]
type SoapHeaderDirection =
Public Enum SoapHeaderDirection
- 繼承
- 屬性
欄位
Fault | 4 | 指定 XML Web Service 方法擲回例外狀況時,將 SoapHeader 傳送至 XML Web Service 用戶端。 |
In | 1 | 指定 SoapHeader 要傳送至 XML Web Service。 |
InOut | 3 | 指定 SoapHeader 要傳送至 XML Web Service 和 XML Web Service 用戶端兩處。 |
Out | 2 | 指定 SoapHeader 要傳送至 XML Web Service 用戶端。 |
範例
下列 XML Web 服務方法會 myHeader
SoapHeader 指定 從 XML Web 服務用戶端傳送至 XML Web 服務,然後回到 XML Web 服務用戶端,而不論 XML Web 服務方法執行期間擲回的例外狀況為何。
public ref class MyHeader: public SoapHeader
{
public:
String^ MyValue;
};
public ref class MyWebService
{
public:
MyHeader^ myHeader;
[WebMethod]
[SoapHeader("myHeader",
Direction=SoapHeaderDirection::InOut|SoapHeaderDirection::Fault)]
void MySoapHeaderReceivingMethod()
{
// Set myHeader->MyValue to some value.
}
};
public class MyHeader : SoapHeader {
public string MyValue;
}
public class MyWebService {
public MyHeader myHeader;
[WebMethod]
[SoapHeader("myHeader",
Direction=SoapHeaderDirection.InOut | SoapHeaderDirection.Fault)]
public void MySoapHeaderReceivingMethod() {
// Set myHeader.MyValue to some value.
}
}
Public Class MyHeader
Inherits SoapHeader
Public MyValue As String
End Class
Public Class MyWebService
Public myHeader As MyHeader
<WebMethod, _
SoapHeader("myHeader", _
Direction := SoapHeaderDirection.InOut Or SoapHeaderDirection.Fault)> _
Public Sub MySoapHeaderReceivingMethod()
' Set myHeader.MyValue to some value.
End Sub
End Class
備註
SoapHeaderAttribute可以套用至 XML Web 服務方法或 Proxy 類別的方法,以套用至 XML Web 服務。 不論是哪一種情況,收件者都是由 SoapHeaderAttribute.Direction 屬性指定。 若要指定 XML Web 服務方法在執行期間擲回例外狀況時傳回 SOAP 標頭,請將 套用 SoapHeaderAttribute 至 方法,並將 屬性設定 SoapHeaderAttribute.Direction 為 Fault
。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應