问题
In my scenario I have two Webservices:
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 {
}
}
Both share the same ApplicationFault
exception:
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;
...
}
And the generated WSDL for the MyWebservice2
is using the namespace of MyWebservice1
to declare the 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>
Why the generated WSDL is using the wrong namespace, ignoring the @WebFault targetNamespace?
来源:https://stackoverflow.com/questions/27964771/why-webservices-wsdl-is-not-using-the-webfault-namespace