使用返回自定义类型的函数创建Web服务(JAX-WS) [英] Creating webservice (JAX-WS) with functions which return custom types

查看:53
本文介绍了使用返回自定义类型的函数创建Web服务(JAX-WS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了许多有关此问题的主题,但确实找到了一些相关的主题-但不幸的是,我无法真正理解如何解决问题.

I read many threads about this issue and i did find some that deal with it - but unfortunately I couldn't really understand how to solve my problem.

现在我正在创建WebService(使用Tomcat 7),并且我想共享接口. 我大约有8个相互关联的接口.例如:

Right now i'm creating WebService (using Tomcat 7), and I want to share interfaces. I have about 8 interfaces that relate to each other. for example:

@WebService
@SOAPBinding(style = Style.RPC)
interface A {
  public String method1();
}

@WebService
@SOAPBinding(style = Style.RPC)
interface B {
  public String method1();
  public A getA();
}

@WebService
@SOAPBinding(style = Style.RPC)
interface C {
  public A getA();
  public B getB();
}

问题是,在我创建WAR(用于接口C)文件并尝试在tomcat中部署Web服务后,我从tomcat收到了一个错误,看起来像这样:

The problem is that after i create the WAR (for interface C) file and i'm trying to deploy the webservice in tomcat, I get an error from tomcat which looks like that:

严重:WSSERVLET11:未能解析运行时描述符: com.sun.xml.ws.spi.db.DatabindingException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:1个计数 IllegalAnnotationExceptions com.mkyong.ws.ITest是一个接口,并且 JAXB无法处理接口.这个问题与 以下位置:com.mkyong.ws.ITest

SEVERE: WSSERVLET11: failed to parse runtime descriptor: com.sun.xml.ws.spi.db.DatabindingException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions com.mkyong.ws.ITest is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at com.mkyong.ws.ITest

com.sun.xml.ws.spi.db.DatabindingException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:1个计数 IllegalAnnotationExceptions com.mkyong.ws.ITest是一个接口,并且 JAXB无法处理接口.这个问题与 以下位置:com.mkyong.ws.ITest

com.sun.xml.ws.spi.db.DatabindingException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions com.mkyong.ws.ITest is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at com.mkyong.ws.ITest

有人知道如何解决吗? 谢谢.

Does anyone have an idea how to solve it? Thanks.

推荐答案

您不能使用JAX-WS返回接口类型.返回类型和参数必须是实际的类. RMI将为此提供支持的接口. JAX-WS没有.

You cannot return an interface type using JAX-WS. Return-types and parameters must be an actual class. RMI would support interfaces for that. JAX-WS doesn't.

这篇关于使用返回自定义类型的函数创建Web服务(JAX-WS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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