Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wsimport not working

Tags:

wsdl

wsimport

When I try to use wsimport using the below command from command prompt, it's working fine:

wsimport -d generated C:\Users\generated\wsdlfile.xml

However, when I try to use wsimport as below, it's throwing the following error:

wsimport -d generated https://example.com/exampleService.svc?wsdl

Failed to read the WSDL document: https://example.com/exampleService.svc?wsdl, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not <wsdl:definitions>.

[ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s): At least one WSDL with at least one service definition needs to be provided.

        Failed to parse the WSDL.

I can access the URL from a browser, and the same thing is working from other systems (from my PC). What could be the reason?

like image 713
Kartic Avatar asked Aug 29 '14 11:08

Kartic


People also ask

How do I run Wsimport?

To run the wsimport , go to the root directory of web services client project and use command prompt. -s -s defines the directory for source files. And pass the wsdl URL of web services end point. The below classes will be generated for web service client for the given WSDL URL.

Where is Wsimport EXE?

The wsimport tool is used to parse an existing Web Services Description Language (WSDL) file and generate required files (JAX-WS portable artifacts) for web service client to access the published web services. This wsimport tool is available in the $JDK/bin folder.

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.

What is Wsimport in Java?

The wsimport tool generates JAX-WS portable artifacts, such as: Service Endpoint Interface (SEI) Service. Exception class mapped from wsdl:fault (if any) Async Reponse Bean derived from response wsdl:message (if any)


2 Answers

I have solved this issue on Windows by disabling all proxy settings as follows:

Internet Options > Connections > Lan Settings > Disable all check boxes

NOTE: Just adding localhost or my IP address as an exception to my proxy settings didn't work for me.

like image 62
Diego Magdaleno Avatar answered Oct 17 '22 23:10

Diego Magdaleno


I had this same issue and, in my case, the problem was the encoding of the WSDL file.

Try opening https://example.com/exampleService.svc?wsdl from a browser. If it can be completely parsed, you will see all the xml content. If not, at least Firefox will point you where the problem is.

Hope it helps someone in this situation

like image 4
Edu Castrillon Avatar answered Oct 18 '22 00:10

Edu Castrillon