java—为什么webservice的wsdl不使用@webfault命名空间?

mum43rcc  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(175)

在我的场景中,我有两个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 正在使用的命名空间 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>

为什么生成的wsdl使用了错误的名称空间,而忽略了@webfault targetnamespace?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题