Skip to content

Method output arguments return <nil> Value() for ExtensionObject arrays representing custom structure dataTypes #768

@hbrackel

Description

@hbrackel

When calling a method whose output argument[0] is an array of custom structure dataType values, the corresponding output argument returns a slice of []*ua.ExtensionObject, where the ua.ExtensionObject.Value() == nil for each slice element. The same method called from e.g. UaExpert returns the correct decoded custom structure; that is the method returns the correct []*ua.ExtensionObject. Tested with multiple clients on multiple custom OPC UA servers. As a result, the ExtensionObject value cannot be decoded.

pseudo code:

...
oID := objectNodeId
mID := methodNodeId // method with zero input arguments; one output argument
req := &ua.CallMethodRequest{
		ObjectID:       oID,
		MethodID:       mID,
		InputArguments: []*ua.Variant{},
	}

resp, err := c.Call(ctx, req)
if err != nil {
	log.Fatal(err)
}
if got, want := resp.StatusCode, ua.StatusOK; got != want {
	log.Fatalf("got status %v want %v", got, want)
}
out := resp.OutputArguments[0].Value() 
// first output argument shall be an array of values of a custom structure dataType; 
// thus encoded as extensionObjects

extObjects, ok := out.([]*ua.ExtensionObject) // works up to here; 
// ...error handling omitted
for _, extObj range extObjects {
  value := extObj.Value(). // value is always nil??
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions