Hi everyone,
I've been going through an article i found on MSDN
(http://msdn.microsoft.com/msdnmag/is...ervicesDesign/)
concerning designing the messages for a webservice in a schema (xsd) first
and then writing a .wsdl file that imports the schema. Following this i have
used wsdl.exe (that comes with framework 1.1) to generate an abstract class
which my webservice inherits from.
All has gone well with this until i actually looked at my abstract class -
some of the class and variable names do not seem ideal. Essentially I want
to return an xml root element called "SubjectLis t" which has a number of
"Subject" elements inside it. The XML looks great but wsdl.exe produces a
class with a SubjectList class that has an array of SubjectListSubj ect
classes called Subject as a member variable. Ideally i would prefer the
"SubjectListSub ject" class to be renamed to just "Subject", also i would
like to rename the array to be called "Subjects" instead of "Subject". I
suppose these are just things that would make the proxy more usable. I'm
thinking i could alter the proxy myself but that wouldn't help me when non
..net languages use the wsdl to generate proxies in different languages.
I was hoping there was some additional way i could mark-up the wsdl file or
my xsd schema so wsdl.exe uses the appropriate names?
Sorry for the long post - i've included my wsdl file and xsd schema in case
it helps - also a code snippet showing how it currently looks and how i'd
prefer it to look.
CODE SNIPPET:
<System.Xml.Ser ialization.XmlT ypeAttribute([Namespace]:="http://localhost/ns/Subjects")>
_
Public Class SubjectList
<System.Xml.Ser ialization.XmlE lementAttribute ("Subject")> _
Public Subject() As SubjectListSubj ect
'WOULD PREFER
'Public Subjects() As Subject
End Class
<System.Xml.Ser ialization.XmlT ypeAttribute([Namespace]:="http://localhost/ns/Subjects")>
_
Public Class SubjectListSubj ect
'WOULD PREFER
'Public Class Subject
Public ID As String
Public Name As String
<System.Xml.Ser ialization.XmlE lementAttribute (DataType:="int eger")> _
Public SubjectCount As String
<System.Xml.Ser ialization.XmlE lementAttribute (DataType:="int eger")> _
Public DocumentCount As String
End Class
XSD SCHEMA:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefa ult="qualified" attributeFormDe fault="qualifie d"
targetNamespace ="http://localhost/ns/Subjects"
xmlns="http://localhost/ns/Subjects">
<xs:element name="SubjectLi stRequest" type="xs:string "></xs:element>
<xs:element name="SubjectLi st">
<xs:complexType >
<xs:sequence maxOccurs="unbo unded">
<xs:element name="Subject">
<xs:complexType >
<xs:sequence>
<xs:element name="ID" type="xs:string "/>
<xs:element name="Name" type="xs:string "/>
<xs:element name="SubjectCo unt" type="xs:intege r"/>
<xs:element name="DocumentC ount" type="xs:intege r"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
WSDL FILE :
<?xml version="1.0" encoding="utf-8" ?>
<definitions
xmlns="http://schemas.xmlsoap .org/wsdl/"
targetNamespace ="http://localhost/ns/Subjects"
xmlns:s0="http://localhost/ns/Subjects"
xmlns:soap="htt p://schemas.xmlsoap .org/wsdl/soap/">
<import
namespace="http ://localhost/ns/Subjects"
location="http://localhost/ns/BBS_Schema.xsd"
/>
<types/>
<message name="RequestMe ssage">
<part name="SubjectLe vel" element="s0:Sub jectListRequest " />
</message>
<message name="ResponseM essage">
<part name="SubjectLi st" element="s0:Sub jectList" />
</message>
<portType name="PortTypeN ame">
<operation name="GetSubjec ts">
<input message="s0:Req uestMessage" />
<output message="s0:Res ponseMessage" />
</operation>
</portType>
<binding name="SubjectsB ase" type="s0:PortTy peName">
<soap:binding
transport="http ://schemas.xmlsoap .org/soap/http"
style="document "
/>
<operation name="GetSubjec ts">
<soap:operati on soapAction="htt p://localhost/BBS/GetSubjects"
style="document " />
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
</definitions>
thanks,
Andrew