I am playing around with a simple webservice JAX-WS without using any fancy tools ( no usage of CXF or Metro etc )
I am using inbuilt support provided by JDK 1.6.x to create this web service ( JAX-WS RI 2.1.6 in JDK 6 )
My question - I would like to introduce validations in my web service so I thought I would use the "@SchemaValidation"
Tried importing it as well - but code fails to compile
Snapshot of my code:
package com.mkyong.ws;
import javax.jws.WebService;
**import com.sun.xml.ws.developer.SchemaValidation;**
@WebService(endpointInterface = "com.mkyong.ws.HelloWorld")
**@SchemaValidation()**
public class HelloWorldImpl implements HelloWorld{
While compiling I get the exception :
javac com\mkyong\ws\HelloWorldImpl.java
com\mkyong\ws\HelloWorldImpl.java:3: package com.sun.xml.ws.developer does not exist
import com.sun.xml.ws.developer.SchemaValidation;
^
com\mkyong\ws\HelloWorldImpl.java:8: cannot find symbol
symbol: class SchemaValidation
@SchemaValidation()
^
2 errors
So my question is : Can we not use this annotation with JDK1.6 implementation of RI ? Do I need to import any special jar's in my classpath ? Thanks, satish
Try to consider to use a wsdl. In the wsdl You can add all kind of validations. The validation rules in the wsdl are independant of the language you use to implement your webservice
Use
@SchemaValidation
from thecom.sun.xml.internal.ws.developer.SchemaValidation
package on the service implementation bean if you wish to use the annotation shipped with the JDK. I must note though, I've seen at least two instances where people have had issues using the annotation in this package.The annotation you're attempting to use is bundled with glassfish's JAX-WS RI in the
com.sun.xml.ws.developer.SchemaValidation
package, so you'll need to include it in your project's classpath if you want to make use of that insteadAccording to JarFinder:
http://www.jarfinder.com/index.php/java/info/com.sun.xml.ws.developer.SchemaValidation
Edit - I do not know what exactly that annotation is used for but:
Unmarshaller
class. Have a look toUnmarshaller.setSchema()
, I also have some examples, let me know if you need them.com.sun.xml...
)