Background
I use wsimport to create, in effect, a Java web service client connecting to the web service. Net, which returns data (unfortunately). To be more specific, I am working on a project (inbound transport) for the GeoEvent package for ESRI ArcGIS Server 10.2 processors, but, in my opinion, more general terms can be answered with regard to JAXB and WSDL bindings. Bear with me since I haven't touched Java since college (10+ years).
For purposes of WSDL.Net, a DataSet is a polymorphic type whose actual layout is not determined until run time after the DataSet has been populated with data. This causes problems when you want to use this web service with nothing but .Net.
After some research, I managed to use wsimport to generate wsdl from webservice. Then I was able to compile a basic proof of a conceptual program that receives results from webservice as a DOM, then looks at that DOM as a nodelist.
Link:
My wsimport looks like this (domain names have been changed to protect the 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
Problem
Unfortunately, the same code base that worked in my proof of concept, getting results from a web service, fails as soon as I implement in ArcGIS GeoEvent Processor. My project is part of the OSGI package that will control the ArcGIS GeoEvent processor. The following is an error, as shown in the Apache Karaf log for the GeoEvent processor.
Based on this error, I understand that there is a problem with the way I made the binding in wsimport, referring to the general scheme for the links that I listed above. It seems that in the general scheme there are no definitions for some elements that exist as classes created by wsimport. These classes seem to be properly generated when I check the output from wsimport.
I did not enable WSDL due to wiring restrictions, but included them in later answers if necessary.
What am I trying to find out
- How to interpret this error?
- Why does the same wsimport-generated code used to access the web service in my basic proof of concept occur when I run it in ArcGIS GeoEvent Processor?
- The error mentions JAXB and SAX, I do not knowingly refer to any of these libraries as proof of concept or to a project for ArcGIS GeoEvent Processor. Is it possible that the binding / decoupling of a web service is handled differently, with processing of the ArcGIS GeoEvent processor in JAXB / SAX and proof of concept?
- What can I do to solve this problem?
- Use different, custom, xsd and xjb that describe the expected scheme for a web service? I donβt know exactly how this will be done.
- Use something other than wsimport to create webservice reference classes?
- Change anything in the java environment for the ArcGIS GeoEvent processor?
- Other options?
- Fix seppuku, then this is not my problem?
Error
2014-09-23 16:10:14,365 | ERROR | ansport Listener | SomeInboundTransport | 367 - com.somecompany.arcgis.geoevent.transport.inbound.somecompanyInboundTransport - 1.0.0 | Unable to call Webservice javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (uri:"http://www.w3.org/2001/XMLSchema", local:"element"). Expected elements are <{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> at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)[120:org.apache.cxf.cxf-rt-frontend-jaxws:2.6.1] at com.sun.proxy.$Proxy198.getCompanyArcgisData(Unknown Source)[367:com.somecompany.arcgis.geoevent.transport.inbound.somecompanyInboundTransport:1.0.0] at com.somecompany.arcgis.geoevent.transport.inbound.SomeInboundTransport.callWebService(SomeInboundTransport.java:184)[367:com.somecompany.arcgis.geoevent.transport.inbound.somecompanyInboundTransport:1.0.0] at com.somecompany.arcgis.geoevent.transport.inbound.SomeInboundTransport.run(SomeInboundTransport.java:257)[367:com.somecompany.arcgis.geoevent.transport.inbound.somecompanyInboundTransport:1.0.0] at java.lang.Thread.run(Thread.java:722)[:1.7.0_17] Caused by: javax.xml.bind.UnmarshalException - with linked exception: [com.sun.istack.SAXParseException2; lineNumber: 1; columnNumber: 651; unexpected element (uri:"http://www.w3.org/2001/XMLSchema", local:"element"). Expected elements are <{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>] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339) at org.apache.cxf.jaxb.JAXBEncoderDecoder.doUnmarshal(JAXBEncoderDecoder.java:784)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] at org.apache.cxf.jaxb.JAXBEncoderDecoder.access$100(JAXBEncoderDecoder.java:97)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] at org.apache.cxf.jaxb.JAXBEncoderDecoder$1.run(JAXBEncoderDecoder.java:812) at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_17] at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:810)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:644)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:157)[91:org.apache.cxf.cxf-rt-databinding-jaxb:2.6.1] at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:108)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:798)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1667)[118:org.apache.cxf.cxf-rt-transports-http:2.6.1] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1520)[118:org.apache.cxf.cxf-rt-transports-http:2.6.1] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1428)[118:org.apache.cxf.cxf-rt-transports-http:2.6.1] at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:658)[118:org.apache.cxf.cxf-rt-transports-http:2.6.1] at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:532)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320)[87:org.apache.cxf.cxf-api:2.6.1] at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89)[119:org.apache.cxf.cxf-rt-frontend-simple:2.6.1] at 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 are <{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> at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:254) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:249) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.childElement(Loader.java:101) at com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.childElement(StructureLoader.java:243) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:478) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:459) at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:242) at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176) at 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 are <{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
Code (fragment)
import com.somecompany.services.*; //generated by 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 the password then set it for the 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 to web services failed!"); //OSGI stop service this.stop(); return null; }else log.info("Authentication to web services successful."); //Convert the results to a java object and then to a byte array to send to the adapter Object companyDataAny = companyData.getAny(); byte[] companyDataBytes = objectToBytes(companyDataAny); return companyDataBytes; } catch(Exception ex) { log.error("Unable to call Webservice", ex); //OSGI stop service this.stop(); return null; } }
Environment specification
- JDK 7u17 (1.7.0_17) 64 bit. The ArcGIS GeoEvent processor uses this version of the JRE, so I am locked for this version to run. Although I did some development in 1.7.0_51 before I realized this.
- wsimport - JAX-WS RI 2.2.4-b01
- ArcGIS Server 10.2
- ArcGIS GeoEvent processor extension
- Karaf (used by ArcGIS Geovent Processor to run OSGI packages)