3

I need desperate help to figure out the reason for the failure in creating the service.

My application is developed using Eclipse tool and it runs well there. It uses cxf-3.1.7 library collection. A console program that initializes the process to create the service to the API. Everything looks good and fine.

I am trying to deploy the code in another machine. I installed the necessary jre and other files. I created a batch file with all the necessary path and classpath settings. I need to run the batch file on a daily base, so that it pulls the data regularly. But, when I run the batch file, it fails to create the service with the above error message.

Can someone suggest me the reason if I am going wrong somewhere or any solution to get the service created. This is the batch file I have:

set path=C:\Program Files\Java\jdk1.8.0_91\bin 
set classpath=cxf-core-3.1.7.jar;cxf-rt-frontend-simple-3.1.7.ja‌​r;sqljdbc42.jar;cxf-‌​rt-frontend-jaxws-3.‌​1.7.jar;wsdl4j-1.6.3‌​.jar;cxf-rt-wsdl-3.1‌​.7.jar;xmlschema-cor‌​e-2.2.1.jar;lib*.jar‌​;. 
java com.strongmail.services.v2.MailingService_MailingServicePort‌​_Client 
pause

Thanks in advance.

Michael Shopsin
  • 2,055
  • 2
  • 24
  • 43
Venu Goli
  • 41
  • 1
  • 1
  • 2
  • Could we see your batch file? – Michael Shopsin Jan 18 '18 at 15:22
  • This is the batch file I have. set path=C:\Program Files\Java\jdk1.8.0_91\bin set classpath=cxf-core-3.1.7.jar;cxf-rt-frontend-simple-3.1.7.jar;sqljdbc42.jar;cxf-rt-frontend-jaxws-3.1.7.jar;wsdl4j-1.6.3.jar;cxf-rt-wsdl-3.1.7.jar;xmlschema-core-2.2.1.jar;lib\*.jar;. java com.strongmail.services.v2.MailingService_MailingServicePort_Client pause – Venu Goli Jan 18 '18 at 15:28

2 Answers2

4

I've created java classes from wsdl with org.apache.cxf.tools.wsdlto.WSDLToJava. While creating an instance of the service, I had exact same exception at runtime:

org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service

Previous code:

URL wsdlURL = new URL("http://example.com/my_service.asmx");
MyWS mailWS = new MyWS(wsdlURL); // Exception is thrown here

Solution was weird. I've just added ?wsdl next to service address:

URL wsdlURL = new URL("http://example.com/my_service.asmx?wsdl");
MyWS mailWS = new MyWS(wsdlURL);
Devrim
  • 15,345
  • 4
  • 66
  • 74
0

If you are trying to create a client for a api has SSL, you should start the Java command with a necessary option. -Dorg.apache.cxf.stax.allowInsecureParser=1