Results 1 to 3 of 3

Thread: Web service xsd parent element attribute being output as child element?

  1. #1

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    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
    Last edited by aconybeare; Dec 5th, 2012 at 07:37 AM. Reason: Correct typos

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width