在休息反应的空uri [英] Empty uri in rest response

查看:111
本文介绍了在休息反应的空uri的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为nexus oss开发一个插件。我的应用程序会创建一个休息调用响应(来自服务器的请求)。但是当服务器收到它时,它会抛出错误,如下所示

I am developing a plugin for nexus oss .My app creates a rest call response(to a request from server) . But when the server receives it , it throws error as follows

 javax.xml.bind.UnmarshalException:
 unexpected element (uri:"", local:"com.collabnet.teamforge.ia.types.GetConfigurationParametersResponse"). 
Expected elements are 
\lt{http://www.collab.net/teamforge/integratedapp}CreateProjectConfigurationRequest\gt,
\lt{http://www.collab.net/teamforge/integratedapp}GetConfigurationParametersRequest\gt,
\lt{http://www.collab.net/teamforge/integratedapp}GetConfigurationParametersResponse\gt,
\lt{http://www.collab.net/teamforge/integratedapp}GetPageComponentParametersRequest> 

我猜这个例外背后的原因是响应没有t匹配预期,因为uri(这只是我的猜测,如果它是错的请纠正我),即没有设置响应中的命名空间。

I guess the reason behind this exception is that the response doesn't match with the expected because the uri ( this is just my guess , if it's wrong please correct me),that is the namespace in response is not set .

snip of我的插件中的代码如下:

snip of the Code in my plugin is as follows


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "configurationParameter"
})
@XmlRootElement(name = "GetConfigurationParametersResponse", namespace = "http://www.collab.net/teamforge/integratedapp")
public class GetConfigurationParametersResponse
    extends BaseResponse
{

创建响应时为什么没有选择名称空间?

Why is name space not picked up while creating response ?

如果异常的真正原因不是空uri,即使纠正我。如果是这样,这个例外背后的真正原因是什么?
请帮忙。

Even correct me if the real reason for the exception is not the empty uri. If so what is the real reason behind this exception ? Please help .

推荐答案

根据错误消息,传递给JAXB的XML文档是。看起来好像这个XML是由JAXB以外的东西创建的(我怀疑是XStream)。

Based on the error message the XML document being passed to JAXB is. It appears as though this XML is being created by something other than JAXB (I suspect XStream).

<com.collabnet.teamforge.ia.types.GetConfigurationParametersResponse>
    ...
</com.collabnet.teamforge.ia.types.GetConfigurationParametersResponse>

您的JAXB映射期望XML文档如下:

Your JAXB mappings are expecting an XML document like the following:

<GetConfigurationParametersResponse xmlns="http://www.collab.net/teamforge/integratedapp">
    ...
</GetConfigurationParametersResponse>






如果您需要与以下XML进行交互:


If you need to interact with the following XML:

<com.collabnet.teamforge.ia.types.GetConfigurationParametersResponse>
    ...
</com.collabnet.teamforge.ia.types.GetConfigurationParametersResponse>

然后您可以将映射更改为:

Then you can change your mapping to be:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "configurationParameter"
})
@XmlRootElement(name = "com.collabnet.teamforge.ia.types.GetConfigurationParametersResponse")
public class GetConfigurationParametersResponse
    extends BaseResponse
{

这篇关于在休息反应的空uri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆