Calling a WebServices service today throws an exception: org. xml. Sax. saxexception: simpledeserializer encountered a child element, which is not expected, in SOMETH ing it was trying to deserialize.
It took one day to find information online.
Call the WebServices code:
Getsubscriptionreq input = new getsubscriptionreq (); <br/> getsubscriptionrsp output = NULL; <br/> service = new service (); <br/> call = (call) service. createcall (); <br/> call. setTimeout (New INTEGER (20000); <br/> Org. apache. axis. description. operationdesc finished; <br/> Org. apache. axis. description. parameterdesc Param; <br/> parameters = new Org. apache. axis. description. operationdesc (); <br/> operation. setname ("getsubtasks"); <br/> param = new Org. apache. axis. description. parameterdesc (New javax. XML. namespace. QNAME ("http://portalEngine.ismp.chinatelecom.com", "getsubscriptionreq"), <br/> Org. apache. axis. description. parameterdesc. in, new javax. XML. namespace. ("http://req.portalEngine.ismp.chinatelecom.com", "getsubscriptionreq"), <br/> getsubscriptionreq. class, false, false); <br/> values. addparameter (PARAM); <br/> parameter. setreturntype (New javax. XML. namespace. QNAME ("http://rsp.portalEngine.ismp.chinatelecom.com", "getsubscriptionrsp"); <br/> response. setreturnclass (getsubscriptionrsp. class); <br/> example. setreturnqname (New javax. XML. namespace. QNAME ("http://portalEngine.ismp.chinatelecom.com", "getsubscriptionrsp"); <br/> response. setstyle (Org. apache. axis. constants. style. document); <br/> optional. setuse (Org. apache. axis. constants. use. literal); <br/> call. setoperation (operator); <br/> call. setoperationname ("getsubtasks"); <br/> call. settargetendpointaddress ("http: //" + service_addr + "/portalengineservice"); </P> <p> try {<br/> output = (getsubscriptionrsp) Call. invoke (new object [] {input}); // call the WebServices service <br/>} catch (exception E) <br/>{< br/> throw new servantexception ("core_invoke_webservices_failure", E. getmessage (); <br/>}
If the getsubscriptionrsp class object returned by services is not associated with another subinfo class object. this exception will not be reported. this exception is thrown when the getsubscriptionrsp class object in the returned result is associated with another subinfo Class Object in 25 rows. the exception indicates that sub-elements in the returned results cannot be deserialized. it is estimated that the column cannot be in reverse order as subinfo. I searched the internet for a long time to find the solution. Some domestic messages did not find the solution. according to the comments from overseas experts, reading English words one by one is still very important .) the solution is found:
Added several lines of code:
Typemappingregistry registry = service. gettypemappingregistry (); <br/> typemapping mapping = registry. createtypemapping (); <br/> registerbeanmapping (mapping, getsubscriptionreq. class, new javax. XML. namespace. QNAME ("http://req.portalEngine.ismp.chinatelecom.com", "getsubscriptionreq"); <br/> registerbeanmapping (mapping, getsubscriptionrsp. class, new javax. XML. namespace. QNAME ("http://rsp.portalEngine.ismp.chinatelecom.com", "getsubscriptionrsp"); <br/> registerbeanmapping (mapping, subinfo. class, new javax. XML. namespace. QNAME ("http://rsp.portalEngine.ismp.chinatelecom.com", "subinfo"); <br/> registry. register ("http://schemas.xmlsoap.org/soap/encoding/", Mapping); <br/> protected void registerbeanmapping (typemapping mapping, class type, <br/> javax. XML. namespace. QNAME) {<br/> mapping. register (type, QNAME, new beanserializerfactory (type, QNAME), <br/> New beandeserializerfactory (type, QNAME); <br/>}
The exception was never thrown again. I finally gave a sigh of relief. Although the problem was solved, I still don't know why. Why should I add these lines of code? Please kindly advise.