Hi Experts,
I am getting "Cannot serialize object of class org.ofbiz.manufacturing.bom.BOMTree" error when calling getBOMTree SOAP services using axis2 in my eclipse. If anyone knows how to resolve this please let me know. below is the code which i tried. __________________________________________________________ private static OMFactory fac; private static OMNamespace omNs; static { fac = OMAbstractFactory.getOMFactory(); omNs = fac.createOMNamespace("http://ofbiz.apache.org/service/", "ns1"); } public static void main(String[] args) throws AxisFault { ServiceClient sc = new ServiceClient(); Options opts = new Options(); opts.setTo(new EndpointReference( "http://ds-sgh632ryd5:8081/webtools/control/SOAPService")); opts.setAction("getBOMTree"); sc.setOptions(opts); //Serializable obj = (Serializable) sc.sendReceive(createPayLoad()); OMElement res = sc.sendReceive(createPayLoad()); System.out.println(res); } private static OMElement createPayLoad() { OMElement findPartiesById = fac.createOMElement("getBOMTree", omNs); OMElement mapMap = fac.createOMElement("map-Map", omNs); findPartiesById.addChild(mapMap); mapMap.addChild(createMapEntry("bomType", "MANUF_COMPONENT")); mapMap.addChild(createMapEntry("productId", "10010")); mapMap.addChild(createMapEntry("login.username", "admin")); mapMap.addChild(createMapEntry("login.password", "ofbiz")); return findPartiesById; } private static OMElement createMapEntry(String key, String val) { OMElement mapEntry = fac.createOMElement("map-Entry", omNs); // create the key OMElement mapKey = fac.createOMElement("map-Key", omNs); OMElement keyElement = fac.createOMElement("std-String", omNs); OMAttribute keyAttribute = fac.createOMAttribute("value", null, key); mapKey.addChild(keyElement); keyElement.addAttribute(keyAttribute); // create the value OMElement mapValue = fac.createOMElement("map-Value", omNs); OMElement valElement = fac.createOMElement("std-String", omNs); OMAttribute valAttribute = fac.createOMAttribute("value", null, val); mapValue.addChild(valElement); valElement.addAttribute(valAttribute); // attach to map-Entry mapEntry.addChild(mapKey); mapEntry.addChild(mapValue); return mapEntry; } ________________________________________________________________ Any help is appreciated. Thanks, Hatim |
Hi Hatim Bhatia,
Your email has been moderated, Please subscribe mailing list. http://ofbiz.apache.org/mailing-lists.html Thanks & Regards -- Deepak Dixit On Thu, Sep 27, 2018 at 5:05 PM, [hidden email] < [hidden email]> wrote: > Hi Experts, > > I am getting "Cannot serialize object of class org.ofbiz.manufacturing.bom.BOMTree" > error when calling getBOMTree SOAP services using axis2 in my eclipse. > > If anyone knows how to resolve this please let me know. > below is the code which i tried. > __________________________________________________________ > private static OMFactory fac; > private static OMNamespace omNs; > > static { > fac = OMAbstractFactory.getOMFactory(); > omNs = fac.createOMNamespace("http://ofbiz.apache.org/service/", > "ns1"); > } > > public static void main(String[] args) throws AxisFault { > > ServiceClient sc = new ServiceClient(); > Options opts = new Options(); > opts.setTo(new EndpointReference( > "http://ds-sgh632ryd5:8081/webtools/control/SOAPService")); > opts.setAction("getBOMTree"); > sc.setOptions(opts); > //Serializable obj = (Serializable) sc.sendReceive(createPayLoad()); > OMElement res = sc.sendReceive(createPayLoad()); > > System.out.println(res); > } > > private static OMElement createPayLoad() { > > OMElement findPartiesById = fac.createOMElement("getBOMTree", omNs); > OMElement mapMap = fac.createOMElement("map-Map", omNs); > > findPartiesById.addChild(mapMap); > mapMap.addChild(createMapEntry("bomType", "MANUF_COMPONENT")); > mapMap.addChild(createMapEntry("productId", "10010")); > mapMap.addChild(createMapEntry("login.username", "admin")); > mapMap.addChild(createMapEntry("login.password", "ofbiz")); > > return findPartiesById; > } > > private static OMElement createMapEntry(String key, String val) { > > OMElement mapEntry = fac.createOMElement("map-Entry", omNs); > > // create the key > OMElement mapKey = fac.createOMElement("map-Key", omNs); > OMElement keyElement = fac.createOMElement("std-String", omNs); > OMAttribute keyAttribute = fac.createOMAttribute("value", null, key); > > mapKey.addChild(keyElement); > keyElement.addAttribute(keyAttribute); > > // create the value > OMElement mapValue = fac.createOMElement("map-Value", omNs); > OMElement valElement = fac.createOMElement("std-String", omNs); > OMAttribute valAttribute = fac.createOMAttribute("value", null, val); > > mapValue.addChild(valElement); > valElement.addAttribute(valAttribute); > > // attach to map-Entry > mapEntry.addChild(mapKey); > mapEntry.addChild(mapValue); > > return mapEntry; > } > > ________________________________________________________________ > > > Any help is appreciated. > > Thanks, > Hatim > |
In reply to this post by hatim.bhatia@gmail.com
Hi Hatim,
It seems the issue is occurring because the 'BomTree' class neither implements the Serializable interface not extends any class which implements the Serializable interface. Thanks & Regards -- Deepak Nigam On Fri, Sep 28, 2018 at 10:23 AM [hidden email] < [hidden email]> wrote: > Hi Experts, > > I am getting "Cannot serialize object of class > org.ofbiz.manufacturing.bom.BOMTree" error when calling getBOMTree SOAP > services using axis2 in my eclipse. > > If anyone knows how to resolve this please let me know. > below is the code which i tried. > __________________________________________________________ > private static OMFactory fac; > private static OMNamespace omNs; > > static { > fac = OMAbstractFactory.getOMFactory(); > omNs = fac.createOMNamespace("http://ofbiz.apache.org/service/", > "ns1"); > } > > public static void main(String[] args) throws AxisFault { > > ServiceClient sc = new ServiceClient(); > Options opts = new Options(); > opts.setTo(new EndpointReference( > "http://ds-sgh632ryd5:8081/webtools/control/SOAPService")); > opts.setAction("getBOMTree"); > sc.setOptions(opts); > //Serializable obj = (Serializable) sc.sendReceive(createPayLoad()); > OMElement res = sc.sendReceive(createPayLoad()); > > System.out.println(res); > } > > private static OMElement createPayLoad() { > > OMElement findPartiesById = fac.createOMElement("getBOMTree", omNs); > OMElement mapMap = fac.createOMElement("map-Map", omNs); > > findPartiesById.addChild(mapMap); > mapMap.addChild(createMapEntry("bomType", "MANUF_COMPONENT")); > mapMap.addChild(createMapEntry("productId", "10010")); > mapMap.addChild(createMapEntry("login.username", "admin")); > mapMap.addChild(createMapEntry("login.password", "ofbiz")); > > return findPartiesById; > } > > private static OMElement createMapEntry(String key, String val) { > > OMElement mapEntry = fac.createOMElement("map-Entry", omNs); > > // create the key > OMElement mapKey = fac.createOMElement("map-Key", omNs); > OMElement keyElement = fac.createOMElement("std-String", omNs); > OMAttribute keyAttribute = fac.createOMAttribute("value", null, key); > > mapKey.addChild(keyElement); > keyElement.addAttribute(keyAttribute); > > // create the value > OMElement mapValue = fac.createOMElement("map-Value", omNs); > OMElement valElement = fac.createOMElement("std-String", omNs); > OMAttribute valAttribute = fac.createOMAttribute("value", null, val); > > mapValue.addChild(valElement); > valElement.addAttribute(valAttribute); > > // attach to map-Entry > mapEntry.addChild(mapKey); > mapEntry.addChild(mapValue); > > return mapEntry; > } > > ________________________________________________________________ > > > Any help is appreciated. > > Thanks, > Hatim > |
Hi Hatim
Deepak's right. Since BOMTree is not serializable, you can't use it as part of web service call. Making it serializable is not going to be an option either because then you will have to take care of the complete serialization chain of BOMTree as well. Best, Girish Vasmatkar HotWax Systems On Fri, Sep 28, 2018 at 10:30 AM Deepak Nigam <[hidden email]> wrote: > Hi Hatim, > > It seems the issue is occurring because the 'BomTree' class neither > implements the Serializable interface not extends any class which > implements the Serializable interface. > > > Thanks & Regards > -- > Deepak Nigam > > > > On Fri, Sep 28, 2018 at 10:23 AM [hidden email] < > [hidden email]> wrote: > > > Hi Experts, > > > > I am getting "Cannot serialize object of class > > org.ofbiz.manufacturing.bom.BOMTree" error when calling getBOMTree SOAP > > services using axis2 in my eclipse. > > > > If anyone knows how to resolve this please let me know. > > below is the code which i tried. > > __________________________________________________________ > > private static OMFactory fac; > > private static OMNamespace omNs; > > > > static { > > fac = OMAbstractFactory.getOMFactory(); > > omNs = fac.createOMNamespace("http://ofbiz.apache.org/service/", > > "ns1"); > > } > > > > public static void main(String[] args) throws AxisFault { > > > > ServiceClient sc = new ServiceClient(); > > Options opts = new Options(); > > opts.setTo(new EndpointReference( > > "http://ds-sgh632ryd5:8081/webtools/control/SOAPService")); > > opts.setAction("getBOMTree"); > > sc.setOptions(opts); > > //Serializable obj = (Serializable) > sc.sendReceive(createPayLoad()); > > OMElement res = sc.sendReceive(createPayLoad()); > > > > System.out.println(res); > > } > > > > private static OMElement createPayLoad() { > > > > OMElement findPartiesById = fac.createOMElement("getBOMTree", > omNs); > > OMElement mapMap = fac.createOMElement("map-Map", omNs); > > > > findPartiesById.addChild(mapMap); > > mapMap.addChild(createMapEntry("bomType", "MANUF_COMPONENT")); > > mapMap.addChild(createMapEntry("productId", "10010")); > > mapMap.addChild(createMapEntry("login.username", "admin")); > > mapMap.addChild(createMapEntry("login.password", "ofbiz")); > > > > return findPartiesById; > > } > > > > private static OMElement createMapEntry(String key, String val) { > > > > OMElement mapEntry = fac.createOMElement("map-Entry", omNs); > > > > // create the key > > OMElement mapKey = fac.createOMElement("map-Key", omNs); > > OMElement keyElement = fac.createOMElement("std-String", omNs); > > OMAttribute keyAttribute = fac.createOMAttribute("value", null, > key); > > > > mapKey.addChild(keyElement); > > keyElement.addAttribute(keyAttribute); > > > > // create the value > > OMElement mapValue = fac.createOMElement("map-Value", omNs); > > OMElement valElement = fac.createOMElement("std-String", omNs); > > OMAttribute valAttribute = fac.createOMAttribute("value", null, > val); > > > > mapValue.addChild(valElement); > > valElement.addAttribute(valAttribute); > > > > // attach to map-Entry > > mapEntry.addChild(mapKey); > > mapEntry.addChild(mapValue); > > > > return mapEntry; > > } > > > > ________________________________________________________________ > > > > > > Any help is appreciated. > > > > Thanks, > > Hatim > > > |
Free forum by Nabble | Edit this page |