Announcement Announcement Module
No announcement yet.
Webservice-Client: Common approach with Spring WS, JAXB and just one WSDL file? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Webservice-Client: Common approach with Spring WS, JAXB and just one WSDL file?


    I would like to use Spring WS to build a Webservice-Client with JAXB for marshalling and unmarshalling the Java classes.

    But what I have is just one WSDL file. When I understand it right, I can generate Java classes with JAXB (xbj.exe), which then can be used by me with Spring WS to retrieve the Webservice-Data and send an answer.

    But JAXB can only generate Java classes from xsd-schema files. Must I now manually copy those xsd-definitions from within the WSDL file to generate those classes via JAXB? (in my case the WSDL file contains 4 XSD definitions).

    Or is there a way to just convert the whole WSDL to Java classes which I can use with Spring WS (I know there is the "wsimport", but it is part of JAX-WS and I think I can't use it in this scenario, right?).

    So what is the common approach with Spring WS / JAXB / one WSDL file?

    I really would like to get startet with Spring WS and JAXB - thanks a lot for your help!

  • #2
    look here


    • #3
      Hello ptalakanti,

      thanks for your answer. Your link describes the maven task like the following webpage:

      The difference is, that the official JAXB-page also uses .xsd files directly, not the WSDL. The example in your link uses quite the same approach with the small difference, that for "xjc.exe" the parameter "-wsdl" will be used. But when I start "xjc.exe" manually and display the help, the "-wsdl" parameter reads:

      "treat input as WSDL and compile schemas inside it (experimental,unsupported)".

      So I thought this could not be the common way to do it.


      • #4
        I am not sure why the example was not working but I ended up creating a maven build file to generate java objects from wsdl

        I could not download the plugin, It turns out it is not available on maven central so I added this repository to pom.xml

        	  <name> Repository for Maven</name>
        I have to say the documentation is not really good for this plugin, I stumbled around a bit before I got this working. I used the following maven plugin config to generate the java objects from wsdl input

        looks like you did the same thing, I don't know why you got that error. I tried to attach my pom.xml to the post but I keep getting invalid file error


        • #5

          I am looking for a similar way of developing a webservice-Client, can you please suggest me a good site , where i can start with.Since i do not know much about JAXB.


          • #6
            Hello GSP,

            when starting with Spring WS, I think the official reference documentation is a good start point. It is not as heavy as the Spring core documentation, so I think, especially when focusing the development of a Webservice client, you will get started quickly.

            As for JAXB, when you only want to generate classes out of a XML Schema file (.xsd), you just use the command line tool "xjc.exe", found in your JDK bin-directory, it is really easy. For a webservice client, this is what you only need. Of course, JAXB is more than that, and if you want to learn to annotate your own classes with JAXB, I suggest consulting JAXB's official documentation, also. But for a Webservice client, you only need JAXB generate your files and then have a look at the Marshalling mechanism in the Spring WS documentation.
            Last edited by patb; Aug 2nd, 2011, 12:35 PM.


            • #7
              Thank you so much for your help.I will try Spring WS and let you know.


              • #8
                This very helpful to me too ptalakanti...

                Education Consultants in India


                • #9
                  I use WSDL generation using this maven artefact.

                  Here are some problems i already met with other technologies (no Spring ws) remote webservices :
                  - SOAP Action is required by some remote webservices ==> you have to add it in soap header using a callback
                  - the wsdl only declares complexType and no element ==> you have to add the complexType object in a JAXBElement with the good QName
                  - the wsdl uses the same root tag for all functions (for example : parameters) and functions all returns the same root tag ==> you have to use a JAXBElement with the good QName for the request / You have to use a specific source extractor

                  In order to call remote services using their wsdl, i shared an interceptor that allows all those functions :
                  In my java code, i just have to code a JAVA interface that matches the remote wsdl with generated classes as parameters and return types. The interceptor does his work in order to call webservice.

                  Hope it helps.


                  • #10
                    Check the following tutorials. You might find something interesting:




                    • #11
                      Hello Everyone,

                      Did anyone suceed in developeing clien web service code using Spring WS, starting with wsdl and using Ant script ?