|
Title: Create MockService through java program rather than using SoapUI GUI Post by: apoorva on July 16, 2008, 07:57:07 pm Hi,
I want to create MockResponse for a particular interface through java program.. I downloaded source code of soapui and successfully build it using maven 1.0.2... Now I am trying to write java program which will create mockservice and save in porject.xml file so later on I can also open in SoapUI as well... I will appreciate if any inpute will available.. Thanks, Jim Title: Re: Create MockService through java program rather than using SoapUI GUI Post by: omatzura on July 17, 2008, 10:26:09 am Hi Jim,
do the following from your Java code: 1) create a new WsdlProject 2) add your WSDL to the project with the WsdlImporter class 3) add a new WsdlMockService to your project with project.addNewMockService 4) add the desired mockOperation/mockResponses 5) save the project with project.save(..) ok? regards! /Ole eviware.com Title: Re: Create MockService through java program rather than using SoapUI GUI Post by: apoorva on July 17, 2008, 11:46:37 pm Hi Ole,
Thanks for your reply. The steps you mentioned helped me a lot. I have one more concern. I am able to generate MockResponse now. But I want to generate the MockResponse content from the schema.. I guess WsdlMockResponse mockresp =mockope.addNewMockResponse(mockresponseConfig); will do something but not aware how to set mockresponseConfig... Can you please throw some light on this please and provide a couple of line of code which will generate mockresponse from schema.. Thank you for precious time. Regards, Jim Title: Re: Create MockService through java program rather than using SoapUI GUI Post by: omatzura on July 22, 2008, 08:34:22 am Hi Jim,
have you resolved this issue? regards, /Ole eviware.com Title: Re: Create MockService through java program rather than using SoapUI GUI Post by: apoorva on July 23, 2008, 12:06:02 am Hi Ole,
I am able to generate MockResponse from schema now.. Just need to set one property WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS to true SoapUI.getSettings().setBoolean(WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS ,true); But I have another concern, When I am trying to save project.xml file using Save() method it gives me null pointer excption The problem is public boolean save() { // this give me error because i m not saving project using soapui GUI file = UISupport.getFileDialogs().saveAs(this, "Save project " + getName(), ".xml", "XML Files (*.xml)", new File( path )); ........ //and i cant even call saveIn to bypass save() because saveIn is private method return saveIn(projectFile); } right now i just change the source code and make saveIn to public .. Is there any alternative way to save project? Looking forward to here from you. Thanks, Jim Title: Re: Create MockService through java program rather than using SoapUI GUI Post by: omatzura on July 23, 2008, 09:37:49 am Hi,
no, we'll make saveIn public in the next release.. thanks for pointing this out. regards, /Ole eviware.com |