469,148 Members | 1,567 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,148 developers. It's quick & easy.

can wsdl's choice of class names be changed?

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 "SubjectList" 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 SubjectListSubject
classes called Subject as a member variable. Ideally i would prefer the
"SubjectListSubject" 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.Serialization.XmlTypeAttribute([Namespace]:="http://localhost/ns/Subjects")>
_

Public Class SubjectList

<System.Xml.Serialization.XmlElementAttribute("Sub ject")> _

Public Subject() As SubjectListSubject

'WOULD PREFER

'Public Subjects() As Subject

End Class

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://localhost/ns/Subjects")>
_

Public Class SubjectListSubject

'WOULD PREFER

'Public Class Subject

Public ID As String

Public Name As String

<System.Xml.Serialization.XmlElementAttribute(Data Type:="integer")> _

Public SubjectCount As String

<System.Xml.Serialization.XmlElementAttribute(Data Type:="integer")> _

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"
elementFormDefault="qualified" attributeFormDefault="qualified"
targetNamespace="http://localhost/ns/Subjects"
xmlns="http://localhost/ns/Subjects">
<xs:element name="SubjectListRequest" type="xs:string"></xs:element>
<xs:element name="SubjectList">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<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="SubjectCount" type="xs:integer"/>
<xs:element name="DocumentCount" type="xs:integer"/>
</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="http://schemas.xmlsoap.org/wsdl/soap/">

<import
namespace="http://localhost/ns/Subjects"
location="http://localhost/ns/BBS_Schema.xsd"
/>

<types/>

<message name="RequestMessage">
<part name="SubjectLevel" element="s0:SubjectListRequest" />
</message>
<message name="ResponseMessage">
<part name="SubjectList" element="s0:SubjectList" />
</message>

<portType name="PortTypeName">
<operation name="GetSubjects">
<input message="s0:RequestMessage" />
<output message="s0:ResponseMessage" />
</operation>
</portType>

<binding name="SubjectsBase" type="s0:PortTypeName">
<soap:binding
transport="http://schemas.xmlsoap.org/soap/http"
style="document"
/>

<operation name="GetSubjects">
<soap:operation soapAction="http://localhost/BBS/GetSubjects"
style="document" />
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
</definitions>
thanks,
Andrew
Jun 28 '06 #1
0 1132

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mike | last post: by
4 posts views Thread by MyName | last post: by
13 posts views Thread by ScottM | last post: by
reply views Thread by John Saunders | last post: by
2 posts views Thread by =?Utf-8?B?TWlnaHR5IE1hcms=?= | last post: by
reply views Thread by =?Utf-8?B?S2FydW5ha2Fy?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.