Bagikan melalui


SoapDocumentMethodAttribute.Action Properti

Definisi

Mendapatkan atau mengatur SOAPAction bidang header HTTP dari permintaan SOAP.

public:
 property System::String ^ Action { System::String ^ get(); void set(System::String ^ value); };
public string Action { get; set; }
member this.Action : string with get, set
Public Property Action As String

Nilai Properti

Bidang SOAPAction header HTTP dari permintaan SOAP. Defaultnya adalah http://tempuri.org/MethodName, di mana MethodName adalah nama metode layanan Web XML.

Contoh

Contoh kode berikut mengatur properti ke Actionhttp://www.contoso.com/GetUserName.

<%@ WebService Language="C#" class="MyUser" %>
 
 using System.Web.Services;
 using System.Web.Services.Protocols;
 
 public class MyUser : WebService {
 
      [ SoapDocumentMethod(Action="http://www.contoso.com/GetUserName")]
      public string GetUserName() {
       return User.Identity.Name;
      }
 }
<%@ WebService Language="VB" class="MyUser" %>

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

Public Class MyUser
    Inherits WebService
        
    <SoapDocumentMethod(Action := "http://www.contoso.com/GetUserName")> _
    Public Function _
        GetUserName() As String
        
        Return User.Identity.Name
    End Function
End Class

Keterangan

Biasanya, Action properti adalah URI yang menunjukkan niat permintaan. Namun, spesifikasi SOAP tidak membatasi format URI, atau aturan apa pun tentang apakah URI dapat diselesaikan. Kehadiran dan konten Action properti dapat digunakan oleh server Web, seperti firewall, untuk memfilter pesan permintaan SOAP dengan tepat di HTTP.

Secara default, .NET Framework versi 1.1 menerbitkan Action properti dalam soapAction atribut soap:operation elemen untuk setiap pengikatan SOAP yang didukung dalam dokumen WSDL yang dihasilkan untuk layanan Web XML. Untuk informasi selengkapnya, lihat spesifikasi SOAP di situs web W3C.

Berlaku untuk