Hi Ole,
This is a good suggestion. I still have to investigate the scripting functionallity, but I guess this could be done.
However the problem is if a web service is removed, I will not be able to detect this and will not stop the mock service.
The best solution for me is to have a central server application that is feeded with project files, parses the files and starts each mock service found in the files. When an update is needed in the services, the application is restarted.
I tried to play with the API and tried this code:
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.List;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.model.mock.MockService;
import com.eviware.soapui.model.project.ProjectFactory;
import com.eviware.soapui.model.project.ProjectFactoryRegistry;
public class TestServer {
public static void main(String[] args){
TestServer server = new TestServer();
try {
server.startServer();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(0);
}
}
public void startServer() throws Exception{
startEndListener();
ProjectFactory projectFactory = ProjectFactoryRegistry.getProjectFactory("wsdl");
WsdlProject project = (WsdlProject) projectFactory.createNew("file:/C:/wp/rsa/ServerSOAPUI/bin/projects/HelloWS-soapui-project.xml", "");
List mockRunner =project.getMockServiceList();
for(int i = 0 ; i < mockRunner.size() ; i ++){
System.out.println(mockRunner.get(i));
MockService service = mockRunner.get(i);
service.start();
}
System.out.println("End of starting services.");
}
public void startEndListener() throws Exception{
final ServerSocket serverSocket = new ServerSocket(0);
System.out.println("==================Listening on port:"+serverSocket.getLocalPort());
Thread thread = new Thread(){
public void run(){
try {
Socket socket = serverSocket.accept();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Exiting SOAP UI.");
System.exit(0);
}
};
thread.start();
}
}
I'll elaborate on the application and will include it in the build.