Auto generated asmx web service documentation omits base class attributes

Discussion in 'ASP .Net Web Services' started by Matt, Nov 3, 2004.

  1. Matt

    Matt Guest

    I am working on a c# web service in VS 2003, .Net Framework version
    1.1. My web method takes as input a complex data class derived from
    another simple data class. Boiled down it looks like the following
    code sample.

    namespace MyService {
    public class MyBaseClass {
    public string s1;
    public string s2;
    }
    public class MyDerivedClass : MyBaseClass {
    public string s3;
    public string s4;
    }
    public class Service1 : System.Web.Services.WebService {
    [System.Web.Services.WebMethod]
    public string DoSomething(MyDerivedClass mdc){
    return mdc.s1 + mdc.s2 + mdc.s3 + mdc.s4;
    }
    }
    }

    My problem is that when I view the auto generated documentation for
    the DoSomething web method at MyService/Service1.asmx?op=DoSomething
    it does not render the attributes of the base class, MyBaseClass in
    the sample SOAP request. Why aren't <s1> and <s2> represented in the
    DoSomething request below?

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <DoSomething xmlns="http://tempuri.org/">
    <mdc>
    <s3>string</s3>
    <s4>string</s4>
    </mdc>
    </DoSomething>
    </soap:Body>
    </soap:Envelope>

    I have spent the day mucking about with DefaultWsdlHelpGenerator.aspx
    to see if it might just be a presentation issue but it seems that the
    ..asmx handler is not providing the details of the base class in the
    service description collections that the help generator draws from the
    Context object. Anyone have any simular experiences or insights on how
    to fix this issue?

    For reference the MyService/Service1.asmx?WSDL presentation is below.
    It shows MyDerivedClass extending MyBaseClass just as it should.

    <?xml version="1.0" encoding="utf-8" ?>
    - <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:s0="http://tempuri.org/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    targetNamespace="http://tempuri.org/"
    xmlns="http://schemas.xmlsoap.org/wsdl/">
    - <types>
    - <s:schema elementFormDefault="qualified"
    targetNamespace="http://tempuri.org/">
    - <s:element name="DoSomething">
    - <s:complexType>
    - <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="mdc"
    type="s0:MyDerivedClass" />
    </s:sequence>
    </s:complexType>
    </s:element>
    - <s:complexType name="MyDerivedClass">
    - <s:complexContent mixed="false">
    - <s:extension base="s0:MyBaseClass">
    - <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="s3" type="s:string" />
    <s:element minOccurs="0" maxOccurs="1" name="s4" type="s:string" />
    </s:sequence>
    </s:extension>
    </s:complexContent>
    </s:complexType>
    - <s:complexType name="MyBaseClass">
    - <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="s1" type="s:string" />
    <s:element minOccurs="0" maxOccurs="1" name="s2" type="s:string" />
    </s:sequence>
    </s:complexType>
    - <s:element name="DoSomethingResponse">
    - <s:complexType>
    - <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="DoSomethingResult"
    type="s:string" />
    </s:sequence>
    </s:complexType>
    </s:element>
    </s:schema>
    </types>
    - <message name="DoSomethingSoapIn">
    <part name="parameters" element="s0:DoSomething" />
    </message>
    - <message name="DoSomethingSoapOut">
    <part name="parameters" element="s0:DoSomethingResponse" />
    </message>
    - <portType name="Service1Soap">
    - <operation name="DoSomething">
    <input message="s0:DoSomethingSoapIn" />
    <output message="s0:DoSomethingSoapOut" />
    </operation>
    </portType>
    - <binding name="Service1Soap" type="s0:Service1Soap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
    style="document" />
    - <operation name="DoSomething">
    <soap:eek:peration soapAction="http://tempuri.org/DoSomething"
    style="document" />
    - <input>
    <soap:body use="literal" />
    </input>
    - <output>
    <soap:body use="literal" />
    </output>
    </operation>
    </binding>
    - <service name="Service1">
    - <port name="Service1Soap" binding="s0:Service1Soap">
    <soap:address location="http://localhost/MyService/Service1.asmx" />
    </port>
    </service>
    </definitions>
    Matt, Nov 3, 2004
    #1
    1. Advertising

  2. Matt

    Dan Rogers Guest

    Hi,

    Full reflection across complexTypes is not a feature of the automatic
    documentation. In all cases, you'll only get the first element name for
    return types or parameters that derive from complex types. The automatic
    documentation tool only "spells out" native types.

    Best regards,

    Dan Rogers
    Microsoft Corporation
    --------------------
    >From: (Matt)
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    >Subject: Auto generated asmx web service documentation omits base class

    attributes
    >Date: 2 Nov 2004 16:03:43 -0800
    >Organization: http://groups.google.com
    >Lines: 131
    >Message-ID: <>
    >NNTP-Posting-Host: 24.1.160.14
    >Content-Type: text/plain; charset=ISO-8859-1
    >Content-Transfer-Encoding: 8bit
    >X-Trace: posting.google.com 1099440224 22081 127.0.0.1 (3 Nov 2004

    00:03:44 GMT)
    >X-Complaints-To:
    >NNTP-Posting-Date: Wed, 3 Nov 2004 00:03:44 +0000 (UTC)
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!new
    sfeed1.ip.tiscali.net!news.glorb.com!postnews1.google.com!not-for-mail
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webservices:26358
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >I am working on a c# web service in VS 2003, .Net Framework version
    >1.1. My web method takes as input a complex data class derived from
    >another simple data class. Boiled down it looks like the following
    >code sample.
    >
    >namespace MyService {
    > public class MyBaseClass {
    > public string s1;
    > public string s2;
    > }
    > public class MyDerivedClass : MyBaseClass {
    > public string s3;
    > public string s4;
    > }
    > public class Service1 : System.Web.Services.WebService {
    > [System.Web.Services.WebMethod]
    > public string DoSomething(MyDerivedClass mdc){
    > return mdc.s1 + mdc.s2 + mdc.s3 + mdc.s4;
    > }
    > }
    >}
    >
    >My problem is that when I view the auto generated documentation for
    >the DoSomething web method at MyService/Service1.asmx?op=DoSomething
    >it does not render the attributes of the base class, MyBaseClass in
    >the sample SOAP request. Why aren't <s1> and <s2> represented in the
    >DoSomething request below?
    >
    ><?xml version="1.0" encoding="utf-8"?>
    ><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    >xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    >xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    > <soap:Body>
    > <DoSomething xmlns="http://tempuri.org/">
    > <mdc>
    > <s3>string</s3>
    > <s4>string</s4>
    > </mdc>
    > </DoSomething>
    > </soap:Body>
    ></soap:Envelope>
    >
    >I have spent the day mucking about with DefaultWsdlHelpGenerator.aspx
    >to see if it might just be a presentation issue but it seems that the
    >.asmx handler is not providing the details of the base class in the
    >service description collections that the help generator draws from the
    >Context object. Anyone have any simular experiences or insights on how
    >to fix this issue?
    >
    >For reference the MyService/Service1.asmx?WSDL presentation is below.
    >It shows MyDerivedClass extending MyBaseClass just as it should.
    >
    > <?xml version="1.0" encoding="utf-8" ?>
    >- <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    >xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    >xmlns:s="http://www.w3.org/2001/XMLSchema"
    >xmlns:s0="http://tempuri.org/"
    >xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    >xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
    >xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    >targetNamespace="http://tempuri.org/"
    >xmlns="http://schemas.xmlsoap.org/wsdl/">
    >- <types>
    >- <s:schema elementFormDefault="qualified"
    >targetNamespace="http://tempuri.org/">
    >- <s:element name="DoSomething">
    >- <s:complexType>
    >- <s:sequence>
    > <s:element minOccurs="0" maxOccurs="1" name="mdc"
    >type="s0:MyDerivedClass" />
    > </s:sequence>
    > </s:complexType>
    > </s:element>
    >- <s:complexType name="MyDerivedClass">
    >- <s:complexContent mixed="false">
    >- <s:extension base="s0:MyBaseClass">
    >- <s:sequence>
    > <s:element minOccurs="0" maxOccurs="1" name="s3" type="s:string" />
    > <s:element minOccurs="0" maxOccurs="1" name="s4" type="s:string" />
    > </s:sequence>
    > </s:extension>
    > </s:complexContent>
    > </s:complexType>
    >- <s:complexType name="MyBaseClass">
    >- <s:sequence>
    > <s:element minOccurs="0" maxOccurs="1" name="s1" type="s:string" />
    > <s:element minOccurs="0" maxOccurs="1" name="s2" type="s:string" />
    > </s:sequence>
    > </s:complexType>
    >- <s:element name="DoSomethingResponse">
    >- <s:complexType>
    >- <s:sequence>
    > <s:element minOccurs="0" maxOccurs="1" name="DoSomethingResult"
    >type="s:string" />
    > </s:sequence>
    > </s:complexType>
    > </s:element>
    > </s:schema>
    > </types>
    >- <message name="DoSomethingSoapIn">
    > <part name="parameters" element="s0:DoSomething" />
    > </message>
    >- <message name="DoSomethingSoapOut">
    > <part name="parameters" element="s0:DoSomethingResponse" />
    > </message>
    >- <portType name="Service1Soap">
    >- <operation name="DoSomething">
    > <input message="s0:DoSomethingSoapIn" />
    > <output message="s0:DoSomethingSoapOut" />
    > </operation>
    > </portType>
    >- <binding name="Service1Soap" type="s0:Service1Soap">
    > <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
    >style="document" />
    >- <operation name="DoSomething">
    > <soap:eek:peration soapAction="http://tempuri.org/DoSomething"
    >style="document" />
    >- <input>
    > <soap:body use="literal" />
    > </input>
    >- <output>
    > <soap:body use="literal" />
    > </output>
    > </operation>
    > </binding>
    >- <service name="Service1">
    >- <port name="Service1Soap" binding="s0:Service1Soap">
    > <soap:address location="http://localhost/MyService/Service1.asmx" />
    > </port>
    > </service>
    > </definitions>
    >
    Dan Rogers, Nov 11, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qazmlp
    Replies:
    1
    Views:
    556
    qazmlp
    Apr 10, 2005
  2. Alf P. Steinbach
    Replies:
    6
    Views:
    533
    John Carson
    Sep 3, 2005
  3. linkswanted
    Replies:
    1
    Views:
    884
  4. Hicham Mouline
    Replies:
    1
    Views:
    583
    Victor Bazarov
    Apr 20, 2009
  5. bparker

    Can't authenticate to lists.asmx web service

    bparker, Nov 14, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    169
    bparker
    Nov 15, 2006
Loading...

Share This Page