Java 为什么使用Webservice';s WSDL未使用@WebFault命名空间?

Java 为什么使用Webservice';s WSDL未使用@WebFault命名空间?,java,web-services,wsdl,jax-ws,Java,Web Services,Wsdl,Jax Ws,在我的场景中,我有两个Web服务: package com.ws.mywebservice1; ... @Webservice(serviceName = "MyWebservice1", targetNamespace="http://some.custom.namespace1/MyWebservice1") @Stateless @LocalBean @HandleChain(file = "handlers.xml") public class MyWebservice1 extends

在我的场景中,我有两个Web服务:

package com.ws.mywebservice1;
...
@Webservice(serviceName = "MyWebservice1", targetNamespace="http://some.custom.namespace1/MyWebservice1")
@Stateless
@LocalBean
@HandleChain(file = "handlers.xml")
public class MyWebservice1 extends AbstractWebService {
  @WebMethod
  @WebResult(name = "outMyResult1", targetNamespace="http://some.custom.namespace1/MyWebservice1")
  public OutMyResult1 myMethod() throws ApplicationFault {
  }
}

package com.ws.mywebservice2;
...
@Webservice(serviceName = "MyWebservice2", targetNamespace="http://some.custom.namespace2/MyWebservice2")
@Stateless
@LocalBean
@HandleChain(file = "handlers.xml")
public class MyWebservice2 extends AbstractWebService {
  @WebMethod
  @WebResult(name = "outMyResult2", targetNamespace="http://some.custom.namespace2/MyWebservice2")
  public OutMyResult2 myMethod() throws ApplicationFault {
  }
}
两者共享相同的
ApplicationFault
异常:

package com.ws.exceptions;
...
@WebFault(name="ApplicationFault", targetNamespace="http://ws.exceptions.com/ApplicationFault")
@ApplicationException(rollback = true)
@XmlType(name="ApplicationFault", namespace="http://ws.exceptions.com/ApplicationFault")
public class ApplicationFault extends Exception {
  private Status status;
  ...
}
MyWebservice2
生成的WSDL使用
MyWebservice1
的命名空间来声明
ApplicationFault

<!-- WSDL -->
<xsd:import namespace="http://some.custom.namespace1/MyWebservice1" schemaLocation="http://localhost:7001/my-app/1.0.0-SNAPSHOT/MyWebservice2?xsd=2"/>

<!-- XSD -->
<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.8-b13937 svn-revision#13942. -->
<xsd:schema xmlns:ns1="http://ws.exceptions.com/ApplicationFault" xmlns:ns0="http://some.custom.namespace1/MyWebservice1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://some.custom.namespace1/MyWebservice1"> namespace="http://ws.exceptions.com/ApplicationFault"/>
  <xsd:complexType name="ApplicationFault">
    <xsd:sequence>
      <xsd:element name="message" type="xsd:string" minOccurs="0"/>
      <xsd:element name="status" type="ns1:Status" minOccurs="0"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

名称空间=”http://ws.exceptions.com/ApplicationFault"/>

为什么生成的WSDL使用了错误的命名空间,而忽略了@WebFault targetNamespace?

在@WebFault注释中声明的命名空间,(targetNamespace=“)与在xml中声明的命名空间相同(xmlns:ns1=“”和namespace=“)。我看不出有什么问题。试着从
ApplicationFault
类中删除
@XmlType
。这不是必需的,我认为它与
@WebFault
@pred-fragmaric冲突。这是一次解决问题的尝试,我最初的测试没有
@XmlType
@SérgioMichels。你找到解决方案了吗?@Lia我使用了t他以合同为先。