• Post Reply Bookmark Topic Watch Topic
  • New Topic

Schema validation in JAX-WS

 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am developing web services using jax-ws and apache cxf with code first approach . I want to enable schema validation in my service . For this I have configured the cxf configuration file as follows

<jaxws:endpoint id="testService"
implementorClass="com.test.impl.TestServiceImpl"
implementor="#testServiceImpl"
address="/testService">
<jaxws:serviceFactory>
<ref bean="jaxws-and-aegis-service-factory"/>
</jaxws:serviceFactory>
<jaxws:properties>
<entry key="schema-validation-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>

Service,

@WebService
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL)

public interface TestService {



@WebMethod
String test(MyVo myVo) ;

}

MyVo,


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MyVo")
public class MyVo {

@XmlElement(name = "name", required = true)
private String name;

............. // getter and setter

}

.

But after deploying the service wsdl looks like


- <xsd:complexType name="MyVo">
- <xsd:sequence>
<xsd:element minOccurs="0" name="name" nillable="true" type="xsd:string" />

</xsd:sequence>
</xsd:complexType>


As per documentation minOccurs should be 1 (because of required=true ) .

Also I am able to call service without setting name attribute in MyVo object . No error is coming from server.


Please advice .


Thanks in advance




 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For objects, required can also mean they can have null value.
And for strings, empty string also is valid.

Try with this annotation.
 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this also ,but nothing happening.
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by nothing happening? What does generated WSDL have for that element?
 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean no change in the generated wsdl.


- <xsd:complexType name="MyVo">
- <xsd:sequence>
<xsd:element minOccurs="0" name="name" nillable="true" type="xsd:string" />

</xsd:sequence>
</xsd:complexType>


I am using jdk1.6.0_11.
 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some one provide solutions ?
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I provided wrong one earlier.
Please try this.
 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Surendra,
This also not working for me. Is it working for you ? . I am using bottom up approach . Any specific schema validation limitation in code- first approach ?

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!