Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Web services Input data validation

 
Janardhan Kotha
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In the wsdl, we had some constraints on the input data.

For eg:-
<xsd:element minOccurs="1" name="DomainID">
<xsd:simpleType>
<xsd:restriction base="int">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="999"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

Web services client & server are implemented in Java. Here the Client builds the DomainID java object and invokes an operation and passes DomainID. Code works fine even if the client sets a value i.e out of range from 0-999. Right now I am validating the data manually on the server side.

Since on the server side I am receiving java object as input, I can NOT use schema defined in WSDL for validation.

Does anyone of you know IF there is a way to inform SOAP Runtime dont send the soap message to the server if input is not valid as per the schema defined in WSDL??

Please share your thoughts on this.

Thanks,
Janardhan.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Janardhan Kotha:
Does anyone of you know IF there is a way to inform SOAP Runtime dont send the soap message to the server if input is not valid as per the schema defined in WSDL??


You haven't indicated which web service API (JAX-RPC, JAX-WS) and which Web service toolkit (Axis, Axis 2, Glassfish Apache CXF, etc.) you are using.

Many SOAP web service toolkits do not validate incoming documents against the schema for performance reasons. And if they did you would need to be able to configure how schema validation errors map to SOAP faults (which themselves need to appear in the WSDL).

So the only recourse is to develop a SOAP Message handler that validates the incoming document and then issue an appropriate SOAP fault if the validation fails.

Writing a Handler in JAX-WS
How to create a simple JAX-RPC handler
 
Janardhan Kotha
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peer Reynders.

We are using Websphere runtime for web services and JAX-RPC in client side.

Do you know by any chance if IBM has any option to enable the data validation by schema?

Thanks,
Janardhan.
 
Chris Graham (WarpSpeed)
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Janardhan Kotha:
Thanks Peer Reynders.

We are using Websphere runtime for web services and JAX-RPC in client side.

Do you know by any chance if IBM has any option to enable the data validation by schema?

Thanks,
Janardhan.


Hello. I have exactly the same issue. Did you ever find a means of doing this?

Thanks.

-Chris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic