title: gSoap generated client-side structure initialization and use
body: <p>gSoap generated client-side structure initialization and use (using ANSI C bindings)</p>
  <p>After reading through <code>gSoap</code> examples and documentation I was not able to find anything directly answering this issue.  I have since sorted it out.  This post/answer pair lays out the problem and my solution.</p>
  <p>Problem description:<br />
  I am using gSoap generated client source code to build ANSI C bindings to access web services.  Arguments 4 &amp; 5 of the &quot;soap_call__&quot; functions provided as application interfaces (defined in <code>soapClient.c</code>) are often generated as complex (nested) structures.  Because <code>struct ns3__send</code> (4th argument) is the input structure, it must be declared, initialized, allocated and freed within the calling application.</p>
  <p>for example, given the following <code>gSoa</code>p generated prototype:</p>
  <pre><code>SOAP_FMAC5 int SOAP_FMAC6 soap_call___ns1__SendFile((struct soap *soap, const char *soap_endpoint, const char *soap_action, struct ns3__send *mtdf, struct recv *response)
  </code></pre>
  <p>with the following structure definition (looking only at argument 4) defined in <code>soapStub.h</code></p>
  <p><em>NOTE: I have shortened the names and reduced the number of members from original contents of the structures to simplify.</em></p>
  <pre><code>struct ns3__send
  {
      char *wsStDate; /* optional element of type xsd:date */
      int *wsStDuration;  /* optional element of type xsd:int */
      int *wsStFailures;  /* optional element of type xsd:int */
      char *wsStFileName; /* optional element of type xsd:string */   
          struct ns3__Param *details; /* optional element of type ns3:Param */
  };
  
  struct ns3__Param
  {
      int __sizeRow;  /* sequence of elements &lt;wsStdDetailsRow&gt; */
      struct ns3__Row *row;   /* optional element of type ns3:xxmtdfws_wsStdDetailsRow */
  };
  
  struct ns3__Row
  {
      int *wsStdSeq;  /* optional element of type xsd:int */
      char *wsStdStep;    /* optional element of type xsd:string */
      char *wsStdTestDesc;    /* optional element of type xsd:string */
      char *wsStdLowLim;  /* optional element of type xsd:string */
  };
  </code></pre>
  <p>Question:<br />
  How are the members and pointers within this complex (nested) input structure properly initialized, memory allocated, values assigned and memory freed such that they are useable within a calling application?</p>