Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Metro Client Using Local WSDL File

I have generated a Metro client using wsimport before, but in that case the WSDL was accessed over https. My commaned looked like this:

wsimport https://service.net/services/Service?wsdl -d C:\ClientProject\src\main\java -keep

and everything worked fine. Now I am trying to generate a client, however, I only have a local copy of the WSDL file. My project directory is set up like this (in c:\Devel):

ClientProject
  |- src
     |- main
        |- java
     |- resources
        |- META-INF
           |- service.wsdl
  |- wsimport.bat

The wsimport.bat file looks like this:

wsimport -keep -d ../src/main/java -wsdlLocation ../src/resources/META-INF/service.wsdl

which was based on the Metro Guide example but without the -p option (http://metro.java.net/guide/Developing_client_application_with_locally_packaged_WSDL.html). However, when I run the bat file, I get an endless loop of of the command being printed to the console. E.g.

C:\Devel\ClientProject>wsimport -keep -d ../src/main/java -wsdlLocation ../src/resources/META-INF/service.wsdl

Can somebody point out what I'm doing wrong?

UPDATE

I have tried using absolute paths (and rearranging the param order to no avail. I still get the endless command console prints:

wsimport C:\Devel\ClientProject\src\resources\META-INF\service.wsdl -d C:\Devel\ClientProject\src\main\java -keep
like image 214
sdoca Avatar asked Mar 08 '11 19:03

sdoca


People also ask

How do you generate the client code from a WSDL?

Generate the client code as follows: In the Project Explorer, right-click your client project's WSDL file, and then select WebLogic Web Services > Generate Web Service Client from the drop-down menu, as Figure 1 shows. This will open the New Web Service Client dialog that Figure 2 shows.

Where do I put WSDL files?

The files referenced by the <wsdl-file> element in the webservices. xml might import other WSDL or XML Schema Definition (XSD) files. Typically, all WSDL or XSD files are initially placed into the META-INF/wsdl directory when using Enterprise JavaBeans (EJB) or the WEB-INF/wsdl directory when using Java™.

How do I generate stubs in Wsimport?

You can run wsimport command from any directory where you like to generate stubs. We have published a sample soap web service which we going to use in this example. You can use this sample service URL https://test.java4coding.com/core/service/service.php?wsdl to test the wsimport command.


1 Answers

http://www.java.net/forum/topic/glassfish/metro-and-jaxb/problems-generating-client-using-local-wsdl-file#comment-812705

If using a .bat file to run the wsimport command, do not name it wsimport or you'll be in an endless recursive loop calling that file.

Also, "-wsdllocation" is case sensitive. "-wsdlLocation" will not work (although I've seen many examples of it during my searches).

This wsimport command generates the client code from the local WSDL and sets the "wsdlLocation" attribute on the Service class' @WebServiceClient annotation:

wsimport src/resources/META-INF/service.wsdl -keep -d src/main/java -wsdllocation META-INF/service.wsdl
like image 94
sdoca Avatar answered Oct 04 '22 22:10

sdoca