简体   繁体   English

避免在XML响应(标记)中使用名称空间

[英]Avoid namespace in the XML response (tags)

We are pulling data from Cisco ips (SDEE server) using Java. 我们正在使用Java从Cisco ips(SDEE服务器)中提取数据。 Its a normal web request and we are using HttpsURLConnection. 它是正常的网络请求,我们正在使用HttpsURLConnection。 The response is in the form of an XML. 响应采用XML形式。

We have a UI (web app) that can trigger the job to pull the data; 我们有一个UI(Web应用程序),可以触发作业以提取数据。 we also have a standalone utility that can also trigger the job to pull the data. 我们还有一个独立的实用程序,它也可以触发作业以提取数据。 So, the code to retrieve data from the sdee server is same in both the cases. 因此,在两种情况下,从sdee服务器检索数据的代码都是相同的。 Using Quartz to schedule a job, though this info is irrelevant here. 使用Quartz安排工作,尽管此信息与此处无关。

Now the problem - when the job is triggered from the UI, we get expected xml, no issues. 现在的问题-当从UI触发作业时,我们得到了预期的xml,没有问题。 But when the job is triggered using the utility, we get the same xml but with namespace within its tags. 但是,当使用该实用程序触发作业时,我们将获得相同的xml,但其标记中包含名称空间。

<['http://example.org/2003/08/sdee']:sd:evIdsAlert eventId='123' vendor='Cisco' severity='low'><['http://example.org/2003/08/sdee']:sd:originator>

[' http://example.org/2003/08/sdee '] - this is something extra we are getting. [' http://example.org/2003/08/sdee']-这是我们得到的额外东西。 We don't want this in the XML. 我们不想在XML中使用它。

As the code is same, I suspect that may be some environment settings is affecting the response, but I don't know what. 由于代码相同,我怀疑可能是某些环境设置正在影响响应,但是我不知道是什么。

Some part of the code (that we are using), just for reference: 代码的一部分(我们正在使用),仅供参考:

// get the connection
connection = (HttpsURLConnection) url.openConnection();
// get the reader
new BufferedReader(new InputStreamReader(connection.getInputStream()));
// read response line by line and dump it to the file

The code is pretty simple - a standard one to pull the data using HTTP(s). 代码非常简单-一种使用HTTP提取数据的标准代码。

The issue was due to different xml parsers. 该问题是由于不同的xml解析器引起的。 Its fixed now. 现在修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM