CXF jaxws endpoint relative publish address
The answer was, of course, simple (banging-head-on-desk simple, that is). In my cxf bean definitions, i was not importing the "cxf-servlet.xml" file as seen here http://cxf.apache.org/docs/servlet-transport.html. If this file is not imported, cxf assumes it should use the embedded jetty instance instead of my CXF servlet. My guess is the jetty instance only works with endpoints specifying an absolute publish address.
Jpnh
Updated on June 14, 2022Comments
-
Jpnh almost 2 years
I am having a lot of difficulty trying to use a relative publish address in my CXF web service endpoint configuration.
I have a simple Java-first JAX-WS project with the following configuration files:
applicationContent-cxf.xml:
<beans xmlns=...> ... <jaxws:endpoint id="helloWorldService" implementorClass="org.helloworld.ws.HelloWorldServiceImpl" implementor="#helloWorldServiceImpl" <!-- spring managed --> endpointName="sayHello" address="HelloWorldService"/> </beans>
web.xml:
<web-app> <context-param> <param-name>contextConfigLocation</param-name> <param-value> WEB-INF/applicationContext.xml WEB-INF/applicationContext-cxf.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <servlet> <servlet-name>HelloWorldServlet</servlet-name> <display-name>Hello World Servlet</display-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloWorldServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> </web-app>
According to http://cxf.apache.org/docs/servlet-transport.html, it seems i should be able to specify the publish address of
HelloWorldService
and the URL of the service will resolve to (e.g.) http://localhost:8080/services/HelloWorldService. But when I try to go to http://localhost:8080/services/HelloWorldService?wsdl I get a 404. If i change the publish address in my jaxws endpoint to the absolute URLhttp://localhost:8080/services/HelloWorldService
I am able to access the wsdl.I want to specify a relative endpoint address if possible. I am new to using CXF (and writing web services), so any help is much appreciated!
UPDATE 1:
Note that I am deploying my web service to Tomcat 7. I don't know what is logging it, but one of the lines in my start up log states
Setting the server's publish address to be HelloWorldService
. If anyone needs more info to help me please let me know.UPDATE 2:
It appears that CXF detects whether a CXFServlet is "being used" and uses an embedded jetty instance if it is not. http://cxf.apache.org/docs/xfire-migration-guide.html#XFireMigrationGuide-HTTPandServletSetup. So, for some reason CXF is using the embedded jetty instance instead of my servlet. However, I don't know what further configuration I need besides the HelloWorldServlet in my web.xml, and the CXF documentation doesn't help me further.
-
Jpnh over 12 yearsThanks for pointing that out. I did try /HelloWorldService, but it still seems to not work.
-
Ganesh over 12 yearsPlease add serviceName="service'sName" in your endpoint and try
-
Jpnh over 12 yearsThanks. I didn't mention that I have the service name configured in the JaxWS annotation on my web service implementation.
-
user1339772 almost 9 yearsAppreciate you posting the solution, I had exactly the same issue and almost banged my head on desk :-)
-
vikingsteve almost 6 years
serviceName=HelloWorldService
didnt work for me, besides it requires a namespac ein curly brackets beforeHelloWorldService