In the default case all the class definitions under a web service are generated in the namespace of the web service. For instance let the web service endpoint
SampleWS
class is under package org.first
and let this web service returns a org.second.SampleType
. When the web service is deployed and stubs are generated in the client side, SampleType
is also under org.first
package. When org.second.SampleType
is a shared class amongst multiple web services, this leads to problem, since there will be multiple SampleType
classes under multiple packages.Solution:
The specified problem could be solved at the client side by providing wsimport with a binding file specifying actual namespaces for all shared classes. https://jax-ws.dev.java.net/guide/Compiling_multiple_WSDLs_that_share_a_common_schema.html
However, it is also possible to solve the situation at server side by forcing to put all shared classes in their actual packages by adding namespace definition via
XmlType
annotation as follows:
import javax.xml.bind.annotation.XmlType;
@XmlType(namespace="http://org.example.hilal")
public class Calc {
private int result;
public int getResult() {
return result;
}
public void setResult(int result) {
this.result = result;
}
}
i prefer the second way, solving problems at server side always seems better to me :)
Hiç yorum yok:
Yorum Gönder