Announcement Announcement Module
Collapse
No announcement yet.
How to generate XML schema (.xsd file) from Java interface ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to generate XML schema (.xsd file) from Java interface ?

    I am doing a webservice with spring webservice 1.5.9 and I have a problem in generating of XML Schema:

    I have the following interface:

    Code:
    public interface EchoService extends RemoteService{
    	 public String echo(String name);
    }
    Code:
    public class EchoServiceImpl implements EchoService{
    
    	public String echo(String name) {
            if (name == null || name.trim().length() == 0) {
                return "echo back: -please provide a name-";
            }
    		
            SimpleDateFormat dtfmt = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss a");
            return "echo back: " + name + " received on "
                    + dtfmt.format(Calendar.getInstance().getTime());
        }
    	
    	}
    I want to generate "echo" method in EchoService interface to XML schema with the following template:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
    		targetNamespace="http://www.example.com/example/schema"
    		xmlns:tns="http://www.example.com/example/schema" 
    		elementFormDefault="qualified">
    		
       <element name="EchoRequest">
            <complexType>
                <sequence>
                    <element name="Name" type="string"></element>
                </sequence>
            </complexType>
        </element>
    
        <element name="EchoResponse">
            <complexType>
                <sequence>
                    <element name="Message" type="string"></element>
                </sequence>
            </complexType>
        </element>
            
    </schema>
    Help me

    If you have difference ways to generate XML schema, please share to me.
    Last edited by scono1986; Nov 30th, 2010, 11:40 PM.
Working...
X