views:

108

answers:

1

Using the following Webservice definition using aClientArgs as a complex type:

[System.Web.Script.Services.ScriptService]
public class Controller : System.Web.Services.WebService {
    [WebMethod]
    public void save_client(aClientArgs client)
    {
           // Save client data
    }
}

Then defining aClientArgs as a sub-class:

public class aArgs 
{
    public string id = null;
    public string name = null;
}

public class aClientArgs : aArgs
{
    public string address = null;
    public string website = null;
}

Returns the following WSDL fragment for the save_client args:

<save_client xmlns="http://tempuri.org/"&gt;
  <client>
    <address>string</address>
    <website>string</website>
  </client>
</save_client>

When I'm expecting the following:

<save_client xmlns="http://tempuri.org/"&gt;
  <client>
    <id>string</id>
    <name>string</name>
    <address>string</address>
    <website>string</website>
  </client>
</save_client>

So it appears that the .NET WebService is not treating inherited properties as arguments/variables for purposes of a web service. How do I get .NET to also use the properties of the base class?

+2  A: 

How did you determine that the WSDL is wrong? Did you browse to the service and click the link for the save_client method?

That's just a help page. In this case, it's wrong. Click the link for the service description, and I think you'll see the following:

  <s:complexType name="aClientArgs">
    <s:complexContent mixed="false">
      <s:extension base="tns:aArgs">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Address" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Website" type="s:string" />
        </s:sequence>
      </s:extension>
    </s:complexContent>
  </s:complexType>
  <s:complexType name="aArgs">
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="ID" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
    </s:sequence>
  </s:complexType>
John Saunders
You're right ... wow, do I feel silly!
pygorex1