Hello,

If you want to know a solution, here it is (yep, it's not a rocket science, but 
matter of experience and very importantly time saver for critical business 
deadlines!!):


javax.xml.bind.JAXBElement<org.uddi.api_v3.TModel> objJAXBELEM = 

  
(javax.xml.bind.JAXBElement<org.uddi.api_v3.TModel>)org.apache.juddi.jaxb.EntityCreator.buildFromString("<custom
 run-time created saveTModel string>", "org.uddi.api_v3");

org.uddi.api_v3.TModel newTM = objJAXBELEM.getValue();

st.getTModel().add(newTM);


PUBLISH_PORTTYPE.saveTModel(st);



This way, you can create a publisher and also create a corresponding TModel "on 
the fly" -- using *BOTH* the methods namely, EntityCreator.buildFromString(...) 
and  EntityCreator.buildFromDoc(...).


Enjoy if you liked it!


-Cli





----- Original Message -----
From: Computer Learning Inst
To: "[email protected]"
Cc: Kurt Stam
Sent: Monday, September 12, 2011 1:19 AM
Subject: EntityCreator: buildFromDoc / buildFromString

Hello jUDDI users:

We are getting over the task of creating a publisher and then creating a 
corresponding TModel "on the fly", that is, programmatically.  We had dig 
through jUDDI's code base and find it ourselves (hopefully, we have right 
solutions which won't affect our future deployments with jUDDI!).

Anyway, why does EntityCreator.buildFromString(...) throw ClassCastException 
whereas EntityCreator.buildFromDoc(...) does not?  See below for an example.


THIS SNIPPET WORKS [EntityCreator.buildFromDoc]:
============================================

org.uddi.api_v3.TModel tmIn = 
(org.uddi.api_v3.TModel)EntityCreator.buildFromDoc(tModelXml, 
"org.uddi.api_v3");
(wheretModelXml is a file that we create using java.io package, save it 
temporarily, and read from it again -- since buildFromString throws the 
exception below..).

THIS SNIPPET THROWS ClassCastException [EntityCreator.buildFromString]:
==========================================================
org.uddi.api_v3.TModel tmIn = 
(org.uddi.api_v3.TModel)EntityCreator.buildFromString("<custom run-time created 
saveTModel string>", "org.uddi.api_v3");


For our requirement, EntityCreator.buildFromString(...) is lot more desirable, 
but it doesn't like the ClassCast of its return type to TModel.

Any thoughts, ideas, insight?  Thank you.

Reply via email to