- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用 wsimport 创建一个本质上是 Java 网络服务客户端的东西,连接到返回数据集的 .Net 网络服务(不幸的是)。更具体地说,我正在为 ESRI ArcGIS Server 10.2 的 GeoEvent Processor 套件开发一个项目(入站传输),但我认为这可能会用与 JAXB 和 WSDL 绑定(bind)相关的更一般的术语来回答。请耐心等待,因为我自大学以来(10 年以上)就没有接触过 Java。
出于 WSDL 的目的,.Net DataSet 是一种多态类型,其实际布局直到运行时才确定,在 DataSet 已填充数据之后。当您想将该 web 服务与 .Net 以外的任何东西一起使用时,这会导致问题。
经过一些研究,我设法使用 wsimport 从网络服务生成 wsdl。然后我能够将一个基本的概念验证程序放在一起,该程序从 Web 服务获取结果作为 DOM,然后将该 DOM 作为节点列表遍历。
引用:
我的 wsimport 看起来像这样(域名已更改以保护无辜者):
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
不幸的是,一旦我在 ArcGIS GeoEvent Processor 中实现,在我的概念验证中工作的相同代码库(从 Web 服务获取结果)就会失败。我的项目是 ArcGIS GeoEvent Processor 将控制的 OSGI 包的一部分。 GeoEvent 处理器的 Apache Karaf 日志中显示了以下错误。
根据错误,我的理解是我在 wsimport 中进行绑定(bind)的方式存在问题,根据我上面列出的那些链接引用通用架构。看起来通用模式缺少一些作为 wsimport 生成的类存在的元素的定义。当我检查 wsimport 的输出时,这些类似乎已正确生成。
由于发布限制,我没有包括 WSDL,但如果需要,将在以后的回复中包括。
- Use a different, custom, xsd and xjb that spells out the expected schema for the webservice? I'm not sure exactly how that would be done.
- Use something other than wsimport to generate the webservice reference classes?
- Tweak something in the java environment for the ArcGIS GeoEvent Processor?
- Other options?
- Commit seppuku, then it's not my problem?
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
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;
}
}
最佳答案
这可能不是最好的答案,但这是我想出的。
包装我的 OSGI 项目的 ArcGIS GeoEvent Processor 似乎正在对我在我的应用程序中引用的 Web 服务进行一些额外的绑定(bind)/取消绑定(bind)。我用来使 .Net(DataSet 返回值)Web 服务在 Java 中运行的解决方法对于 GeoEvent 处理器的包装器来说是 Not Acceptable 。
最终,我所做的是创建一个辅助 .Net Web 服务,该服务采用 DataSet 值并将它们转换为 JSON,并返回 JSON 字符串。这消除了尝试从 Web 服务引用 DataSet 返回值时遇到的问题,现在我正在处理一个简单的 JSON 字符串。该 JSON 网络服务的 wsimport 运行顺利,无需解决方法。我将新导入的 Web 服务文件放入我的 java 项目中,现在没有问题了。
关于 C# DataSet 到 JSON 的引用:
关于java - ArcGIS GeoEvent 处理器 - javax.xml.ws.soap.SOAPFaultException : Unmarshalling Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26026043/
我有两个 shapefile。一种是有交通量数据的街道 map ,另一种是没有交通量的详细街道 map (精确 map )。 当我将带有交通量数据的街道 map 与没有交通量的详细街道 map 进行比
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 9年前关闭。 Improve this q
我注意到 Arc Gis map 渲染速度非常慢。当你缩放时,它呈现得很慢。当您平移时,它呈现缓慢。有没有人有任何关于使 map 呈现速度更快的建议,类似于谷歌地图和微软虚拟地球。 最佳答案 动态 m
我有几个带有大约 100-150 个特征的压缩 shapefile。我正在尝试将它们添加到 ArcGIS Online(每个 shapefile 接受少于 1000 个要素)但无法这样做,这表明压缩的
我正在尝试使用 react-arcgis npm 向 arcgis 添加一个图层, esriPromise(["esri/layers/TileLayer"]).then(([ TileLayer ]
我正在使用 javascript 在 web map 上显示要素图层的标签和要素。要素图层成功在 arcgis 工具中显示标签,而不是在 web map 上显示标签。 谁能帮我解决这个问题吗?我正在尝
我有从驻留在目录托管服务器中的 ArcGIS 生成的形状文件列表,请注意该服务器不是 ArcGIS 服务器并且形状文件未发布。 是否可以使用 ArcGIS JS API 将此形状文件作为图层(要素图层
去年的某个时候,当我们使用 ArcGIS 9.3 时,我在 Visual Studio 2008 中编写了一个 C# 程序来遍历文件夹中的所有 MXD 文件,检查所有图层源,如果错误或不正确则替换它们
是否可以指定 ESRI basemap 图库 (esri/dijit/BasemapGallery) 使用哪些 ArcGIS basemap ? 将 showArcGISBasemaps 设置为 tr
我是 Eclipse 的新手。我打算创建一个 ArcGIS Android 应用程序,但目前我正在逐步学习它。我有一个问题,“ArcGIS Runtime SDK for Android”和“ArcG
如何在启用混淆器的情况下使用 com.esri.arcgis.android:arcgis-android:10.2.6-2?我在努力 -keep class com.esri.** { *; } -
我遵循this guide将ArcGIS map 添加到我的应用程序中,但是没有用。我收到以下错误: Error: Failed to resolve: com.esri.arcgis.android
我正在尝试开发我自己的 map 服务,然后将我生成的图像显示到 ARCGIS map 查看器中......无论如何,我的 *.ashx 服务读取 ARCGIS Tile URL 看起来像“http:/
我在一个多边形 shapefile 中有一个不规则的三角形网格。这些单元格的主题是仅显示高于我的“兴趣”阈值水平的三角形。可见的相邻三角形被认为是真实的。需要删除空间隔离的三角形,因为它们可能是虚假的
我被困住了,试图使用 ArcGIS 绘制一个简单的圆形缓冲区。以下是我设置 basemap 的方法: dojo.require("esri.map"); dojo.require("esri.task
我正在使用 JavaScript 编写一个程序,该程序通过 ArcGIS REST API 连接到本地 ArcGIS 服务器并加载 map 。 获取服务的 URL 是 let xmlhttp = ne
我想开发 Arcgis for android 和 web 服务,但我不知道它有 API 吗?如果有,是否可以在我服务器上收集的经纬度 map 上进行标记(如谷歌地图 API)? 谢谢卡:)) 最佳答
我刚刚偶然发现了 Backgroundworker 对象,它似乎是我正在寻找的工具,可以让我的 GUI 在执行计算时做出响应。我正在为 ArcGIS 编写 IO 插件。 我正在 ArcGIS 之外进行
我正在尝试使用 ArcGIS JavaScript API在 Angular 应用程序中。如我所见,它使用 Dojo。所以,我正在尝试从 Angular 指令初始化 ArcGIS,如下所示: li
在 Microsoft SQL 中,我可以使用 GETDATE() 函数作为 DATETIME 字段的默认值。我希望能够对 ArcGIS 地理数据库中的日期字段执行相同类型的操作。这可能吗,还是我仅限
我是一名优秀的程序员,十分优秀!