After my first post about the NBII DREFT web service I yesteday had a second look at it. I decided to refactor the JSP sample client source code for Demo 1 to JSPX/JSTL, beacuse I figured out that redoing the presentation would be an easy way into how data model was. That was a good idea, but not as easy as I thought. The Concept construct was relatively clear to me, but what about Concept Relatives? all ready here I was totally blank. The JSP example is sort of classes MODEL 1 web architecture with the same page both containing the form, receiving the submitted data and doing the presentation. That's not my preferred way of doing it, and neither best practice would I think, som I'll split it up with a very simple Front Controller doing the web servcice call and dispatching to XML style JSP pages, JSPX - hey man, I dig those angle brackets :-). Using JSTL I'm able to do scriptless pages, which are much easier to read/maintain.
In the JSP example there is a comment and some constants are defined like:
the following declarations are to get the associated terms off the conceptResult object. They are stored in the following order. So use the following variables or their values to retrieve the right associated group of terms
int BROADER = 0; int NARROWER = 1; int RELATED = 2; int SUBJECT = 3; int USEFOR = 4;
I sort of didn't understand it right, because when i saw this in the code:
.... //display synonyms for a particular Term Category if(conceptRelatives != null) { if(displayAll||termGroupList.contains(BT)) { //broader terms ConceptRelatives btConRel = conceptRelatives[BROADER]; ....
I was really surprised, because it's almost like voodoo to have that kind of meaning into a sequence (the order), and what puzzled me even more was that these were not even always present, as my example showed me in the Betwixt dump of the object model. What did the schema say:
... 95 <complexType name="ConceptResult"> 96 <sequence> 97 <element 98 name="conceptRelatives" 99 nillable="true" 100 type="impl:ArrayOf_tns1_ConceptRelatives" /> 101 <element 102 name="concept" 103 nillable="true" 104 type="tns1:Concept" /> 105 </sequence> 106 </complexType> ... ... ... 112 <complexType name="ArrayOf_tns1_ConceptRelatives"> 113 <complexContent> 114 <restriction base="soapenc:Array"> 115 <attribute 116 ref="soapenc:arrayType" 117 wsdl:arrayType="tns1:ConceptRelatives[]" /> 118 </restriction> 119 </complexContent> 120 </complexType>
Nothing here. This was very strange and I used quite some time figuring out what was wrong. It turned out that I has sort of fooled my self. I then ran the example and it seemed to work right, which was an even greater puzzle to me. I went back and looked at the encoded response message and found:
19 <multiRef 20 id="id0" 21 soapenc:root="0" 22 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 23 xsi:type="ns3:ConceptResult" 24 xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 25 xmlns:ns3="http://www.w3.org/2001/sw/Europe/skos/namespace"> 26 <conceptRelatives 27 xsi:type="soapenc:Array" 28 soapenc:arrayType="ns3:ConceptRelatives[5]"> 29 <item href="#id2" /> 30 <item xsi:nil="true" /> 31 <item href="#id3" /> 32 <item href="#id4" /> 33 <item xsi:nil="true" /> 34 </conceptRelatives> 35 <concept href="#id5" /> 36 </multiRef>
Those darn xsi:nil they were in the response and therefore in the object model, but Betwixt (and the J2SE XMLEncoder) didn't serialize them since they were null.
So what did I learn from that? That I vulnerable when I know almost zip about the subject, and that i oversaw the fact that they were there and that in fact there is always 5 entires in the ConceptRelatives array. Of couse it's just wated time and there is no one to blame, but it could have been avoided if the creator of the service/WSDL had been explicit about with a minOccurs="5" maxOccurs="5"> as a minimum, but to be really god the diffent semantics of the entries in the array should have been explicit and not kept in an generic type, so like <NarrowerTermCollection>. If I don't give up on this thing I'll try and make a doc/lit WSDL to the best of my knowledge later on, but with the progress rate I'm at right know that's not very likely.
Now that's one thing, another is the indicated Relations in //relation/label is always http://www.w3.org/2004/02/skos/core#useFor which most be an error.
0 comments :
Post a Comment