aspose file tools*
The moose likes Spring and the fly likes Spring not auto-generating WSDL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring not auto-generating WSDL" Watch "Spring not auto-generating WSDL" New topic
Author

Spring not auto-generating WSDL

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
I have what I think is a simple "Hello World" (from Imbibing Java Web Services) type web service project where the WSDL should be generated, but it's not.

Just wondering if anyone can see something obvious I'm missing.

I can post other code if it would be helpful.

Here's the web.xml:


And here's the Spring app context file:



----

I can go to the browser and do a "http://localhost:8080/SpringWSJDOMExample/services/holidayService" and see a blank page, which would be OK here so I'm close.

http://localhost:8080/SpringWSJDOMExample/services/holidayService?wsdl is also blank, however.

Yet, looking at the deployed application under Tomcat, there is no WSDL so there are no exposed services. Not sure if this WSDL is actually a disk file or just in memory. In either case, the WSDL isn' showing anything from the browser command above.

Not sure what's wrong.

Would really appreciate any ideas or input.

Thanks,

-mike
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

The bean id determines the URL where the WSDL can be retrieved.

See here:
http://static.springsource.org/spring-ws/sites/1.5/reference/html/tutorial.html#tutorial-publishing-wsdl

and here:
http://forum.springsource.org/showthread.php?33791-Getting-the-WSDL-from-a-Web-service-endpoint&p=101967#post101967

long story short try


[How To Ask Questions][Read before you PM me]
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
Bill Gorder wrote:The bean id determines the URL where the WSDL can be retrieved.

See here:
http://static.springsource.org/spring-ws/sites/1.5/reference/html/tutorial.html#tutorial-publishing-wsdl

and here:
http://forum.springsource.org/showthread.php?33791-Getting-the-WSDL-from-a-Web-service-endpoint&p=101967#post101967

long story short try


Hey Bill,

Thanks. I was eventually able to see the WSDL in the browser (but not on disk).

Now, my problem is that I'm getting a 404 error on the Endpoint. I'm using the "Imbibing Java Web Services" book (which is very, very good), but for some reason, even though everything I have seems to match, I'm still not able to actually run the sample JDOM Spring WS example.

Could you tell me if I should post the code and spring configuration files?

I see that lots of people seem to have similar issues with 404 and endpoints (not from this book, of course).

Very frustrating.

Please advise.

Thanks,

- Mike
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

Well as far as finding it on disk you wont. That is more of a developer tool. As a matter of fact they caution against using this feature in production:

CAUTION:
Even though it can be quite handy to create the WSDL at runtime from your XSDs, there are a couple of drawbacks to this approach. First off, though we try to keep the WSDL generation process consistent between releases, there is still the possibility that it changes (slightly). Second, the generation is a bit slow, though once generated, the WSDL is cached for later reference.

It is therefore recommended to only use <dynamic-wsdl> during the development stages of your project. Then, we recommend to use your browser to download the generated WSDL, store it in the project, and expose it with <static-wsdl>. This is the only way to be really sure that the WSDL does not change over time.



As for your 404 I am not familiar with the book although my suggestion would be to download SOAP UI (there is a free version which is perfectly sufficient)

http://www.soapui.org/

Point this at your published WSDL and have it generate mock requests. You can use this tool to test your service endpoints. You might find the the Spring-WS side of things is not the problem.

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
Bill Gorder wrote:Well as far as finding it on disk you wont. That is more of a developer tool. As a matter of fact they caution against using this feature in production:

CAUTION:
Even though it can be quite handy to create the WSDL at runtime from your XSDs, there are a couple of drawbacks to this approach. First off, though we try to keep the WSDL generation process consistent between releases, there is still the possibility that it changes (slightly). Second, the generation is a bit slow, though once generated, the WSDL is cached for later reference.

It is therefore recommended to only use <dynamic-wsdl> during the development stages of your project. Then, we recommend to use your browser to download the generated WSDL, store it in the project, and expose it with <static-wsdl>. This is the only way to be really sure that the WSDL does not change over time.



As for your 404 I am not familiar with the book although my suggestion would be to download SOAP UI (there is a free version which is perfectly sufficient)

http://www.soapui.org/

Point this at your published WSDL and have it generate mock requests. You can use this tool to test your service endpoints. You might find the the Spring-WS side of things is not the problem.



Good points all. Thanks again Bill. I'll report back with any updates.

mike
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
Mike London wrote:
Bill Gorder wrote:Well as far as finding it on disk you wont. That is more of a developer tool. As a matter of fact they caution against using this feature in production:

CAUTION:
Even though it can be quite handy to create the WSDL at runtime from your XSDs, there are a couple of drawbacks to this approach. First off, though we try to keep the WSDL generation process consistent between releases, there is still the possibility that it changes (slightly). Second, the generation is a bit slow, though once generated, the WSDL is cached for later reference.

It is therefore recommended to only use <dynamic-wsdl> during the development stages of your project. Then, we recommend to use your browser to download the generated WSDL, store it in the project, and expose it with <static-wsdl>. This is the only way to be really sure that the WSDL does not change over time.



As for your 404 I am not familiar with the book although my suggestion would be to download SOAP UI (there is a free version which is perfectly sufficient)

http://www.soapui.org/

Point this at your published WSDL and have it generate mock requests. You can use this tool to test your service endpoints. You might find the the Spring-WS side of things is not the problem.



Good points all. Thanks again Bill. I'll report back with any updates.

mike



--------

Here's the output from SOAPUI: 404:



OK, so here are configuration and server and client files and such to help debug this issue. Appreciate any ideas here.

I've spent hours and hours and it's not clear where the 404 issue is coming from. The key thing I've focused on is making sure the Endpoint mapping matches the definition. I think that part
is correct, but again, given the 404 error, I'm not 100% sure...




-----------------------------------

springws-servlet.xml:


--------------------------
HolidayService EndPoint class:



----------------------

WEB.XML:



====================
====================

CLIENT CALLING CODE:



Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

I don't have time to look to hard at it at the moment but at a glance something looks off about your component scan. You should be scanning any packages with classes that have stereotype annontations (like @Endpoint)

What class is your HolidayServiceEndpoint in? If it is in com.sample.endpoint then you component scan should be sure to include that i..e.

<context:component-scan base-package="com.sample.endpoint"/>

Without that class getting picked up and registered there will be no endpoints to service your request. Like I said I only had time to give it a glance this morning but try that and maybe I can take a closer look later this afternoon.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
Bill Gorder wrote:I don't have time to look to hard at it at the moment but at a glance something looks off about your component scan. You should be scanning any packages with classes that have stereotype annontations (like @Endpoint)

What class is your HolidayServiceEndpoint in? If it is in com.sample.endpoint then you component scan should be sure to include that i..e.

<context:component-scan base-package="com.sample.endpoint"/>

Without that class getting picked up and registered there will be no endpoints to service your request. Like I said I only had time to give it a glance this morning but try that and maybe I can take a closer look later this afternoon.


Hi Bill,

Thanks for your reply!!!

The directory of the HolidayServiceEndpoint class is: src > main > resources

The main was created by maven setup.

Please see attached. (Note: I could sent you my Intellij project at your request.)

Thanks again very much.

-- mike



[Structure.png]

Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

Well lets continue to set the client side apart for now and use SoapUI.

I still thing that component scan is at the heart of your problems. It is very very unconventional at best to be putting class files in the src/main/resources directory or vice versa to put .xml or .properties in the src/main/java/ The second you see once in awhile but it requires modifications to your maven pom file so that when you build the WAR they actually get placed.

A simple test would be to crack open the WAR that gets built and placed in the target directory. My guess is that things are missing or just wrong in there.


There should be a package at the top of your HolidayServiceEndpoint ex. package com.mycompany.hr.ws. This is the package that should be in the component scan. All .java files should be under src/main/java or src/test/java (if they are testing classes) this is the standard for Maven projects. Likewise non .java files should be in src/main/resources or src/test/resources.

Note for web projects maven creates a webapp directory containing your WEB-INF directory. This is where you web.xml should be located. Many people will also place their Spring config xml's somewhere beneath this web-app directory although some place them in src/main/resources as well.

I have not used IntelliJ except for a handful of times but they should adhere to the standard maven conventions. Were you building this project from existing sources or did you start from scratch?


I did not see sources listed for this book but it looks like he adapted one of the official Spring-ws examples (the holiday service). The other thing you could do is run that example you will find it here:

https://github.com/SpringSource/spring-ws/tree/master/samples

The samples link above has a number of projects/examples but the one you are interested in is the tutorial project. I think you will also find this in a samples directory if you download the distribution from here:
http://www.springsource.org/spring-web-services#download
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
Bill Gorder wrote:Well lets continue to set the client side apart for now and use SoapUI.

I still thing that component scan is at the heart of your problems. It is very very unconventional at best to be putting class files in the src/main/resources directory or vice versa to put .xml or .properties in the src/main/java/ The second you see once in awhile but it requires modifications to your maven pom file so that when you build the WAR they actually get placed.

A simple test would be to crack open the WAR that gets built and placed in the target directory. My guess is that things are missing or just wrong in there.


There should be a package at the top of your HolidayServiceEndpoint ex. package com.mycompany.hr.ws. This is the package that should be in the component scan. All .java files should be under src/main/java or src/test/java (if they are testing classes) this is the standard for Maven projects. Likewise non .java files should be in src/main/resources or src/test/resources.

Note for web projects maven creates a webapp directory containing your WEB-INF directory. This is where you web.xml should be located. Many people will also place their Spring config xml's somewhere beneath this web-app directory although some place them in src/main/resources as well.

I have not used IntelliJ except for a handful of times but they should adhere to the standard maven conventions. Were you building this project from existing sources or did you start from scratch?


I did not see sources listed for this book but it looks like he adapted one of the official Spring-ws examples (the holiday service). The other thing you could do is run that example you will find it here:

https://github.com/SpringSource/spring-ws/tree/master/samples

The samples link above has a number of projects/examples but the one you are interested in is the tutorial project. I think you will also find this in a samples directory if you download the distribution from here:
http://www.springsource.org/spring-web-services#download


Hi Bill,

Added a package and changed the component scan, but still get the same Exception:

org.springframework.ws.client.WebServiceTransportException: Not Found [404]
at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:622)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:546)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:496)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:451)
at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:395)
at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:386)
at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:376)
at HolidayServiceClient.invokeService(HolidayServiceClient.java:46)
at HolidayServiceClient.main(HolidayServiceClient.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Process finished with exit code 0
-----

Here are the updated configuration files:



----------------



-----------------

Do I now need to make other changes to account for the package change?

The project complies, creates a WAR file, and deploys.

This is very confusing.

Thanks,

- Mike


[project-updated.png]

[project.png]

Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

You still have your com.test.ws under src/main/resources instead of src/main/java

Not sure you are still trying to get this to work but if you are open of the WAR you are bulding with a program like 7zip and see if the files in there are what you expect and in the places you expect. Typically maven will not copy the .java /.class files it finds under the /src/main/resources tree.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
Bill Gorder wrote:You still have your com.test.ws under src/main/resources instead of src/main/java

Not sure you are still trying to get this to work but if you are open of the WAR you are bulding with a program like 7zip and see if the files in there are what you expect and in the places you expect. Typically maven will not copy the .java /.class files it finds under the /src/main/resources tree.


Thanks for your reply.

I finally got everything to work. The problems were a combination of using the same namespace everywhere and Maven not creating a directory structure I could modify.

The bottom line is that the Spring-WS is not well documented and with few examples, the developer spends hours trying to figure everything out initially.

Back to Maven, creating a "Web archetype" in Intellij creates the directory structure where only the "resource" folder is "blue" and lets you create packages. Extremely confusing. All the links to the "standard maven directory structure" do little to help when the IDE doesn't create a workable or expected structure. The "src" folder that gets created only lets you create folders beneath it - regardless of how many you create. I also made the (newbie) mistake of adding libs directly within Intelilj that Maven didn't know about. So, even when the code was perfect, I got JDOM errors that were related to JAR conflicts or missing JARs, or whatever. Still the errors made no sense, didn't relate to the code, and only further obfuscated the solution. I'm sure I'm "missing" something, but should it be so difficult?

Appreciate all your kind replies.

-- mike
 
Don't get me started about those stupid light bulbs.
 
subject: Spring not auto-generating WSDL
 
Similar Threads
SpringWS - Problem in invoking webservice
Autowiring Problem - NullPointerException.
Spring webMVC - org.springframework.web.servlet.DispatcherServlet noHandlerFound
spring-ws - failed to deploy the tutorial example on jboss server
Problem in setting bean scope to request