0

I am using Apache Geronimo Server for my Development. I need to generate code from a WSDL exposed over https. I used the following command:

wsimport -keep -verbose https://devurl:7443/process-engine/soap/CustomerByNumber_v1?wsdl

But I am getting this error:

parsing WSDL...

[ERROR] Received fatal alert: protocol_version

Failed to read the WSDL document: https://devurl:7443/process-engine/soap/CustomerByNumber_v1?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.

When we hit the WSDL URLs it has a username/password authentication.

How can I solve this problem?

Bogdan
  • 23,890
  • 3
  • 69
  • 61
Joy
  • 1
  • 1

1 Answers1

0

The error message mentions the possible reasons:

  1. could not find the document;
  2. the document could not be read;
  3. the root element of the document is not <wsdl:definitions>.

You mention that the service requires username/password authentication. Is that the case for accesing the WSDL also? So the protocol might not necessarily be the problem.

Do the following:

  • open the WSDL URL in the browser. Your browser will have no issue with HTTPS.
  • provide username/password if it is required to access the WSDL.
  • make sure the document that opens is a WSDL and contains a <wsdl:definitions> root element.
  • download the WSDL to your computer with a .wsdl extension.
  • use wsimport with this file: wsimport -keep -verbose yourSavedFile.wsdl
Bogdan
  • 23,890
  • 3
  • 69
  • 61
  • The stub files got generated if I download it in my local machine. Since its HTTPS wsdl I was trying to create the stub files using the URL with https. Does it matter when we create the stub files after downloading the wsdl in local machine and stub files created using the URL ... This stub files will be used in the development later in the project. Do I need to install the Server Certificate in the Client webserver or in the Keystore where Java is only installed? – Joy May 26 '21 at 13:50
  • If you managed to generate the client code with a local WSDL, then that code can be used to call the SOAP web service. You will make your SOAP calls over HTTPS, so yes, you will need to configure your client with a keystore so that it knows how to communicate with the service over the secure connection. – Bogdan May 26 '21 at 15:52
  • I created the Stub files. Also I added the server certificate in JVM "C:\Program Files\Java\jdk1.7.0_60\jre\lib\security\cacerts" file. I wrote a Client Java file and try to access the SOAP webservice over https but getting the exception mentioned below:javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://devurl:7443/process-engine/soap/CustomerByNumber_v1?wsdl. It failed with: Got sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target... – Joy May 26 '21 at 21:11
  • What is the wsdlLocation attribute on your client `@WebServiceClient` annotation? Does it point to the URL you had trouble with? Since you already downloaded the WSDL you can use it locally by making a few changes to your client code. See for example [this question](https://stackoverflow.com/questions/20101009/why-does-a-jax-ws-client-access-the-wsdl-at-run-time) or [this one](https://stackoverflow.com/questions/4163586/jax-ws-client-whats-the-correct-path-to-access-the-local-wsdl) for starters. – Bogdan May 27 '21 at 08:55
  • I was able to solve the issue. The certificate is not installed in exact place I installed it now. Now getting 401 response from server. 401 response I am getting because I am not able to set username and password correctly. I am using JAXWS can some write how to pass Username and password in Client. I am using JDK 1.7... – Joy May 27 '21 at 15:06
  • Since you mentioned the WSDL was also protected by username/password, I'm assuming this is BASIC authentication? If that's the case see if this helps: https://stackoverflow.com/questions/7071366/java-web-service-client-basic-authentication – Bogdan May 28 '21 at 10:04
  • Thanks Bogdan was able to solve the issue. I now need to configure the same static Java client for webserver. What are the changes I need to make in webserver for HTTPS to work. I am using Apache Geronimo server. – Joy May 28 '21 at 14:51