开发者

how to use jaxws for a class referencing an interface

开发者 https://www.devze.com 2023-01-08 14:51 出处:网络
I have a java class which I need to annotate up for a web service. Everything is set up and compiles etc, the wsdl is generated using the maven plugin for wsprovide... the problem I have is that the c

I have a java class which I need to annotate up for a web service. Everything is set up and compiles etc, the wsdl is generated using the maven plugin for wsprovide... the problem I have is that the class references an interface...

@WebService(name = "myWebService", targetNamespace = "......")
@SOAPBinding(style = SOAPBinding.Style.RPC)

public class MyClassImpl implements MyClass {
protected TheService m_theService;
/**
 * @return the theService
 */
public TheS开发者_如何学Cervice getTheService() {
    return m_theService;
}

TheService is an interface, and so I get a JAXB error... TheService is an interface, and JAXB can't handle interfaces. The getTheService method does not need to be exposed in the web service, but I can't see how to get around it. Can anyone explain what to do in this situation?


Solved! Found this shortly after posting this message and managed to resolve my issues :-)

https://jaxb.dev.java.net/guide/Mapping_interfaces.html


You can annotate any method that does not require to be exposed with:

@WebMethod(exclude = true)

This way wsgen will ignore the method when generating the JAX-WS artifacts.

0

精彩评论

暂无评论...
验证码 换一张
取 消