The only way I can think of doing what you want to do is to process the WSDL programmatically (using, for instance, WSDL4J) and extract the XML schema, which you then feed a Resource object holding (or referring to) the XML schema to the Jaxb2Marshaller object.
I suspect that this will require some programming on your part.
Since Spring WS doesn’t use a service contract, you must know the request and response type.
The test below demonstrates how to create and instantiate a request object of a JAXB generated class, call the marshall Send And Receive method with it and how to cast the response object to an object of the JAXB generated response class.
Create a String Reader with the String and create a Stream Source object with the String Reader.
For all the details, see the source code: When the Payload Validating Interceptor work as expected, the interceptor will throw a Web Service Validation Exception when you try to send a value that’s not valid according to the XSD schema. The validation issues is a minus, but since it’s an open-source project, you always have the chance to replace or extend the classes you want.
If we dont provide, then it will try to fetch the information from wsdl file and if it doesnt even find it in wsdl, then it would give you an error called , "cvc: element not found".
I am so happy that together with some ideas, we did it !!
But, I am really thankful to you for your patience and your suggestions! So, What I learnt was, If we do provide a schema property, it will use it.The client part of Spring WS can validate the parsed XML before it sends the XML document.You only need to specify a validator interceptor in the configuration and reference to it from the Web Service Template bean.It’s an issue with the SAX validator and the DOM source element that represents the parsed XML.A quick fix to solve this problem is to transform the DOM source to a String.