Skip to main content

accessing xsd during runtime from handler?

6 replies [Last post]
vguna
Offline
Joined: 2006-03-03

Hi.

How is it possible to access the auto-generated xsd per endpoint during runtime from a handler? In the handler I do the xsd schema validation of the payload and for this I need the generated xsd for the current endpoint.

Actually I've got an ugly workaround that takes the requestedURL from the ServletRequest of the MessageContext and does a SchemaFactory.newSchema on the URL appended with ?xsd=1. Although I'm caching the validator instances per URL, that will be a performance hit and is not really a nice solution. Are there alternatives?

Regards,
Veit

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jitu
Offline
Joined: 2003-06-14

There are some solutions. for e.g From MessageContext, you could get WSEndpoint object. Then you could use WSEndpoint.getServiceDefinition() to get WSDL and schema documents. You could use them for validation. So you need to use lot JAX-WS RI's API classes to achieve this. We plan to provide some sort of validation support in future.

vguna
Offline
Joined: 2006-03-03

Sounds like a better solution to me than what I'm actually doing.

How do I achieve this? Get the WSEndpoint from the MessageContext? All WSDL_* constants just return qname's or URIs. Is there an undocumented key that I can use to get the WSEndpoint? From there on I could find my way alone.

Thanks for the hint!

kohsuke
Offline
Joined: 2003-06-09

See JAXWSProperties.WSENDPOINT

vguna
Offline
Joined: 2006-03-03

Thanks.

Seems so, that WSEndpoint.getServiceDefinition() is always null when it's an outbound message. Is that a bug or by design? Nevertheless it's enough for me to do the schemavalidation since I cache the schema instance per url. Since the incoming message is always the 1st call, there's no problem for me because the outgoing url is the same.

That javadoc on the JAXWSProperties.WSENDPOINT should inform me, that there will be a better solution in future, right :)?

THIS PROPERTY IS EXPERIMENTAL AND IS SUBJECT TO CHANGE WITHOUT NOTICE IN FUTURE.

Thanks for your help!

Regards,
Veit

jitu
Offline
Joined: 2003-06-14

Is the JAXWSProperties.WSENDPOINT null during the Outbound ? Otherwise, WSEndpoint.getserviceDefinition() shouldn't be null(if there are WSDL and schema documents).

vguna
Offline
Joined: 2006-03-03

Sorry, yes you're right. JAXWSProperties.WSENDPOINT is null during Outbound. But no problem for me since I already got the schema during Inbound.

Regards,
Veit