Announcement Announcement Module
Collapse
No announcement yet.
Separate WSDLs or a single WSDL for CRUD functions? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Separate WSDLs or a single WSDL for CRUD functions?

    I have an architectural question that I would like to ask. First some background: I need to create some webservices that provide basic CRUD functions and are backed by a database. My question concerns the WSDL and whether or not is it best to have a separate WSDL for each of the functions (e.g. create, read, update, delete), or should they all be inside a single WSDL? What are the best practices?

    Shannon Kendrick

  • #2
    Well, it depends on whether you want the ability to change them independently. If so, it makes sense to separate them. But I think that's most often not the case.

    Comment


    • #3
      But it's useful to seperate the xml schema and the wsdl file.
      I also have my fault related things (fault types and constants) in a seperate file.

      I have an other question regarding the wsdl.
      I've wrote the wsdl and manually added the URL of the web service. But if i have an application-server which runs on different machines, so the URL is different (of course ).
      Do i have to write my own tool which automatically modifies the WSDL file or has someone before wrote it? Or is a variable available which will be replaced automatically by the server-URL?

      Cheers,

      Ingo

      Comment


      • #4
        Originally posted by res1st
        Do i have to write my own tool which automatically modifies the WSDL file or has someone before wrote it? Or is a variable available which will be replaced automatically by the server-URL?
        For now, you have to write your own solution. However, there seems to be much request for this feature, so I think i'll add it somehow before I do a M2.

        Comment


        • #5
          Thank you Arjen.

          Comment


          • #6
            I've create a feature issue here: http://opensource.atlassian.com/proj.../browse/SWS-47. Check it out.

            Comment


            • #7
              And the issue is fixed. Please read the way it works, or check out the echo sample, which uses this functionality.

              Comment


              • #8
                Very good Arjen, it's looking nice.
                As soons as M2 is released, i'll try it. At the moment, i have to fight with JAXB2 and other client WS technologies.

                Ingo

                Comment


                • #9
                  Arjen,
                  I tried implementing the WSDL dynamic-location solution using WsdlDefinitionHandlerAdapter, and I ran into a slight problem. Apparently the rewrite of the location URL does not include the web context from the request - only the scheme, host, and port is modified. So if I deploy my WAR file to another web context in my app server, then the new context is not picked up.

                  WSDL file
                  Code:
                  <soap:address location="http://localhost:8080/pcc-web/services" />
                  Actual rewritten WSDL
                  Code:
                  <soap:address location="https://www.myhost.com/pcc-web/services" />
                  Expected rewritten WSDL
                  Code:
                  <soap:address location="https://www.myhost.com/production/services" />
                  I think that the web context should be updated in addition to the scheme, host, and port. What do you think?

                  Shannon Kendrick

                  Comment


                  • #10
                    I think you are right, Shannon. It would be nice if the application context can also be changed.

                    But how does it work? I did it like in the echo example and i get this log message:
                    Code:
                    DEBUG handler.SimpleUrlHandlerMapping  - Mapped URL path [/eim.wsdl] onto handler [org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition@26fb32]
                    But if i open my browser and request
                    Code:
                    http://localhost:8080/eim/eim.wsdl
                    , i get my unchanged wsdl file.

                    Cheers,

                    Ingo
                    Last edited by res1st; Jul 27th, 2006, 05:03 AM.

                    Comment


                    • #11
                      Originally posted by res1st
                      IBut how does it work? I did it like in the echo example and i get this log message
                      Don't forget to actually map *.wsdl requests to the DispatcherServlet in your web.xml

                      Comment


                      • #12
                        Originally posted by mskendrick
                        I tried implementing the WSDL dynamic-location solution using WsdlDefinitionHandlerAdapter, and I ran into a slight problem. Apparently the rewrite of the location URL does not include the web context from the request - only the scheme, host, and port is modified. So if I deploy my WAR file to another web context in my app server, then the new context is not picked up.
                        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.
                        Suppose we have the following original location in the WSDL:
                        Code:
                        http://localhost:8080/services/MyService
                        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?

                        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:
                        Code:
                        /services/MyService
                        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.

                        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?

                        Comment


                        • #13
                          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):
                          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]
                          Any idea why he doesn't transform it correctly?

                          Ingo

                          Comment


                          • #14
                            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).

                            Comment


                            • #15
                              Damn, you are right. I request the wsdl from "http://localhost:8080/eim/eim.wsdl". It's working fine now.

                              Thank you,

                              Ingo

                              Comment

                              Working...
                              X