Don't forget to actually map *.wsdl requests to the DispatcherServlet in your web.xmlOriginally Posted by res1st
Don't forget to actually map *.wsdl requests to the DispatcherServlet in your web.xmlOriginally Posted by res1st
Yeah, it doesn't include the context, only the server location. The problem is that I don't know which part of the original location represents the context.Originally Posted by mskendrick
Suppose we have the following original location in the WSDL:
The '/services' part can actually be two things: it can be the context path, or it can be the servlet path when the app is deployed in the ROOT context (i.e. a mapping of /service/* in the web.xml). There's no way to tell. If it's the context path, it needs to rewritten with the current context path. If it's the servlet path, it needs to be retained. Do you see the problem?Code:http://localhost:8080/services/MyService
So what I originally did was to depend on relative paths in the original location field. That way, I can always add the server information and context path, and it's done. So the original WSDL has to contain a location such as:
And I can just prepend the server + context path to it. However, this means that the original WSDL can only be used within a Spring-WS context, and I didn't like that too much. So in the end I opted for the solution we have now.Code:/services/MyService
I could add the 'relative path' solution, though. Basically, I only have to check whether the location starts with a slash, and then do the magic. Would that solve your problem?
I've already done that, i changed the mapping to
<servlet-mapping>
<servlet-name>eimws</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
My log is contains the following lines(please look at the bold line):
Any idea why he doesn't transform it correctly?Code:521697 [http-8080-Processor24] DEBUG handler.SimpleUrlHandlerMapping - Looking up handler for [/eim.wsdl] 521697 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - Testing handler adapter [org.springframework.ws.transport.http.MessageEndpointHandlerAdapter@f1a58d] 521697 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - Testing handler adapter [org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter@abe515] 521697 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - Last-Modified value for [/eim/eim.wsdl] is [-1] 521697 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - DispatcherServlet with name 'eimws' received request for [/eim/eim.wsdl] 521713 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - Bound request context to thread: org.apache.catalina.connector.RequestFacade@1ddcb 521713 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - Testing handler adapter [org.springframework.ws.transport.http.MessageEndpointHandlerAdapter@f1a58d] 521713 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - Testing handler adapter [org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter@abe515] 521760 [http-8080-Processor24] DEBUG http.WsdlDefinitionHandlerAdapter - Transforming [http://localhost:8080/eim/services] to [http://localhost:8080/eim/services] 521760 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'eimws': assuming HandlerAdapter completed request handling 521760 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@1ddcb 521760 [http-8080-Processor24] DEBUG servlet.DispatcherServlet - Successfully completed request 521838 [http-8080-Processor24] DEBUG support.XmlWebApplicationContext - Publishing event in context [WebApplicationContext for namespace 'eimws-servlet']: ServletRequestHandledEvent: url=[/eim/eim.wsdl]; client=[127.0.0.1]; method=[GET]; servlet=[eimws]; session=[null]; user=[null]; time=[63ms]; status=[OK] 521838 [http-8080-Processor24] DEBUG support.XmlWebApplicationContext - Publishing event in context [Root WebApplicationContext]: ServletRequestHandledEvent: url=[/eim/eim.wsdl]; client=[127.0.0.1]; method=[GET]; servlet=[eimws]; session=[null]; user=[null]; time=[63ms]; status=[OK]
Ingo
See, it works!
Since a server can be bound to many addresses and names, it's impossible to know which one was used to request the wsdl. Therefore, I use the incoming HttpServletRequest to figure it out.
I'd say you probably requested http://localhost:8080/eim/eim.wsdl. In order for this to work, you'd have request the WSDL by the non-local IP address, i.e. http://192.168.x.x:8080/eim/eim.wsdl.
If that doesn't work, then we have a bug, and I need some more information (i.e. the web container you use).
Damn, you are right. I request the wsdl from "http://localhost:8080/eim/eim.wsdl". It's working fine now.
Thank you,
Ingo
That might be better. I also wonder if there is any way to completely generate the URL (i.e. not use the original source) using the HttpServletRequest and the information in web.xml. Can that be retrieved using the one of the other Servlet APIs?Originally Posted by poutsma
Currently my web.xml contains the following:
Shannon KendrickCode:<servlet-mapping> <servlet-name>pcc-ws</servlet-name> <url-pattern>/services</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>pcc-ws</servlet-name> <url-pattern>/wsdl/PccService.wsdl</url-pattern> </servlet-mapping> <mime-mapping> <extension>xsd</extension> <mime-type>text/xml</mime-type> </mime-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list>
I don't think completely generating the URL is possible. The problem is that with both the web.xml and the *-servlet.xml, you're extremely flexible with regard to were handlers are bound. Basically, you can determine which handler an incoming URL handles, but you cannot get a list of all handlers and the URLs they're mapped on. This mostly has to do with the wildcards in both files (e.g. /services/*). So, there's basically now way to determine where the Web services are bound.
I will implement the relative location fix soon this evening.
It's done. Try a nightly build tomorrow. You can now use both absolute paths and relative paths in the location field. From the javadoc:
If the property transformLocations is set to true, this adapter will change location attributes in the WSDL definition to reflect the URL of the incoming request. If the location
field in the original WSDL is an absolute path, the scheme, hostname, and port will be changed. If the location is a relative path, the scheme, hostname, port, and context path will be prepended. This behavior can be customized by overriding the transformLocation() method.
For instance, if the location attribute defined in the WSDL is http://localhost:8080/context/services/myService, and the request URI for the WSDL is http://example.com/context/myService.wsdl, the location will be changed to http://example.com/context/services/myService.
If the location attribute defined in the WSDL is /services/myService, and the request URI for the WSDL is http://example.com:8080/context/myService.wsdl, the location will be changed to http://example.com:8080/context/services/myService.
Hi,
could you please post an extract of your Spring configuration, showing declarations of WsdlDefinitionHandlerAdapter, SimpleWsdl11Definition and their mapping ?
Thanks,
Damien.
Yes i can.
Cheers,
Ingo
Code:<bean id="wsdlDefinitionHandlerAdapter" class="org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter"> <description> ... </description> <property name="transformLocations" value="true"/> </bean> <bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <description> ... </description> <property name="defaultHandler" ref="messageDispatcher"/> <property name="mappings"> <props> <prop key="/services/*">messageDispatcher</prop> <prop key="/eim.wsdl">eimWsdl</prop> </props> </property> </bean> <bean id="eimWsdl" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition"> <description> ... </description> <property name="wsdl" value="/eim.wsdl"/> </bean>