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 8144861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:29:34+00:00 2026-06-06T13:29:34+00:00

I’m trying to develop a soap client that will access data over the OPC

  • 0

I’m trying to develop a soap client that will access data over the OPC XML-DA specification: Here

I’ve used the tools provided by gSOAP to generate the gSOAP header file from the OPC Foundations WSDL. (Relevant parts below)

I can’t seem to get gSOAP to properly add an attribute to the tag. (See Output section below). Is there a builtin way to do this, or will the WSDL/gSOAP header need to be modified?

WSDL extract:

<s:complexType name="ItemValue">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="DiagnosticInfo" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Value" />
<s:element minOccurs="0" maxOccurs="1" name="Quality" type="s0:OPCQuality" />
</s:sequence>
<s:attribute name="ValueTypeQualifier" type="s:QName" />
<s:attribute name="ItemPath" type="s:string" />
<s:attribute name="ItemName" type="s:string" />
<s:attribute name="ClientItemHandle" type="s:string" />
<s:attribute name="Timestamp" type="s:dateTime" />
<s:attribute name="ResultID" type="s:QName" />
</s:complexType>

Generated gSOAP header

class ns1__ItemValue
{ public:
/// Element DiagnosticInfo of type xs:string.
    char*                                DiagnosticInfo                 0;  ///< Optional element.
/// Element 'Value' has no type or ref: assuming XML content.
    _XML                                 Value                          0;  ///< Optional element.
/// Element Quality of type "http://opcfoundation.org/webservices/XMLDA/1.0/":OPCQuality.
    ns1__OPCQuality*                     Quality                        0;  ///< Optional element.
/// Attribute ValueTypeQualifier of type xs:QName.
   @_QName                               ValueTypeQualifier             0;  ///< Optional attribute.
/// Attribute ItemPath of type xs:string.
   @char*                                ItemPath                       0;  ///< Optional attribute.
/// Attribute ItemName of type xs:string.
   @char*                                ItemName                       0;  ///< Optional attribute.
/// Attribute ClientItemHandle of type xs:string.
   @char*                                ClientItemHandle               0;  ///< Optional attribute.
/// Attribute Timestamp of type xs:dateTime.
   @time_t*                              Timestamp                      0;  ///< Optional attribute.
/// Attribute ResultID of type xs:QName.
   @_QName                               ResultID                       0;  ///< Optional attribute.
/// A handle to the soap struct that manages this instance (automatically set)
    struct soap                         *soap                          ;
};

Generated Code

class SOAP_CMAC ns1__ItemValue
{
public:
    char *DiagnosticInfo;   /* optional element of type xsd:string */
    char *Value;    /* optional element of type xsd:anyType */
    class ns1__OPCQuality *Quality; /* optional element of type ns1:OPCQuality */
    char *ValueTypeQualifier;   /* optional attribute */
    char *ItemPath; /* optional attribute */
    char *ItemName; /* optional attribute */
    char *ClientItemHandle; /* optional attribute */
    time_t *Timestamp;  /* optional attribute */
    char *ResultID; /* optional attribute */
    struct soap *soap;  /* transient */
public:
    virtual int soap_type() const { return 18; } /* = unique id SOAP_TYPE_ns1__ItemValue */
    virtual void soap_default(struct soap*);
    virtual void soap_serialize(struct soap*) const;
    virtual int soap_put(struct soap*, const char*, const char*) const;
    virtual int soap_out(struct soap*, const char*, int, const char*) const;
    virtual void *soap_get(struct soap*, const char*, const char*);
    virtual void *soap_in(struct soap*, const char*, const char*);
             ns1__ItemValue() : DiagnosticInfo(NULL), Value(NULL), Quality(NULL), ValueTypeQualifier(NULL), ItemPath(NULL), ItemName(NULL), ClientItemHandle(NULL), Timestamp(NULL), ResultID(NULL), soap(NULL) { }
    virtual ~ns1__ItemValue() { }
};

Output

<ns1:Items
    ClientItemHandle="Channel1.Device1"
    ItemName="Channel_1.Device_1.Tag_1"
    ValueTypeQualifier="xsd:unsignedInt">
    <Value
        xmlns="http://opcfoundation.org/webservices/XMLDA/1.0/">
        5
    </Value>
</ns1:Items>

Needed Output

<ns1:Items
    ClientItemHandle="Channel1.Device1"
    ItemName="Channel_1.Device_1.Tag_1"
    ValueTypeQualifier="xsd:unsignedInt">
    <Value
        xmlns="http://opcfoundation.org/webservices/XMLDA/1.0/"
        xsi:Type="xsd:unsignedInt">
        5
    </Value>
</ns1:Items>

Output means the XML that is generated and sent over the wire to the remote server.

  • 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-06-06T13:29:35+00:00Added an answer on June 6, 2026 at 1:29 pm

    @Tisho, thanks for your input.

    It turns out that the WSDL provided by the OPC Foundation lacked to specify a type on the value element. Our solution was to add a type of s:anyType, this allowed us to use polymorphic types such as:
    xsd_unsignedInt
    xsd
    _string
    xsd__anyType

    Since all of the types inherited from xsd__anyType, and a virtual soap_type function was included, we can use any of the types, and store them in the value, then gSOAP magically uses the soap_type to figure out what type the var is.

    Relevant portion of the OPC Foundation’s WSDL Modified:

    <s:complexType name="ItemValue">
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="DiagnosticInfo" type="s:string"/>
        <s:element minOccurs="0" maxOccurs="1" name="Value" type="s:anyType"/> <!-- Here -->
        <s:element minOccurs="0" maxOccurs="1" name="Quality" type="s0:OPCQuality"/>
      </s:sequence>
      <s:attribute name="ValueTypeQualifier" type="s:QName"/>
      <s:attribute name="ItemPath" type="s:string"/>
      <s:attribute name="ItemName" type="s:string"/>
      <s:attribute name="ClientItemHandle" type="s:string"/>
      <s:attribute name="Timestamp" type="s:dateTime"/>
      <s:attribute name="ResultID" type="s:QName"/>
    </s:complexType>
    

    Here’s the new gSOAP generated header

    class ns1__ItemValue : public xsd__anyType
    { public:
    /// Element DiagnosticInfo of type xs:string.
        char*                                DiagnosticInfo                 0;  ///< Optional element.
    /// Element Value of type xs:anyType.
        xsd__anyType*                        Value                          0;  ///< Optional element.
    /// Element Quality of type "http://opcfoundation.org/webservices/XMLDA/1.0/":OPCQuality.
        ns1__OPCQuality*                     Quality                        0;  ///< Optional element.
    /// Attribute ValueTypeQualifier of type xs:QName.
       @_QName                               ValueTypeQualifier             0;  ///< Optional attribute.
    /// Attribute ItemPath of type xs:string.
       @char*                                ItemPath                       0;  ///< Optional attribute.
    /// Attribute ItemName of type xs:string.
       @char*                                ItemName                       0;  ///< Optional attribute.
    /// Attribute ClientItemHandle of type xs:string.
       @char*                                ClientItemHandle               0;  ///< Optional attribute.
    /// Attribute Timestamp of type xs:dateTime.
       @time_t*                              Timestamp                      0;  ///< Optional attribute.
    /// Attribute ResultID of type xs:QName.
       @_QName                               ResultID                       0;  ///< Optional attribute.
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
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
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 used javascript for loading a picture on my website depending on which small

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.