Forum Discussion
cortez
13 years agoOccasional Contributor
cortez wrote: I could, of course, easily run the Swagger UI from a different server, but I have encountered a different issue when I do that - the CORS pre-flight OPTIONS request sent when I do a POST from the Swagger UI is declined, even if I set the correct headers: "Access-Control-Allow-Origin" "*"
"Access-Control-Allow-Methods" "POST, GET, OPTIONS, PUT, PATCH, DELETE"
I am not sure if that is a Swagger problem or a SoapUI problem.
In fact this also looks like a SoapUI issue. Watching the Swagger UI POST request with Firefox it indeed stalls at the pre-flight OPTIONS method, with a 500 Internal Server error; this is what the SoapUI log displays:
Thu Nov 07 18:06:22 GMT 2013:ERROR:An error occured [Unsupported HTTP Method: OPTIONS], see error log for details
This is from the error log:
Thu Nov 07 18:06:22 GMT 2013:ERROR:com.eviware.soapui.impl.wsdl.mock.DispatchException: Unsupported HTTP Method: OPTIONS
com.eviware.soapui.impl.wsdl.mock.DispatchException: Unsupported HTTP Method: OPTIONS
at com.eviware.soapui.model.support.AbstractMockRunner.dispatchRequest(AbstractMockRunner.java:79)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:377)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:715)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The request does work if I explicitly handle the OPTIONS method in my Groovy script:
if ( mockRequest.method == "OPTIONS" )
{
return new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(mockRequest)
}
Is that the right way to handle the request in this context? Should I really have to handle it all? Even when I do that it never actually goes beyond the OPTIONS, so the follow-up POST never gets handled.