Overloading di un Service Contract in WCF

Primi utilizzi... primi problemi... Sad

Stavo pubblicando il mio primo servizio con WCF è IIS mi ha detto:

“Cannot have two operations in the same contract with the same name [......]. You can change the name of one of the operations by changing the method name or by using the Name property of OperationContractAttribute.”

L’overloading rimane possibile... basta assegnare un nome differente nella parametrizzazione dell’attributo:

<ServiceContract()> _
Public Interface IMyCalculator
    <OperationContract(Name := "AddFloats")> _
    Function Add(ByVal operand1 As Single, ByVal operand2 As Single) As Single

    <OperationContract(Name := "AddIntegers")> _
    Function Add(ByVal operand1 As Integer, ByVal operand2 As Integer) As Integer
End Interface

Sarà ancora riferirsi a entrambi i metodi con Add. Solo nel WSDL si vedranno i diversi nomi.

Grazie a MSDN Forum.

posted @ Sunday, October 5, 2008 7:15 PM

Print
Comments have been closed on this topic.
«January»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678