Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.2.6
-
None
Description
Problem is that "remote procedure call" by couple JaxWsProxyFactoryBean and JaxWsServerFactoryBean doesnt work.
Methods from client (remote) interface return null values.
Reason: server leaks namespace from service implementation (not only interface) .. so client can read data and return null
Server code:
JaxWsServerFactoryBean serverFactoryBean = new JaxWsServerFactoryBean(); serverFactoryBean.setServiceClass(AopUtils.getTargetClass(implementor)); //WSImpl.class serverFactoryBean.setServiceBean(implementor); //WSImpl.class serverFactoryBean.setDataBinding(new AegisDatabinding()); serverFactoryBean.setAddress(url); serverFactoryBean.setBus(cxfServlet.getBus()); serverFactoryBean.create();
Client code:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(resultInterfaceClass); //WS.class factory.setAddress(asURL); factory.setDataBinding(new AegisDatabinding()); Object remoteInterfaceImpl = factory.create();
Interface:
@WebService(name="datove_zdroje", targetNamespace="http://v1_0_0.ws.doc.daisy.marbes.cz") public interface WS { List<String> getCodes(@WebParam(name = "baseCode") String baseCode); }
Implementation:
@WebService(serviceName = "datove_zdroje", endpointInterface = "cz.marbes.daisy.modules.doc.ws.v1_0_0.WS") public class WSImpl implements WS { @Override public List<String> getCodes(final String baseCode) { return new ArrayList<String>(); } }
In this configuration client always receive "NULL" from method call !
Problem is that server include in WSDL(and XML communication) namespace from service implementation (WSImpl.java) - not only from (client) interface (WS.java).
In this particular case servers "targetNamespace" is empty. So server made it up from class and package name. But client has only information from interface.
Client anticipate that "ServiceNamespace" is equals with "targetNamespace" from interface (WS.java) WebService annotation.
Working WSImpl.java:
@WebService(serviceName = "datove_zdroje", endpointInterface = "cz.marbes.daisy.modules.doc.ws.v1_0_0.WS", *targetNamespace="http://v1_0_0.ws.doc.daisy.marbes.cz"* //must be same as WS.java targetNamespace ) public class WSImpl implements WS {
NON-Working WSImpl.java:
@WebService(serviceName = "datove_zdroje", endpointInterface = "cz.marbes.daisy.modules.doc.ws.v1_0_0.WS", *targetNamespace=""* //empty or other than WS.java targetNamespace ) public class WSImpl implements WS {
We need clarify real meaning of @WebService(targetNamespace="") on service implementation.