Home / C# / OPC XML DA Client with C#

OPC XML DA Client with C#

With this article I want to show how to create a webservice in C# to communicate with an OPC-XML-DA server, like the one of SIMOTION D plc.
OPC-XML-DA is a communication protocol based on SOAP and XML.
To connect to a OPC-XML-DA server you need a WSDL file, that defines the procedures, arguments and data types.
OPC-XML-DA from is different from OPC-DA, because:

  • XML-DA uses an xml serialization to send messages through HTTP, OPC-DA uses a binary efficient codification.
  • Web services are connectionless and stateless, so you can’t create items and groups, or use callbacks like OPC-DA clients. You can use the subscription, but it’s far from the subscription that you have seen in OPC-DA clients. This subscritption is like an “intelligent polling”.
  • You can’t browse for OPC servers like you did with OPC-DA. With XML-DA you need to know the IP address of the web service

An example of device that implements OPC-XML-DA server are the SIMOTION’S CPU family.

With this post i will show you how to create a webservice with Visual Studio and get started with OPC XML DA. Once you did this, there is plenty of resources in internet on how to do a polling to the plc.

How to get the wsdl file

To create a web service you need the wsdl file, and you will find this file on OPC Foundation website.

So go to the OPC Foundation website, browse for OPC XML DA wsdl file, and save it with .wsdl extension.
After the update of OpcFoundation website, i couldn’t find the wsdl anymore.
So you should use wayback machine: http://web.archive.org/web/20120414093633/http://opcfoundation.org/webservices/XMLDA/1.0/




Remember to save the file with .wsdl extension, and not with .xml extension.

Create a web service in Visual Studio

Then to create a webservice in Visual Studio you should follow the next steps:







Sample code:

Siemens provided a document containing an explanation and sample code, check it out here.
I created a sample client based on the code provided by Siemens, you can download it from my github repository.


  1. Very intresting, thanks.

  2. I always enjoy your articles, thanks. I love weaving .NET and automation together.

  3. I could not find the wsdl using this method. Do I need to sign up to be a member of OPCFoundation.org in order to find it?

  4. Roddy Delgado Zambrano

    Regards, I bother with a question? I would like to know how you can access from C # to histrorian data replicated in SQL Server? Do they have any example code or documentation? Sorry my bad english

  5. Mesta, thanks for your interesting blogs.

    A couple of quick question.

    1. I am wondering what is the fastest update rate can opc-xml handle ? Just say if we have 20 variables of array of 360 reals. (7200 variables)

    2. I noticed, sometimes during the async poll, if my data get too big, I lost the subscription from the server. Is this possible due to the server limitation?
    Or is this due to the subscription wait time and hold time?

    • Are you talking about Simotion ?
      If yes, we tried to use subscription but it was bugged in basically every firmware version. What we noticed whas that after a while (hours, or days) the server didn’t gave back the changes to certain variables (random ones, there wasn’t a pattern) and no error of course.
      We gave up with subscription and the only way to get it working with decent performance was to continously poll it and group variables in large arrays.

      • Thanks mesta, that is what I am encountering as well where the tags does not update on the server side and the plc side has updated values.
        Okay, so you used cyclic poll rather than async? If that’s the case, how do you handle the comm thread without lagging the UI thread ?

        Other than the opc-xml, do you have any suggestion on other driver?

  6. Very nice solution!!
    Do you have some examples for the browse and write function??

Leave a Reply

Your email address will not be published.