XMLDA.NET Reference
Write Method
See Also  Example Send Feedback
xmldanet.xmlda Namespace > OpcXmlDA Class : Write Method

Options
Container with options used in most server calls.
ItemList
The container for the individual Items. It is expected that there are one or more Items per ItemList.
ReturnValuesOnReply
Indicates whether to return the Value for each item (i.e., the Value of the ItemValue structure). The returned value is the value “accepted” by the server, or device. If a Value is returned, then the associated QualityField will also be returned, and as appropriate the LimitField, and VendorField. The returned value is equivalent to the value which would be returned by the server to the client if the client had performed a read request directly after the write request. Values are never returned if the Write fails. If an item is write-only the server will return E_WRITEONLY in the response for this item. The response will provide no value element for the affected item.
RItemList
A container with an array of item information It is expected that there are one or more Item elements in the list. The WriteResponse will maintain the order of Items in the Write request. The data type of the returned value(s) must match the data type of the value(s) being supplied in the Write request. The Value element is only present if ReturnValuesOnReply was True. Timestamp is only present if ReturnItemTime was True.
Errors
An array of OPCError elements with the description of the errors occured in this server call. Errors are only present if Items contain result codes.

Glossary Item Box

XML-DA method to write a set of item values to either an XML-DA or OPC-DA server.

Syntax

Visual Basic (Usage)Copy Code
Dim instance As OpcXmlDA
Dim Options As RequestOptions
Dim ItemList As WriteRequestItemList
Dim ReturnValuesOnReply As Boolean
Dim RItemList As ReplyItemList
Dim Errors As OPCError()
Dim value As ReplyBase
 
value = instance.Write(Options, ItemList, ReturnValuesOnReply, RItemList, Errors)
C# 
[SoapDocumentMethodAttribute(Action="http://opcfoundation.org/webservices/XMLDA/1.0/Write", 
   RequestNamespace="http://opcfoundation.org/webservices/XMLDA/1.0/", 
   ResponseNamespace="http://opcfoundation.org/webservices/XMLDA/1.0/", 
   Use=SoapBindingUse.Literal, 
   ParameterStyle=SoapParameterStyle.Wrapped)]
public ReplyBase Write( 
   RequestOptions Options,
   WriteRequestItemList ItemList,
   bool ReturnValuesOnReply,
   out ReplyItemList RItemList,
   out OPCError[] Errors
)

Parameters

Options
Container with options used in most server calls.
ItemList
The container for the individual Items. It is expected that there are one or more Items per ItemList.
ReturnValuesOnReply
Indicates whether to return the Value for each item (i.e., the Value of the ItemValue structure). The returned value is the value “accepted” by the server, or device. If a Value is returned, then the associated QualityField will also be returned, and as appropriate the LimitField, and VendorField. The returned value is equivalent to the value which would be returned by the server to the client if the client had performed a read request directly after the write request. Values are never returned if the Write fails. If an item is write-only the server will return E_WRITEONLY in the response for this item. The response will provide no value element for the affected item.
RItemList
A container with an array of item information It is expected that there are one or more Item elements in the list. The WriteResponse will maintain the order of Items in the Write request. The data type of the returned value(s) must match the data type of the value(s) being supplied in the Write request. The Value element is only present if ReturnValuesOnReply was True. Timestamp is only present if ReturnItemTime was True.
Errors
An array of OPCError elements with the description of the errors occured in this server call. Errors are only present if Items contain result codes.

Return Value

Container of information that represents the basic information for most responses.

Example

Visual BasicCopy Code
Private Sub Write( ByVal Srv As XmlServer, ByVal embeddedList As ListBuilder )
      Dim wril As WriteRequestItemList = embeddedList.GetWriteItemList("Write1")
      If wril Is Nothing Then
         MessageBox.Show("List " & listName & " not found in definition file", "Error at get list")
         Return
      End If
      Try
         embeddedList.SetWriteValue(wril, "InOut_I4", 123, DateTime.Now, Nothing)
         embeddedList.SetWriteValue(wril, "InOut_Boolean", True, Nothing)
         embeddedList.SetWriteValue(wril, "Lo", 200, Nothing)
         embeddedList.SetWriteValue(wril, "Hi", 300, Nothing)
         Dim reply As ReplyBase
         Dim options As RequestOptions = New RequestOptions
         options.ReturnErrorText = True
         options.ReturnItemName = True
         Dim rslt As ReplyItemList
         Dim err As OPCError()
         reply = Srv.Write(options, wril, True, rslt, err)
         If err Is Nothing Or err.Length = 0 Then  ' no errors
            Dim info As String = ""
            Dim iv As ItemValue
            For Each iv In rslt.Items
               Dim errinf As String = "ok"
               If Not iv.ResultID Is Nothing Then
                  errinf = iv.ResultID.Name
               End If
               info = info & iv.ItemName & "  " & errinf & ControlChars.CrLf
            Next
            MessageBox.Show(info, "Write Result")
         Else
            MessageBox.Show(err(0).Text, "Error at Write")
         End If
      Catch ex As Exception
         MessageBox.Show(ex.Message, "Exception in Write")
      End Try
   End Sub
C#Copy Code
private void Write(XmlServer Srv, ListBuilder embeddedList )
      {
         WriteRequestItemList wril = embeddedList.GetWriteItemList( "Write1" );
         if( wril == null )
         {
            MessageBox.Show( "List " + listName + " not found in definition file", "Error at get list" );
            return ;
         }
         try
         {
            embeddedList.SetWriteValue( wril, "InOut_I4", 123, DateTime.Now, null );
            embeddedList.SetWriteValue( wril, "InOut_Boolean", true, null );
            embeddedList.SetWriteValue( wril, "Lo", 200, null );
            embeddedList.SetWriteValue( wril, "Hi", 300, null );
            ReplyBase reply ;
            RequestOptions options = new RequestOptions();
            options.ReturnErrorText = true ;
            options.ReturnItemName = true ;
            ReplyItemList rslt ;
            OPCError[] err ;
            reply = Srv.Write( options, wril, true, out rslt, out err );
            if( (err != null) && (err.Length>0) )
               MessageBox.Show( err[0].Text, "Error at Write" );
            else
            {
               string info = "" ;
               foreach( ItemValue iv in rslt.Items )
               {
                  string errinf ="ok";
                  if( iv.ResultID != null )
                     errinf = iv.ResultID.Name ;
                  info += iv.ItemName +"  "+ errinf + "\r\n" ;
               }
               MessageBox.Show( info, "Write Result" );
            }
         }
         catch( Exception ex )
         {
            MessageBox.Show( ex.Message, "Exception in Write" );
         }
      }

Requirements

Target Platforms:Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows 7, Windows Server 2008 family

>

See Also

© 2002-2012 Advosol Inc. All Rights Reserved.