The UA Specification Rendered in Angle Brackets 

Tags:

UA is a specification that is based on the web service model. This means that all of the services defined in the UA specification are described by a WSDL which can be used by any application that understands WSDLs. The UA specification also defines a number of data types that can be exchanged via UA but are not used directly in the services. These types are described by an XML Schema.

The first step in building a UA application requires that you choose a web services stack that supports the programming language of your choice and then use the WSDL tool that comes with the stack to generate the client and/or server APIs.

WCF uses the svcutil.exe tool. The following command will generate the interface contracts:

svcutil /namespace:*,Opc.Ua http://opcfoundation.org/UA/2008/02/Services.wsdl /out:Opc.Ua.Services.cs

The options above will produce code that uses arrays for lists defined in the schema. Adding the following options will use the generic List<T> type instead:

/reference:C:\windows\Microsoft.NET\Framework\v2.0.50727\System.dll /ct:System.Collections.Generic.List`1

It is a lot easier to work with code based on the List<T> type.

The generated code will contain classes for all of the UA defined data types that are referenced directly by the UA services. However, there are a number of UA defined data types which are only used as values for variables which are not included in the auto-generated output. For this reason, it is necessary to run the tool directly on the UA XML schema. This can be done with the following command:

svcutil /dconly /namespace:*,Opc.Ua Types.xsd /out:Opc.Ua.Types.cs

Note that svcutil does not work with online schemas and, as a result, the schema must be first downloaded from http://opcfoundation.org/UA/2008/02/Types.xsd to a local file. The options that specify List<T> instead of arrays can also be added to the command.

At this point you will have all of the code necessary to invoke or implement UA web services with WCF. Unfortunately, the same schema is processed when reading WSDL with svcutil which means that there will be classes that appear in both autogenerated files. These duplicate classes can be quickly dealt with by deleting the all of the data type classes that appear at the start of the Services.cs file. If this creates a problem for users of other WSDL tools the OPC Foundation will provide two seperate schema documents.

A similar process would work for Java developers who use the JAX-WS libraries. In this case the command is 'wsimport' and can be invoked with the following arguments:

wsimport -extension http://opcfoundation.org/UA/2008/02/Services.wsdl

The classes for data types which are not referenced by the WSDL can be produced by using the JAXB schema compiler on the UA XML Schema with the following command:

xjc -extension http://opcfoundation.org/UA/2008/02/Types.xsd

Those of you familiar with WSDL mechanics may have noticed that the UA WSDL specifies SOAP 1.2 bindings which may not be supported by some older WSDL tools. The SOAP 1.2 requirement is mandated by the default XML Web Services mapping in Part 6. This mapping also specifies that compliant applications must use SOAP stacks which support WS-Security 1.1, WS-Trust 1.3, WS-Secure Conversation 1.3 and WS-Addressing 1.0. UA will likely define additional mappings in the future which require other combinations of WS-* specifications. The exact combinations will be determined by the needs of OPC Foundation members and end users as they gain experience deploying UA applications in the field.

That said, there is nothing in the base UA specification that prevents application developers from using non-standard mappings for specific systems. The mappings exist because UA needs to limit the number of permutations and combinations used to test applications for compliance. This policy, in turn, will minimize the number of interoperability problems for UA users.

Future blog posts will look at the configuring a SOAP stack to use the correct WS security options. The autogenerated files will allow you to develop interoperable UA applications without security. 

A ZIP file containing the auto-generated code can be downloaded from here.

 
Posted by OPCF02\randyarmstrong on 25-Jan-09
0 Comments  |  | Bookmark this post with:        
 
Failed to render control: Value does not fall within the expected range.

Comments

Name:
URL:
Email:
Comments:

CAPTCHA Image Validation