0
votes

I have a WSDL file with me and the service is tactfully not up so i want do a mock service from the WSDL file

Can we generate Java files from WSDL file? i tried wsdl2java win CXF but it saying ERROR

Fail to create WSDL_definition

C:\Users\malnassar\Desktop\cxf3\apache-cxf-3.0.0-milestone1\bin>wsdl2java -impl ContributorSummaryService_1.wsdl

WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: FAIL_TO_CREATE_WSDL_DEFINITION


C:\Users\malnassar\Desktop\cxf3\apache-cxf-3.0.0-milestone1\bin>wsdl2java  ContributorSummaryService_1.wsdl

WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: FAIL_TO_CREATE_WSDL_DEFINITION


C:\Users\malnassar\Desktop\cxf3\apache-cxf-3.0.0-milestone1\bin>wsdl2java  ContributorSummaryService_1.wsdl

WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: FAIL_TO_CREATE_WSDL_DEFINITION


C:\Users\malnassar\Desktop\cxf3\apache-cxf-3.0.0-milestone1\bin>

and tried with wsdl2java in axis1.6 it it ends up with file not found exception

C:\Users\malnassar\Desktop\axis2-1.6.2\bin>wsdl2java.bat -uri ContributorSummaryService_1.wsdl -o c:\WebService\ -uw

logs

Using

AXIS2_HOME: C:\Users\malnassar\Desktop\axis2-1.6.2 Using JAVA_HOME: C:\Program Files (x86)\Java\jdk1.6.0_33 Retrieving document at 'ContributorSummaryService_1.wsdl'. Retrieving schema at 'ContributorSummaryService_1_2.xsd', relative to 'file:/C:/Users/malnassar/Desktop/axis2-1.6.2/bin/ContributorSummaryService_1.wsdl'. log4j:WARN No appenders could be found for logger (org.apache.axis2.i18n.ProjectResourceBundle). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: Error parsing WSDL at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.(CodeGenerationEngine.java:178) at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35) at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24) Caused by: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/xsd:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'ContributorSummaryServ ice_1_2.xsd', relative to 'file:/C:/Users/malnassar/Desktop/axis2-1.6.2/bin/ContributorSummaryService_1.wsdl'.: java.io.FileNotFoundException: This file was not found: file:/C:/Users/malnassar/Desktop /axis2-1.6.2/bin/ContributorSummaryService_1_2.xsd at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.readInTheWSDLFile(CodeGenerationEngine.java:320) at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.(CodeGenerationEngine.java:133) ... 2 more Caused by: java.io.FileNotFoundException: This file was not found: file:/C:/Users/malnassar/Desktop/axis2-1.6.2/bin/ContributorSummaryService_1_2.xsd at com.ibm.wsdl.util.StringUtils.getContentAsInputStream(Unknown Source) ... 13 more C:\Users\malnassar\Desktop\axis2-1.6.2\bin>

3 . When try to create a project with SOAPUI getting below error

Error loading [file:\C:\Users\kpane\Desktop\ContributorSummaryService.xsd]: java.io.FileNotFoundException: C:\Users\kpane\Desktop\ContributorSummaryService.xsd (The system cannot find the file specified

1
Can you please share your error from the logs when you attempt to execute wsdl2java? The community won't be able to assist without more information. - derdc
it seems that the file ContirbutorSummaryService_1_2.xsd is not located where it must to be. - Omar
@kapildas - one more request. "WSDLRuntimeException: FAIL_TO_CREATE_WSDL_DEFINITION" is not a lot by itself and I can see why you did not post it initially. Could you run one more time with "wsdl2java -impl ContributorSummaryService_1.wsdl -verbose" ? - derdc

1 Answers

2
votes

If you want to mock and play around with the web service, try using soapui. souapui.org

Mocking web service using SoapUI : http://www.soapui.org/Getting-Started/mock-services.html

For generating classe using wsdl, JDK has in built wsimport tool to do that. Give it a shot.