【问题标题】:How can I set path to myException.java in client?, when create client from WSDL从 WSDL 创建客户端时,如何在客户端中设置 myException.java 的路径?
【发布时间】:2014-02-03 13:28:05
【问题描述】:

我有服务器,服务器方法抛出我的异常 - MBFault:

import javax.xml.ws.WebFault;

@WebFault(name = "fault.MBFault", 
        targetNamespace = "fault")
public class MBFault extends Exception {

    private String detail;

    public MBFault(String message, String detail) {
        super(message);
        this.detail = detail;
    }

    public MBFault(String message, String detail, Throwable cause) {
        super(message, cause);
        this.detail = detail;
    }

    public String getDetail() {
        return detail;
    }
}

我创建基于服务器的 WSDL,从 WSDL 我创建客户端 (wsimport -s myPackage ...wsdl)。 如何在客户端设置 MBFault 的路径?如果我愿意,MBFault.java 保存在包“故障”中,所有其他保存在客户端的包“otherClasses”中。请帮帮我。

【问题讨论】:

  • 你试过简单地给MBFault一个合适的java风格的包吗?
  • 什么是“java风格的包”?
  • 我的意思是把MBFault放在一个包里,即package you.foo.exception。这将是工件生成时的默认命名空间
  • MBFault 有包(包example.fault),但是在@WebService 的文件夹中创建了文件MBFault,可能这个问题可以用jab:binding, jax-ws:binding...解决...

标签: java wsdl jax-ws fault


【解决方案1】:

您可能需要进行以下更改:

@WebFault(
        name            = "MBFault", 
        targetNamespace = "http://fault"
)

Java API for XML Web Services Annotations 中查看更多信息。

【讨论】:

  • 当设置 targetNamespace = "http://fault" 时,使用 ObjectFactory 类创建文件夹 "fault",但我需要在文件夹 "fault" 中创建类 MBFault...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-05-27
  • 2012-02-07
  • 2012-04-18
  • 1970-01-01
  • 1970-01-01
  • 2019-04-30
  • 1970-01-01
相关资源
最近更新 更多