Web service xsd parent element attribute being output as child element?
Hi,
I'm trying to write a service but there seems to be something not working with my set up. I've generated the .Net serialization classes from my xsd using xsd.exe, so far so good. When I query my webservice for the WSDL (http://services_test.portlandpress.c...rvice.svc?wsdl) and XSD (http://services_test.portlandpress.c...e.svc?xsd=xsd1) the returned XSD shows my attributes as elements instead of an attributes.
Here is the relevant snippet from the initial XSD -
Code:
...
<xs:complexType name="ReportRequest">
<xs:annotation>
<xs:documentation/>
</xs:annotation>
<xs:sequence>
<xs:element type="s:Requestor" name="Requestor">
<xs:annotation> <xs:documentation>Consumer of the service (client).</xs:documentation> </xs:annotation>
</xs:element>
<xs:element type="s:CustomerReference" name="CustomerReference">
<xs:annotation> <xs:documentation>Identity of the customer for which data is requested</xs:documentation> </xs:annotation>
</xs:element>
<xs:element type="s:ReportDefinition" name="ReportDefinition">
<xs:annotation> <xs:documentation>Report paramters including report name, version and filters (e.g. date ranges)</xs:documentation> </xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:dateTime" name="Created">
<xs:annotation> <xs:documentation>Date/time the request was created</xs:documentation> </xs:annotation>
</xs:attribute>
<xs:attribute type="xs:string" name="ID">
<xs:annotation> <xs:documentation>Identifier may be provided by client application for internal use/diagnostics.</xs:documentation> </xs:annotation>
</xs:attribute>
</xs:complexType>
...
Here is the same snippet after the call to http://services_test.portlandpress.c...e.svc?xsd=xsd1
Code:
...
<xs:complexType name="ReportRequest">
<xs:sequence>
<xs:element name="createdField" type="xs:dateTime"/>
<xs:element name="createdFieldSpecified" type="xs:boolean"/>
<xs:element name="customerReferenceField" type="tns:CustomerReference" nillable="true"/>
<xs:element name="idField" type="xs:string" nillable="true"/>
<xs:element name="reportDefinitionField" type="tns:ReportDefinition" nillable="true"/>
<xs:element name="requestorField" type="tns:Requestor" nillable="true"/>
</xs:sequence>
</xs:complexType>
...
Any help will be greatly appreciated.
Cheers Al
Re: Web service xsd parent element attribute being output as child element?
Well I've no experience of using this method but surely an attribute has to be an attribute of an element. As you don't define which element they should be associated with I assume that the default is to process them as elements themselves.
Re: Web service xsd parent element attribute being output as child element?
Hi,
Thanks for your reply
My understanding is that the attribute tag defined within an element will make it an attribute of the parent element.
http://www.w3schools.com/xsl/el_attribute.asp
Cheers Al