WebMethodAttribute.MessageName Propriedade
Definição
O nome usado para o método de serviço Web XML nos dados passados e retornados de um método de serviço Web XML.The name used for the XML Web service method in the data passed to and returned from an XML Web service method.
public:
property System::String ^ MessageName { System::String ^ get(); void set(System::String ^ value); };
public string MessageName { get; set; }
member this.MessageName : string with get, set
Public Property MessageName As String
Valor da propriedade
O nome usado para o método de serviço Web XML nos dados passados de e para um método de serviço Web XML.The name used for the XML Web service method in the data passed to and from an XML Web service method. O padrão é o nome do método de serviço Web XML.The default is the name of the XML Web service method.
Exemplos
No exemplo a seguir, MessageName é usado para desambiguar os dois Add métodos.In the example below, MessageName is used to disambiguate the two Add methods.
<%@ WebService Language="C#" Class="Calculator" %>
using System;
using System.Web.Services;
public class Calculator : WebService {
// The MessageName property defaults to Add for this XML Web service method.
[WebMethod]
public int Add(int i, int j) {
return i + j;
}
[WebMethod(MessageName="Add2")]
public int Add(int i, int j, int k) {
return i + j + k;
}
}
<%@ WebService Language="VB" Class="Calculator" %>
Imports System
Imports System.Web.Services
Public Class Calculator
Inherits WebService
' The MessageName property defaults to Add for this XML Web service method.
<WebMethod()> _
Overloads Public Function Add(i As Integer, j As Integer) As Integer
Return i + j
End Function
<WebMethod(MessageName := "Add2")> _
Overloads Public Function Add(i As Integer, j As Integer, k As Integer) As Integer
Return i + j + k
End Function
End Class
Comentários
A MessageName propriedade pode ser usada para nomes de método ou propriedade de alias.The MessageName property can be used to alias method or property names. O uso mais comum da MessageName propriedade será identificar exclusivamente os métodos polimórficos.The most common use of the MessageName property will be to uniquely identify polymorphic methods. Por padrão, MessageName é definido como o nome do método de serviço Web XML.By default, MessageName is set to the name of the XML Web service method. Portanto, se um serviço Web XML contiver dois ou mais métodos de Web Service XML com o mesmo nome, você poderá identificar exclusivamente os métodos individuais do serviço Web XML definindo o MessageName para um nome exclusivo no serviço Web XML, sem alterar o nome do método real no código.Therefore, if an XML Web service contains two or more XML Web service methods with the same name, you can uniquely identify the individual XML Web service methods by setting the MessageName to a name unique within the XML Web service, without changing the name of the actual method name in code.
Quando os dados são passados para um serviço Web XML, eles são enviados em uma solicitação e quando retornados são enviados em uma resposta.When data is passed to an XML Web service it is sent in a request and when it is returned it is sent in a response. Dentro da solicitação e resposta, o nome usado para o método de serviço Web XML é sua MessageName propriedade.Within the request and response, the name used for the XML Web service method is its MessageName property.
O nome da mensagem associado a um método de serviço Web XML deve ser exclusivo dentro do serviço Web XML.The message name associated with an XML Web service method must be unique within the XML Web service.
Se um novo método de serviço Web XML com o mesmo nome, mas parâmetros diferentes for adicionado após os clientes chamarem o método original, um nome de mensagem diferente deverá ser especificado para o novo método, mas o nome da mensagem original deverá ser deixado como é para garantir a compatibilidade com os clientes existentes.If a new XML Web service method with the same name but different parameters is added after clients are calling the original method, a different message name should be specified for the new method but the original message name should be left as is to ensure compatibility with existing clients.