java - ArcGIS GeoEvent Processor - javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error -
background
i'm using wsimport create java webservice client, connecting .net webservice returning datasets (unfortunately). more specific i'm working on project (inbound transport) geoevent processor suite of esri arcgis server 10.2, think might answered on more general terms in relation jaxb , wsdl bindings. bear me haven't touched java since college (10+ years).
for purposes of wsdl, .net dataset polymorphic type actual layout isn't determined until run time, after dataset has been filled data. causes problems when want use webservice .net.
after research i've managed use wsimport generate webservice wsdl. able put basic proof of concept program gets results webservice dom, walks dom nodelist.
reference:
- jax-ws error on wsdl file: "error resolving component 's:schema'"
- https://weblogs.java.net/blog/vivekp/archive/2007/05/how_to_deal_wit_1.html
- the section on toolkit bindings , figure 6 in http://msdn.microsoft.com/en-us/magazine/cc188755.aspx
my wsimport looks (domain names have been changed protect innocent):
c:\development\arcgis\wsdl>wsimport -b http://www.w3.org/2001/xmlschema.xsd -b xsd.xjb -keep -p com.somecompany.services -xadditionalheaders http://services.somecompany.com/dataretrieval.asmx?wsdl
the problem
unfortunately, same codebase worked in proof of concept, getting results webservice, fails once implement in arcgis geoevent processor. project part of osgi bundle arcgis geoevent processor control. error below shown in apache karaf log geoevent processor.
based on error, understanding there problem how did binding in wsimport, referencing generic schema per links have listed above. looks generic schema lacks definitions of elements exist classes generated wsimport. classes appear generated when check output wsimport.
i've not included wsdl due posting limitations, include in later responses if needed.
what i'm trying figure out
- how should error interpreted?
- why same wsimport generated code used access webservice in basic proof of concept fail when run in arcgis geoevent processor?
- the error mentions jaxb , sax, i'm not consciously referencing either of libraries in proof of concept or project arcgis geoevent processor. binding/unmarshalling of webservice handled differently, arcgis geoevent processor wrapping in jaxb/sax , proof of concept not?
- what can resolve this?
- use different, custom, xsd , xjb spells out expected schema webservice? i'm not sure how done.
- use other wsimport generate webservice reference classes?
- tweak in java environment arcgis geoevent processor?
- other options?
- commit seppuku, it's not problem?
the error
2014-09-23 16:10:14,365 | error | ansport listener | someinboundtransport | 367 - com.somecompany.arcgis.geoevent.transport.inbound.somecompanyinboundtransport - 1.0.0 | unable call webservice javax.xml.ws.soap.soapfaultexception: unmarshalling error: unexpected element (uri:"http://www.w3.org/2001/xmlschema", local:"element"). expected elements <{http://services.somecompany.com/}complextype>,<{http://services.somecompany.com/}annotation>,<{http://services.somecompany.com/}redefine>,<{http://services.somecompany.com/}element>,<{http://services.somecompany.com/}include>,<{http://services.somecompany.com/}attributegroup>,<{http://services.somecompany.com/}group>,<{http://services.somecompany.com/}notation>,<{http://services.somecompany.com/}import>,<{http://services.somecompany.com/}simpletype>,<{http://services.somecompany.com/}attribute> @ org.apache.cxf.jaxws.jaxwsclientproxy.invoke(jaxwsclientproxy.java:156)[120:org.apache.cxf.cxf-rt-frontend-jaxws:2.6.1] @ com.sun.proxy.$proxy198.getcompanyarcgisdata(unknown source)[367:com.somecompany.arcgis.geoevent.transport.inbound.somecompanyinboundtransport:1.0.0] @ com.somecompany.arcgis.geoevent.transport.inbound.someinboundtransport.callwebservice(someinboundtransport.java:184)[367:com.somecompany.arcgis.geoevent.transport.inbound.somecompanyinboundtransport:1.0.0] @ com.somecompany.arcgis.geoevent.transport.inbound.someinboundtransport.run(someinboundtransport.java:257)[367:com.somecompany.arcgis.geoevent.transport.inbound.somecompanyinboundtransport:1.0.0] @ java.lang.thread.run(thread.java:722)[:1.7.0_17] caused by: javax.xml.bind.unmarshalexception - linked exception: [com.sun.istack.saxparseexception2; linenumber: 1; columnnumber: 651; unexpected element (uri:"http://www.w3.org/2001/xmlschema", local:"element"). expected elements <{http://services.somecompany.com/}complextype>,<{http://services.somecompany.com/}annotation>,<{http://services.somecompany.com/}redefine>,<{http://services.somecompany.com/}element>,<{http://services.somecompany.com/}include>,<{http://services.somecompany.com/}attributegroup>,<{http://services.somecompany.com/}group>,<{http://services.somecompany.com/}notation>,<{http://services.somecompany.com/}import>,<{http://services.somecompany.com/}simpletype>,<{http://services.somecompany.com/}attribute>] @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallerimpl.handlestreamexception(unmarshallerimpl.java:425) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallerimpl.unmarshal0(unmarshallerimpl.java:362) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallerimpl.unmarshal(unmarshallerimpl.java:339) @ org.apache.cxf.jaxb.jaxbencoderdecoder.dounmarshal(jaxbencoderdecoder.java:784)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] @ org.apache.cxf.jaxb.jaxbencoderdecoder.access$100(jaxbencoderdecoder.java:97)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] @ org.apache.cxf.jaxb.jaxbencoderdecoder$1.run(jaxbencoderdecoder.java:812) @ java.security.accesscontroller.doprivileged(native method)[:1.7.0_17] @ org.apache.cxf.jaxb.jaxbencoderdecoder.unmarshall(jaxbencoderdecoder.java:810)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] @ org.apache.cxf.jaxb.jaxbencoderdecoder.unmarshall(jaxbencoderdecoder.java:644)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] @ org.apache.cxf.jaxb.io.datareaderimpl.read(datareaderimpl.java:157)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] @ org.apache.cxf.interceptor.docliteralininterceptor.handlemessage(docliteralininterceptor.java:108)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.phase.phaseinterceptorchain.dointercept(phaseinterceptorchain.java:262)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.endpoint.clientimpl.onmessage(clientimpl.java:798)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.transport.http.httpconduit$wrappedoutputstream.handleresponseinternal(httpconduit.java:1667)[118:org.apache.cxf.cxf-rt-transports-http:2.6.1] @ org.apache.cxf.transport.http.httpconduit$wrappedoutputstream.handleresponse(httpconduit.java:1520)[118:org.apache.cxf.cxf-rt-transports-http:2.6.1] @ org.apache.cxf.transport.http.httpconduit$wrappedoutputstream.close(httpconduit.java:1428)[118:org.apache.cxf.cxf-rt-transports-http:2.6.1] @ org.apache.cxf.transport.abstractconduit.close(abstractconduit.java:56)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.transport.http.httpconduit.close(httpconduit.java:658)[118:org.apache.cxf.cxf-rt-transports-http:2.6.1] @ org.apache.cxf.interceptor.messagesenderinterceptor$messagesenderendinginterceptor.handlemessage(messagesenderinterceptor.java:62)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.phase.phaseinterceptorchain.dointercept(phaseinterceptorchain.java:262)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.endpoint.clientimpl.doinvoke(clientimpl.java:532)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.endpoint.clientimpl.invoke(clientimpl.java:464)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.endpoint.clientimpl.invoke(clientimpl.java:367)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.endpoint.clientimpl.invoke(clientimpl.java:320)[87:org.apache.cxf.cxf-api:2.6.1] @ org.apache.cxf.frontend.clientproxy.invokesync(clientproxy.java:89)[119:org.apache.cxf.cxf-rt-frontend-simple:2.6.1] @ org.apache.cxf.jaxws.jaxwsclientproxy.invoke(jaxwsclientproxy.java:134)[120:org.apache.cxf.cxf-rt-frontend-jaxws:2.6.1] ... 4 more caused by: com.sun.istack.saxparseexception2; linenumber: 1; columnnumber: 651; unexpected element (uri:"http://www.w3.org/2001/xmlschema", local:"element"). expected elements <{http://services.somecompany.com/}complextype>,<{http://services.somecompany.com/}annotation>,<{http://services.somecompany.com/}redefine>,<{http://services.somecompany.com/}element>,<{http://services.somecompany.com/}include>,<{http://services.somecompany.com/}attributegroup>,<{http://services.somecompany.com/}group>,<{http://services.somecompany.com/}notation>,<{http://services.somecompany.com/}import>,<{http://services.somecompany.com/}simpletype>,<{http://services.somecompany.com/}attribute> @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallingcontext.handleevent(unmarshallingcontext.java:642) @ com.sun.xml.bind.v2.runtime.unmarshaller.loader.reporterror(loader.java:254) @ com.sun.xml.bind.v2.runtime.unmarshaller.loader.reporterror(loader.java:249) @ com.sun.xml.bind.v2.runtime.unmarshaller.loader.reportunexpectedchildelement(loader.java:116) @ com.sun.xml.bind.v2.runtime.unmarshaller.loader.childelement(loader.java:101) @ com.sun.xml.bind.v2.runtime.unmarshaller.structureloader.childelement(structureloader.java:243) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallingcontext._startelement(unmarshallingcontext.java:478) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallingcontext.startelement(unmarshallingcontext.java:459) @ com.sun.xml.bind.v2.runtime.unmarshaller.staxstreamconnector.handlestartelement(staxstreamconnector.java:242) @ com.sun.xml.bind.v2.runtime.unmarshaller.staxstreamconnector.bridge(staxstreamconnector.java:176) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallerimpl.unmarshal0(unmarshallerimpl.java:360) ... 28 more caused by: javax.xml.bind.unmarshalexception: unexpected element (uri:"http://www.w3.org/2001/xmlschema", local:"element"). expected elements <{http://services.somecompany.com/}complextype>,<{http://services.somecompany.com/}annotation>,<{http://services.somecompany.com/}redefine>,<{http://services.somecompany.com/}element>,<{http://services.somecompany.com/}include>,<{http://services.somecompany.com/}attributegroup>,<{http://services.somecompany.com/}group>,<{http://services.somecompany.com/}notation>,<{http://services.somecompany.com/}import>,<{http://services.somecompany.com/}simpletype>,<{http://services.somecompany.com/}attribute> ... 39 more
the code (snippet)
import com.somecompany.services.*; //generated wsimport import javax.xml.ws.*; //... private com.somecompany.services.dataretrieval myws; private com.somecompany.services.dataretrievalsoap port; private byte[] callwebservice(string username, string pwd, long datatimeframe) { try { myws = new com.somecompany.services.dataretrieval(); port = myws.getdataretrievalsoap(); com.somecompany.services.authsoapheader mysoapheader = new com.somecompany.services.authsoapheader(); mysoapheader.setusername(username); //hash password set soap header string pwdhash = hashmd5(pwd); mysoapheader.setpassword(pwdhash); holder holder = new holder<authsoapheader>(mysoapheader); date endtime = new date(); date starttime = new date(endtime.gettime() - datatimeframe); xmlgregoriancalendar gcendtime = datetogregoriantime(endtime); xmlgregoriancalendar gcstarttime = datetogregoriantime(starttime); getcompanyarcgisdataresponse.getcompanyarcgisdataresult companydata = port.getcompanyarcgisdata(gcstarttime, gcendtime, holder); if( ((authsoapheader)holder.value).geterror() != null) { log.error("authentication web services failed!"); //osgi stop service this.stop(); return null; }else log.info("authentication web services successful."); //convert results java object , byte array send adapter object companydataany = companydata.getany(); byte[] companydatabytes = objecttobytes(companydataany); return companydatabytes; } catch(exception ex) { log.error("unable call webservice", ex); //osgi stop service this.stop(); return null; } }
environment specifics
- jdk 7u17 (1.7.0_17) 64 bit. arcgis geoevent processor using version of jre, i'm locked version execution. though i've done development in 1.7.0_51 before realized that.
- wsimport - jax-ws ri 2.2.4-b01
- arcgis server 10.2
- arcgis geoevent processor extension
- karaf (used arcgis geovent processor run osgi bundles)
this not best answer on this, it's came with.
the arcgis geoevent processor wrapped osgi project appeared doing additional binding/unbinding of web service referenced in application. work-around employed .net (dataset return values) web service function in java wasn't acceptable wrapper geoevent processor.
my solution
ultimately did create secondary .net web service took dataset values , converted them json, , returned json strings. removed problems encountered when attempting reference dataset return values web service, dealing simple json string. wsimport of json web service went smooth, no work-around required. tucked newly imported web service files java project , have no problems.
for reference on c# dataset json:
- using newtonsoft.json (http://james.newtonking.com/json). after playing few other libraries json serialization found worked best me.
- newtonsoft.json available via nuget package
- rick strahl's site big http://weblog.west-wind.com/posts/2008/sep/03/datatable-json-serialization-in-jsonnet-and-javascriptserializer
Comments
Post a Comment