# OpcServiceRequest Members

> Reference: Defines the base class of the requests of the services of OPC UA, e.g. as passed to the Invoke method of a service.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcServiceRequest</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx.services">Opc.UaFx.Services</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

## Constructors

### OpcServiceRequest

<span class="api-meta">protected · 2 overloads</span>

| Overload | Description |
|---|---|
| [OpcServiceRequest()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcservicerequest/members#opcservicerequest-noparams)<span class="api-meta">protected</span> | Initializes a new instance of the [OpcServiceRequest](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcservicerequest/) class using a new header. |
| [OpcServiceRequest(IOpcServiceRequestHeader)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcservicerequest/members#opcservicerequest-opc-uafx-services-iopcservicerequestheader)<span class="api-meta">protected · since v2.7</span> | Initializes a new instance of the [OpcServiceRequest](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcservicerequest/) class using the specified `header`. |

#### OpcServiceRequest()

<span class="api-meta">protected</span>

Initializes a new instance of the [OpcServiceRequest](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcservicerequest/) class using a new header.

<div class="api-signature" data-lang="csharp">

```csharp
protected OpcServiceRequest()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Sub New()
```

</div>

#### OpcServiceRequest(IOpcServiceRequestHeader)

<span class="api-meta">protected · since v2.7</span>

Initializes a new instance of the [OpcServiceRequest](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcservicerequest/) class using the specified `header`.

<div class="api-signature" data-lang="csharp">

```csharp
protected OpcServiceRequest(IOpcServiceRequestHeader header)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Sub New(header As IOpcServiceRequestHeader)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `header` | [IOpcServiceRequestHeader](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcservicerequestheader/) | The header of the request. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `header` is a null reference (Nothing in Visual Basic). |

## Properties

### Header

Gets the header of the request.

<div class="api-signature" data-lang="csharp">

```csharp
public IOpcServiceRequestHeader Header { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Header As IOpcServiceRequestHeader
```

</div>

**Property value**

[IOpcServiceRequestHeader](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcservicerequestheader/)

The [IOpcServiceRequestHeader](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcservicerequestheader/) of the request.

**Implements**

[Header](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcservicerequest/members#header)

### ServiceName

<span class="api-meta">since v2.19</span>

Gets the name of the service of the request.

<div class="api-signature" data-lang="csharp">

```csharp
public string ServiceName { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property ServiceName As String
```

</div>

**Property value**

[String](https://learn.microsoft.com/dotnet/api/system.string)

The name of the type of the request without the prefix "Opc" and the suffix "Request" (e.g. "ReadNodes" for [OpcReadNodesRequest](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcreadnodesrequest/)); for a request of a service without a type of its own, the name of the service as defined by OPC UA.

## Methods

### CreateHeader

<span class="api-meta">protected · since v2.7</span>

Creates the header of the request using [CreateHeaderCore](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcservicerequest/members#createheadercore) and assigns it to the request.

<div class="api-signature" data-lang="csharp">

```csharp
protected IOpcServiceRequestHeader CreateHeader()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Function CreateHeader() As IOpcServiceRequestHeader
```

</div>

**Returns**

[IOpcServiceRequestHeader](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcservicerequestheader/)

The header created.

### CreateHeaderCore

<span class="api-meta">protected · virtual · since v2.7</span>

When overridden in a derived class, creates the header of the request.

<div class="api-signature" data-lang="csharp">

```csharp
protected virtual IOpcServiceRequestHeader CreateHeaderCore()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Overridable Function CreateHeaderCore() As IOpcServiceRequestHeader
```

</div>

**Returns**

[IOpcServiceRequestHeader](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcservicerequestheader/)

The header created. The default implementation returns an [OpcServiceRequestHeader](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcservicerequestheader/) which represents the header of the request data, or a new [OpcServiceRequestHeader](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.opcservicerequestheader/) if the request data does not have a header.

### Validate

<span class="api-meta">protected · virtual · since v2.50</span>

When overridden in a derived class, validates the request before a server processes it.

<div class="api-signature" data-lang="csharp">

```csharp
protected virtual void Validate()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Overridable Sub Validate()
```

</div>

**Remarks**

A server rejects a request which fails the validation with the status code of the validation, e.g. a request without commands with [BadNothingToDo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnothingtodo). The default implementation does not validate anything.
