M
Matt
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="s0oSomething" />
</message>
- <message name="DoSomethingSoapOut">
<part name="parameters" element="s0oSomethingResponse" />
</message>
- <portType name="Service1Soap">
- <operation name="DoSomething">
<input message="s0oSomethingSoapIn" />
<output message="s0oSomethingSoapOut" />
</operation>
</portType>
- <binding name="Service1Soap" type="s0:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
- <operation name="DoSomething">
<soapperation 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>
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="s0oSomething" />
</message>
- <message name="DoSomethingSoapOut">
<part name="parameters" element="s0oSomethingResponse" />
</message>
- <portType name="Service1Soap">
- <operation name="DoSomething">
<input message="s0oSomethingSoapIn" />
<output message="s0oSomethingSoapOut" />
</operation>
</portType>
- <binding name="Service1Soap" type="s0:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
- <operation name="DoSomething">
<soapperation 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>