Spring Web Services
  1. Spring Web Services
  2. SWS-605

Dynamic WSDL Generation and specifying SOAP Headers

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 1.5.9
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      The WSDL generation on the fly based on convetions and XML schema is a great feature. I'm looking for customization which allows me to specify SOAP headers in the binding part of WSDL. When the headers definition is missing Web Service client is not aware of it. Please refer to the following example:
      http://www.w3.org/TR/wsdl#_soap-e and to the referenced spring forum.

        Activity

        Hide
        Arjen Poutsma added a comment -

        By default, Spring-WS uses the DefaultWsdl11Definition to create WSDLs. In effect, this is just a ProviderBasedWsdl4jDefinition with default providers set.

        To customize this, you can wire up your own ProviderBasedWsdl4jDefinition and simply plugin your own providers, possibly subclassing some of the existing ones. See the org.springframework.ws.wsdl.wsdl11.provider package for more details.

        Show
        Arjen Poutsma added a comment - By default, Spring-WS uses the DefaultWsdl11Definition to create WSDLs. In effect, this is just a ProviderBasedWsdl4jDefinition with default providers set. To customize this, you can wire up your own ProviderBasedWsdl4jDefinition and simply plugin your own providers, possibly subclassing some of the existing ones. See the org.springframework.ws.wsdl.wsdl11.provider package for more details.
        Hide
        Marcin Kuthan added a comment -

        Thank you Arjen for the comment.

        Unfortunately it is not so easy to modify WSDL generator as you mentioned. Regardless of Spring classes you need to know javax.wsdl API and WSDL spec. Subclassing the spring classes also doesn't seem to be the best way, I rather expect well defined place to inject header generator/provider. I'm wondering how unusual is a case with a custom SOAP header definition, and why it has not been addressed already.

        At this moment I manage WSDL by hand, but I will look forward for any tutorial or example how to configure WSDL providers to generate custom soap headers.

        Better support for custom headers in WsTemplate also will be appreciated. Now doWithMessage method must be overridden, and the header must be marshaled and put into message manually. I wish to give body and header objects as parameters into wsTemplate method.

        Show
        Marcin Kuthan added a comment - Thank you Arjen for the comment. Unfortunately it is not so easy to modify WSDL generator as you mentioned. Regardless of Spring classes you need to know javax.wsdl API and WSDL spec. Subclassing the spring classes also doesn't seem to be the best way, I rather expect well defined place to inject header generator/provider. I'm wondering how unusual is a case with a custom SOAP header definition, and why it has not been addressed already. At this moment I manage WSDL by hand, but I will look forward for any tutorial or example how to configure WSDL providers to generate custom soap headers. Better support for custom headers in WsTemplate also will be appreciated. Now doWithMessage method must be overridden, and the header must be marshaled and put into message manually. I wish to give body and header objects as parameters into wsTemplate method.
        Hide
        Gurpreet added a comment -

        I would second Marcin on that. Implementing my own custom header will require me deep diving into complex specs, which I won't prefer. If an out of the box usage can be provided, where developers can specify Soap header definition (say in the configuration file), probably would be a cleaner/better approach.

        Again like Marcin, right now I am handling my wsdls myself. But tomorrow if I consume some external systems' wsdl, and that interface expects me to send a custom soap header, I will have to do a lot of homework.

        Moreover, there is not much info available online on this particular part, which makes it more difficult to achieve.

        If this can be supported in the forthcoming releases, would be pretty handy Arjen!
        Thanks.

        Show
        Gurpreet added a comment - I would second Marcin on that. Implementing my own custom header will require me deep diving into complex specs, which I won't prefer. If an out of the box usage can be provided, where developers can specify Soap header definition (say in the configuration file), probably would be a cleaner/better approach. Again like Marcin, right now I am handling my wsdls myself. But tomorrow if I consume some external systems' wsdl, and that interface expects me to send a custom soap header, I will have to do a lot of homework. Moreover, there is not much info available online on this particular part, which makes it more difficult to achieve. If this can be supported in the forthcoming releases, would be pretty handy Arjen! Thanks.
        Hide
        Paul Hilliar added a comment -

        Did anyone ever find an example of how to do this? The dynamic WSDL generation is great but it would be really good to have a worked example of how to get it to specify some SOAP headers.

        Or even something just a little more verbose than 'wire up your own ProviderBasedWsdl4jDefinition and simply plugin your own providers'? I don't mind subclassing Spring classes to achieve this but a little more of a head start would be really appreciated. I am assuming I need to be creating a custom MessagesProvider? But that is just a guess.

        Thanks

        Show
        Paul Hilliar added a comment - Did anyone ever find an example of how to do this? The dynamic WSDL generation is great but it would be really good to have a worked example of how to get it to specify some SOAP headers. Or even something just a little more verbose than 'wire up your own ProviderBasedWsdl4jDefinition and simply plugin your own providers'? I don't mind subclassing Spring classes to achieve this but a little more of a head start would be really appreciated. I am assuming I need to be creating a custom MessagesProvider? But that is just a guess. Thanks
        Hide
        Marcin Kuthan added a comment -

        From my experience, the WSDL generation should be used only during prototyping. When the prototype is stable, save a static copy of generated WSDL and modify as you want.

        Show
        Marcin Kuthan added a comment - From my experience, the WSDL generation should be used only during prototyping. When the prototype is stable, save a static copy of generated WSDL and modify as you want.
        Hide
        Paul Hilliar added a comment -

        Arjen - any chance of a few pointers? it doesn't have to be a worked example but a bit more to go on would be great.

        I did manage to manually modify the WSDL in order to add headers, but it is an incredibly involved manual process (WSDL is 130K and there are about 20 operations that need the same header, X-API-KEY) and my manual modification process is bound to go wrong at some point through human error!

        Show
        Paul Hilliar added a comment - Arjen - any chance of a few pointers? it doesn't have to be a worked example but a bit more to go on would be great. I did manage to manually modify the WSDL in order to add headers, but it is an incredibly involved manual process (WSDL is 130K and there are about 20 operations that need the same header, X-API-KEY) and my manual modification process is bound to go wrong at some point through human error!
        Hide
        Arjen Poutsma added a comment -

        I've attached a simple Maven project to show you how to add SOAP headers to the wsdl. Hope this helps.

        Show
        Arjen Poutsma added a comment - I've attached a simple Maven project to show you how to add SOAP headers to the wsdl. Hope this helps.
        Hide
        Paul Hilliar added a comment -

        Hey Arjen - I ran that sample and it's great. I don't think I would have ever got to that solution on my own!

        Really appreciate your time on this and the speedy turnaround.

        Cheers. Paul.

        Show
        Paul Hilliar added a comment - Hey Arjen - I ran that sample and it's great. I don't think I would have ever got to that solution on my own! Really appreciate your time on this and the speedy turnaround. Cheers. Paul.
        Hide
        Arjen Poutsma added a comment -

        Closing old issues

        Show
        Arjen Poutsma added a comment - Closing old issues

          People

          • Assignee:
            Arjen Poutsma
            Reporter:
            Marcin Kuthan
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: