Action Property
Collapse the table of content
Expand the table of content

OperationContractAttribute.Action Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the WS-Addressing action of the request message.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

'Declaration
Public Property Action As String

Property Value

Type: System.String
The action to use in generating the WS-Addressing Action header.

ExceptionCondition
ArgumentNullException

The value is Nothing.

Use the Action property to control the action of the method's input message. Because Windows Phone uses this action to dispatch an incoming message to the appropriate method, messages used within a contract operation must have unique actions. The default action value is a combination of the contract namespace (the default value is "http://tempuri.org/"), the contract name (interface name or the class name, if no explicit service interface is used), the operation name, and an additional string ("Response") if the message is a correlated response. You can override this default with the Action property.

To indicate that a service operation handles all messages that the service receives but cannot be directed to a service operation, specify the value "*" (an asterisk). This type of operation, called an unmatched message handler, must have one of following method signatures, or a InvalidOperationException is thrown:

  • The service operation can take only a Message object and return a Message object.

  • The service operation can take only a Message object and return nothing (that is, return void).


	' A service contract defined with a class
	' for an operation that handles all messages the service receives.
	<ServiceContract(Name := "SampleServiceContract2", Namespace := "http://microsoft.wp.documentation")> _
	Public Class CustomerService
		<OperationContract(Name := "SampleOperationContract1")> _
		Public Function CountUsers() As Integer
			Return 2
		End Function

		<OperationContract(Action := "*")> _
		Public Function GetUser(ByVal id As Integer) As User
			If id = 1 Then
				Return New User() With {.IsMember = True, .Name = "Paul", .Age = 24}
			Else
				Return New User() With {.IsMember = False, .Name = "John", .Age = 64}
			End If
		End Function
	End Class

	<DataContract> _
	Public Class User
		Private privateIsMember As Boolean
		<DataMember> _
		Public Property IsMember() As Boolean
			Get
				Return privateIsMember
			End Get
			Set(ByVal value As Boolean)
				privateIsMember = value
			End Set
		End Property

		Private privateName As String
		<DataMember> _
		Public Property Name() As String
			Get
				Return privateName
			End Get
			Set(ByVal value As String)
				privateName = value
			End Set
		End Property

		Private privateAge As Integer
		<DataMember> _
		Public Property Age() As Integer
			Get
				Return privateAge
			End Get
			Set(ByVal value As Integer)
				privateAge = value
			End Set
		End Property
	End Class



Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft