Announcement Announcement Module
Collapse
No announcement yet.
STS spring-ws tutorial code bug Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • STS spring-ws tutorial code bug

    I have found a bug in the HolidayRequestClient class. In the createHolidayRequest method where adding the startDate and endDate to the rootElement content, it looks like a misplaced end bracket embeds the endDate attribute inside the startDate ie:
    Code:
    document.getRootElement()
    	.addContent(new Element("Holiday", hrNs)
    		.addContent(new Element("StartDate", hrNs).setText(fmt.format(startDate))
    				.addContent(new Element("EndDate", hrNs).setText(fmt.format(endDate)))))
    				.addContent(new Element("Employee", hrNs)
    				.addContent(new Element("Number", hrNs).setText(String.valueOf(employeeId)))
    				.addContent(new Element("FirstName", hrNs).setText(firstName))
    				.addContent(new Element("Number", hrNs).setText(lastName)));
    Produces the following XML:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <hr:HolidayRequest xmlns:hr="http://mycompany.com/hr/schemas">
      <hr:Holiday>
        <hr:StartDate>
          2008-08-01
          <hr:EndDate>2008-08-31</hr:EndDate>
        </hr:StartDate>
      </hr:Holiday>
      <hr:Employee>
        <hr:Number>1</hr:Number>
        <hr:FirstName>William</hr:FirstName>
        <hr:Number>Nicholson</hr:Number>
      </hr:Employee>
    </hr:HolidayRequest>
    What should be actually this in the code:
    Code:
    document.getRootElement()
    	.addContent(new Element("Holiday", hrNs)
    		.addContent(new Element("StartDate", hrNs).setText(fmt.format(startDate)))//<-- ADD HERE 
    				.addContent(new Element("EndDate", hrNs).setText(fmt.format(endDate)))) //REMOVED HERE
    				.addContent(new Element("Employee", hrNs)
    				.addContent(new Element("Number", hrNs).setText(String.valueOf(employeeId)))
    				.addContent(new Element("FirstName", hrNs).setText(firstName))
    				.addContent(new Element("Number", hrNs).setText(lastName)));
    Produces the correct XML

    Code:
    <hr:HolidayRequest xmlns:hr="http://mycompany.com/hr/schemas">
      <hr:Holiday>
        <hr:StartDate>2008-08-01</hr:StartDate>
        <hr:EndDate>2008-08-31</hr:EndDate>
      </hr:Holiday>
      <hr:Employee>
        <hr:Number>1</hr:Number>
        <hr:FirstName>William</hr:FirstName>
        <hr:Number>Nicholson</hr:Number>
      </hr:Employee>
    </hr:HolidayRequest>
    Can we get someone from Springsource to check this out, and make amends in their deployer files for the tutorials.
Working...
X