Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6559911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:23:31+00:00 2026-05-25T13:23:31+00:00

I’m trying to build a demonstrative OPC XML DA Server using C#. Developement is

  • 0

I’m trying to build a demonstrative OPC XML DA Server using C#. Developement is underway, but i am stuck on a serialization issue concerning arrays. Apparently, when I try to set ItemProperty.Value (which is of type Object) to any kind of array but byte[], i get this exception:

System.InvalidOperationException: The type <ArrayType> may not be used in this context.

Here’s the content of a sample GetProperties() method which triggers the exception:

[WebMethodAttribute()]
[
    SoapDocumentMethodAttribute
    (
        "http://opcfoundation.org/webservices/XMLDA/1.0/GetProperties", 
        RequestNamespace = "http://opcfoundation.org/webservices/XMLDA/1.0/", 
        ResponseNamespace = "http://opcfoundation.org/webservices/XMLDA/1.0/", 
        Use = SoapBindingUse.Literal, 
        ParameterStyle = SoapParameterStyle.Wrapped
    )
]
public override ReplyBase GetProperties
(
    [XmlElementAttribute("ItemIDs")] ItemIdentifier[] ItemIDs, 
    [XmlElementAttribute("PropertyNames")] XmlQualifiedName[] PropertyNames, 
    [XmlAttributeAttribute()] string LocaleID, 
    [XmlAttributeAttribute()] string ClientRequestHandle, 
    [XmlAttributeAttribute()] string ItemPath, 
    [XmlAttributeAttribute()] [DefaultValueAttribute(false)] bool ReturnAllProperties,
    [XmlAttributeAttribute()] [DefaultValueAttribute(false)] bool ReturnPropertyValues,
    [XmlAttributeAttribute()] [DefaultValueAttribute(false)] bool ReturnErrorText, 
    [XmlElementAttribute("PropertyLists")] out PropertyReplyList[] PropertyLists, 
    [XmlElementAttribute("Errors")] out OPCError[] Errors
)
{
    ReplyBase Response = new ReplyBase();
    Response.RcvTime = System.DateTime.Now;

    Response.RevisedLocaleID = LocaleID;
    Response.ClientRequestHandle = ClientRequestHandle;

    Errors = null;

    PropertyLists = new PropertyReplyList[1] { new PropertyReplyList() };
    PropertyLists[0].Properties = new ItemProperty[1] { new ItemProperty() };
    PropertyLists[0].Properties[0].Value = new short[2] { 3, 4 };

    Response.ReplyTime = System.DateTime.Now;
    return Response;
}

Full stack trace (italian)

System.Web.Services.Protocols.SoapException: Impossibile elaborare la richiesta. ---> System.InvalidOperationException: Errore durante la generazione del documento XML. ---> System.InvalidOperationException: Il tipo System.Int16[] può non essere utilizzato in questo contesto.
in System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType)
in Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write2_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType)
in Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write16_ItemProperty(String n, String ns, ItemProperty o, Boolean isNullable, Boolean needType)
in Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write19_PropertyReplyList(String n, String ns, PropertyReplyList o, Boolean isNullable, Boolean needType)
in Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write26_GetPropertiesResponse(Object[] p)
in Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer13.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
in System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- Fine della traccia dello stack dell'eccezione interna ---
in System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
in System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
in System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
in System.Web.Services.Protocols.WebServiceHandler.Invoke()
--- Fine della traccia dello stack dell'eccezione interna ---

I’ve already included into my project the service skeleton generated by wsdl.exe, and have absolutely no problems with non-array values. The target framework of my project is .NET 4.0 (but the same problem happens to 3.5).

My guess is that the method isn’t working well with the XmlIncludeAttribute() decorators in the service skeleton. Any clues on how to make it work?

Thank you for your time.

Edit: I’ve tried adding the XmlIncludeAttribute(typeof(int[])) decorator to the GetProperties() method (i guess decorators are not inheritable), and i’m not getting the exception. However, the client is unable to properly unserialize the underlying data. What I get from the client (written in VB.NET) after unserialization is an XmlNode reference instead of an int[]. The data is there, but it’s not properly unserialized.

Is this the expected behaviour? Might it be a client issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:23:31+00:00Added an answer on May 25, 2026 at 1:23 pm

    After a little more analysis of the produced XML I’ve found out the client required a specific namespace, which is the OPC web service default namespace, in order to properly deserialize data. I’ve updated the class definition of the web service implementation with the following decorators:

    [WebService(Namespace = "http://opcfoundation.org/webservices/XMLDA/1.0/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [XmlInclude(typeof(short[]))]
    

    The GetProperties() method now properly behaves, and the client is able to properly unserialize the array of Int16.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.