Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.7
-
WinXPsp3; Java-1.6.0_35; Tomcat-7.0.33
-
Unknown
Description
I am currently tweaking the DoubleItService tutorial described by Glen Mazza on his Weblog http://www.jroller.com/gmazza/entry/web_service_tutorial.
I created test clients using generated classes using wsdl2java. Everything works as intented.
Now I would like to expose the same service at two location.
Intended use is to filter access by requiring authentication at container level on some url-pattern like /underquota/doubleit, while /services/doubleit default remains accessible.
In WSDL, I added a second <wsdl:port> element
<wsdl:service name="DoubleItService"> <wsdl:port name="DoubleItPort" binding="tns:DoubleItBinding"> <soap:address location="http://localhost:8080/fr.efe4it.sample.webmodule.doubleitwsunderquota/services/doubleit"/> </wsdl:port> <wsdl:port name="DoubleItPortUnderquota" binding="tns:DoubleItBinding"> <soap:address location="http://localhost:8080/fr.efe4it.sample.webmodule.doubleitwsunderquota/underquota/doubleit"/> </wsdl:port> </wsdl:service>
In cxf-servlet.xml, I declared 2 endpoints
<jaxws:endpoint id="doubleit" implementor="fr.efe4it.sample.webmodule.doubleitwsunderquota.DoubleItPortTypeImpl" wsdlLocation="WEB-INF/wsdl/DoubleIt.wsdl" address="/doubleit" publishedEndpointUrl="http://localhost:8080/fr.efe4it.sample.webmodule.doubleitwsunderquota/services/doubleit" /> <jaxws:endpoint id="doubleitunderquota" implementor="fr.efe4it.sample.webmodule.doubleitwsunderquota.DoubleItUnderQuotaPortTypeImpl" wsdlLocation="WEB-INF/wsdl/DoubleIt.wsdl" address="/underquota/doubleit" publishedEndpointUrl="http://localhost:8080/fr.efe4it.sample.webmodule.doubleitwsunderquota/underquota/doubleit" />
The wsdl2java-generated classe DoubleItService now has 2 methods to retrieve each portType
@WebEndpoint(name = "DoubleItPort") public DoubleItPortType getDoubleItPort() { return super.getPort(DoubleItPort, DoubleItPortType.class); } @WebEndpoint(name = "DoubleItPortUnderquota") public DoubleItPortType getDoubleItPortUnderquota() { return super.getPort(DoubleItPortUnderquota, DoubleItPortType.class); }
I also have to implementors, attached to the corresponding portName. Below is the one attached to the portName I added to the WSDL.
@WebService(targetNamespace = "http://www.example.org/contract/DoubleIt", // portName = "DoubleItPortUnderquota", // serviceName = "DoubleItService", // endpointInterface = "org.example.contract.doubleit.DoubleItPortType") @Features(features = "org.apache.cxf.feature.LoggingFeature") public class DoubleItUnderQuotaPortTypeImpl implements DoubleItPortType { ...
When deploying the WAR under Tomcat, the call to http://localhost:8080/myapp/services/ display the 2 deployed services with correct URL.
PortType | Operation | Detail |
---|---|---|
DoubleItPortType | DoubleIt | Endpoint address: http://localhost:8080/fr.efe4it.sample.webmodule.doubleitwsunderquota/underquota/doubleit WSDL : {http://www.example.org/contract/DoubleIt} DoubleItService |
DoubleItPortType | DoubleIt | Endpoint address: http://localhost:8080/fr.efe4it.sample.webmodule.doubleitwsunderquota/services/doubleit WSDL : {http://www.example.org/contract/DoubleIt} DoubleItService |
Using SoapUI, I can succesfully run test queries against the 2 services.
However, when I request the WSDL in the browser, only one publishedEndpointUrl corresponds to what I setup in cxf-servlet.xml.
<wsdl:service name="DoubleItService"> <wsdl:port binding="tns:DoubleItBinding" name="DoubleItPortUnderquota"> <soap:address location="/underquota/doubleit"/> </wsdl:port> <wsdl:port binding="tns:DoubleItBinding" name="DoubleItPort"> <soap:address location="http://localhost:8080/fr.efe4it.sample.webmodule.doubleitwsunderquota/services/doubleit"/> </wsdl:port> </wsdl:service>
A the SOAP address, here /underquota/doubleit, retrieved from published WSDL is the URL used by my java test code to invoke service operations, I get the following error.
Caused by: javax.xml.ws.soap.SOAPFaultException: URI is not absolute at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) at $Proxy27.doubleIt(Unknown Source)