1. 程式人生 > >CXF中定義方法時返回值的類名跟方法名不能一樣

CXF中定義方法時返回值的類名跟方法名不能一樣

比如:

ListVirtualServerStatuses listVirtualServerStatuses(
            @WebParam(name = "req") ListVirtualServerStatusesRequest request);

其實上面的返回值還不是完全一樣的,首字母不同,但框架會統一把首字母變成小寫。

除此之外,返回值去掉結尾的"Response"後與方法名一致也不行:

ListNodeStatusesResponse listNodeStatuses(
            @WebParam(name = "req") ListNodeStatusesRequest request);

否則會報下面的錯誤:

Two classes have the same XML type name "{http://web.88.**.****.com/}listNodeStatusesResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
    this problem is related to the following location:
        at com.****.**.88.web.datamodel.response.ListNodeStatusesResponse
        at private com.****.**.88.web.datamodel.response.ListNodeStatusesResponse com.****.**.88.web.jaxws_asm.ListNodeStatusesResponse.listNodeStatusesRsp
        at com.****.**.88.web.jaxws_asm.ListNodeStatusesResponse
    this problem is related to the following location:
        at com.****.**.88.web.jaxws_asm.ListNodeStatusesResponse
Two classes have the same XML type name "{http://web.88.**.****.com/}listVirtualServerStatuses". Use @XmlType.name and @XmlType.namespace to assign different names to them.
    this problem is related to the following location:
        at com.****.**.88.web.jaxws_asm.ListVirtualServerStatuses
    this problem is related to the following location:
        at com.****.**.88.web.datamodel.response.ListVirtualServerStatuses
        at private com.****.**.88.web.datamodel.response.ListVirtualServerStatuses com.****.**.88.web.jaxws_asm.ListVirtualServerStatusesResponse.listVirtualServerStatusesRsp
        at com.****.**.88.web.jaxws_asm.ListVirtualServerStatusesResponse

應該是有方法可以設定的,只是沒找到。試過WebResult重置名字不行。錯誤資訊裡說的重置名稱空間名字,沒試過。