Second solution is much simpler because it uses JAXB to do the validation. It looked simple so decided to use it. Unfortunately when I applied the second solution, I got this cryptic error message.
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ’tns:application’.
First solution didn't work either. I spent whole afternoon on trying to fix the issue but gave up because had other higher priority stories.
A week later, I got a mail from a developer who was having trouble talking to my application. The request was received by the server and a response message was returned but his client application could not process the response message.
The problem was that first element in soap body had wrong namespace associated. First element of the soap body tag had namespace of wsdl while the rest of the message had namespace of the xsd schema. After trying some fruitless configuration changes, I started thinking that this may be a defect in XFire.
Quick google search returned the following entry in XFire JIRA.
Apparently it's behaviour introduced in recent versions of XFire. The solution mentioned in the Jira entry suggests to use
JAXWSProfile
when generating server stubs. The detail of how to use the WS profile is here.Another change I had to make was to use
org.codehaus.xfire.jaxws.JAXWSServiceFactory
instead of org.codehaus.xfire.jaxb2.JaxbServiceFactory
.This problem occured on server and client side so I couldn't detect it.
Sorting out namespace issue also fixed the schema validation issue I had earlier. It turned out that the namespace problem was causing the schema validation above because the first element had wrong namespace.
Well... Web services experience wasn't not quite what I expected. Lots of hidden gotchas....
I will post on general web services experiences and lessons learned later.
No comments:
Post a Comment