简体   繁体   English

与JAX-WS + JAXB作为返回类型的接口

[英]Interfaces as return types with JAX-WS + JAXB

I think I'm just missing something simple here but here is what I am working from... 我想我只是在这里遗漏了一些简单的东西,但这就是我正在做的事情...

@WebService
public interface MyService {
     public AnInterface doStuff();
}

Here is some of what I have tried. 这是我尝试过的一些方法。 All with CXF 2.5.2 + Spring on Weblogic 10.3.4... 在Weblogic 10.3.4上全部使用CXF 2.5.2 + Spring ...

  1. Use @XmlSeeAlso on the MyService interface and AnInterface to point JAXB to the AnInterfaceImpl class. 在MyService接口和AnInterface上使用@XmlSeeAlso,将JAXB指向AnInterfaceImpl类。 This still resulted in the infamous JAXB can't handle interfaces exception. 这仍然导致臭名昭著的JAXB无法处理接口异常。
  2. Used @XmlElementReference on the method but this had the same effect as item (1) and seems to be for property serialization 在方法上使用@XmlElementReference,但这与项目(1)具有相同的效果,并且似乎是用于属性序列化的
  3. Use @ResponseWrapper on the method but it's my understanding that CXF does this automatically (Bare vs Wrapped) but I may be wrong. 在方法上使用@ResponseWrapper,但据我了解,CXF会自动执行此操作(裸机与包装机),但我可能是错的。 While this allowed WSDL to be created marshaling at runtime always returned a default object. 尽管这允许在运行时创建WSDL封送处理,但始终会返回一个默认对象。 Perhaps I misunderstand how this annotation should work. 也许我误解了此批注应如何工作。

I'm guessing there is some way to easily annotate that AnInterface should be exposed via 我猜想有某种方法可以轻松地注释AnInterface应该通过以下方式公开
AnInterfaceImpl from the MyService class pretty easily but I'm missing some crucial and simple step. MyService类中的AnInterfaceImpl非常容易,但是我缺少一些关键而简单的步骤。

The trick appears to be the use of @XmlJavaTypeAdapter on the target interfaces as described here . 诀窍似乎是使用@XmlJavaTypeAdapter所描述的目标接口在这里 It is not obvious to me why this works where other methods seem to fail. 对于我来说,这还不明显,为什么在其他方法似乎失败的情况下,这种方法仍然有效。

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

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