'How to provide complex objects as parameters to web service functions

I am new to consuming web services with .Net and facing following issue. I have a WSDL with following definition

<s:element name="ClassTransfer">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="trans" type="tns:ClassStudent" />
            <s:element minOccurs="0" maxOccurs="1" name="RollNo" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:complexType name="ClassStudent">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Subject" type="s:string" />
…
        </s:sequence>
      </s:complexType>

And in code when calling the function

SchoolWebService.RemoteClassApi objSchool = new SchoolWebService.RemoteClassApi();
res= objSchool.ClassTransfer(…)

it required me to provide two parameters: ClassStudent trans & string RollNo

RollNo can be provided simply as a string but I don’t know how to provide trans object?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source