CS526 George E. Turner Spring 2009
Current Implementation Four standard methods used to manipulate complex types in SOAP o Create o Read o Update o Delete
The Update method is extremely inefficient o Comparison to current data to determine “What’s changed?” o Bandwidth is abused when only updating a single field “Why send data that isn’t different?” o Requires a separate method for every field “Additional code to support each new method”
Proposal Create a single update method to update ANY field or child object
The QName classname value defines what is being updated Fully qualified description of the top level object Example: shop:ShoppingCart (namespace:localPart) The String xpathValue defines the keys to distinguish the part to update key=value[ …][ / attribute:key=value[ …]] Example: id=12345/Item:id=3
The any is the new value, ANY valid XML Example: Pork Full SOAP Example <soapenv:Envelope xmlns:soapenv=" xmlns:urn="urn:UpdateService:Operations" xmlns:shop="urn:UpdateService:Shopping"> shop:ShoppingCart id=12345/Item:id=3 Pork
This solution uses a combination of o Java Persistence API (JPA) o Java Reflection o Modifications to generated JAXB public class ObjectFactory { private final static QName _ShoppingCart_QNAME = new QName("urn:UpdateService:Shopping", "ShoppingCart"); private final static QName _OrderItem_QNAME = new QName("urn:UpdateService:Shopping", "OrderItem");
New Code private static final Map QNAME_CLASS_MAP; static { Map tmp = new HashMap (2); tmp.put(_ShoppingCart_QNAME, ShoppingCartType.class); tmp.put(_OrderItem_QNAME, OrderItemType.class); QNAME_CLASS_MAP = Collections.unmodifiableMap(tmp); } public Class getClass(QName qname) { return QNAME_CLASS_MAP.get(qname); }
Conclusion This prototype is not the final solution A Document Object Model solution may be easier Changes to the generated JAXB classes are required Submission to W3C for acceptance and inclusion into milestone releases and specification
References: JAXB – Reference Implementation – JAXWS – Reference Implementation – METRO – Reference Implementation – JPA - Persistence API -