Contributions
Re: Problems testing REST service on Glassfish
Selecting "Post query string" fixed this for me. Here is a before and after of the posts if anyone is having the same problem. Not sure I understand whats going on here but it's working. This was a "bad" request POST /ScannerWebService/actions/store?scannerId=12341231&data=testdataHTTP/1.1 Content-Type: application/x-www-form-urlencoded User-Agent: Jakarta Commons-HttpClient/3.1 Host: localhost:8080 Content-Length: 0 And this was a "good" request POST /ScannerWebService/actions/store HTTP/1.1 Content-Type: application/x-www-form-urlencoded User-Agent: Jakarta Commons-HttpClient/3.1 Host: localhost:8080 Content-Length: 390 scannerId=12341231&data=testdata807Views0likes0CommentsProblems testing REST service on Glassfish
We have a very simple REST service that takes 2 params, I have a commons http client that can successfully send a request, but I have not been able to get SoapUI to work. Mostly I get "HTTP/1.1 415 Unsupported Media Type", this messages seems to be coming from Jersey/Glassfish. I don't think our code is even getting called. I have tried all the default content types (text/xml,application/xml etc), still no luck. A tcpdump of the request looks ok. This is the java code that works (attached is the soapui.xml) package mcjavascanclient; import java.io.IOException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.methods.PostMethod; public class ScanTest { public static void main(String args[]) { HttpClient client = new HttpClient(); String uri = "http://qaaejb03:13080/ScannerWebService/actions/store"; PostMethod post = new PostMethod(uri); post.addParameter(new NameValuePair("scannerId", "19621962")); post.addParameter(new NameValuePair("data","testdata")); try { client.executeMethod(post); System.out.println(post.getResponseBodyAsString()); System.out.println(post.getStatusCode()); } catch (HttpException e) { e.printStackTrace(); } catch ( IOException e ) { e.printStackTrace(); } finally { post.releaseConnection(); } } } Any help would be great TIA1.9KViews0likes1CommentRe: REST End point with port number
Yes the service is running on that port In the request(raw) window I see this POST http://qaaejb03.qa.appriss.com:13080/Sc ... 1231&data= And int the http log Thu Jan 22 11:43:55 EST 2009:DEBUG:>> "POST /ScannerWebService//actions/store?scannerId=12341231&data=QAoeDUFOU0kgNjM2MDMwMDEwMkRMMDAzOTAxODdaTTAyMjYwMDQ0RExEQVFSOTAxMjM0MDIxCkRBQVNBTVBMRSxTQU1QTEUsQiwKREFHMTAwIE1BSU4gU1RSRUVUCkRBSUpFRkZFUlNPTiBDSVRZCkRBSk1PCkRBSzY1MTA5ICAgICAgCkRBUkIgICAKREFTSiAgICAgICAgIApEQVRQUyAgIApEQVU2MDAKREFXMTkwCkRBWUJSTwpEQkEyMDA2MDMwNgpEQkIxOTcwMDEwNQpEQkNNCkRCRDIwMDUxMjA2DVpNWk1BQ09MRQpaTUIwNTkwMTIzNDAwMjgKWk1DVSAgICAgICAgIApaTUQNDQoNCg== HTTP/1.1[\r][\n]" Thu Jan 22 11:43:55 EST 2009:DEBUG:>> "Connection: close[\r][\n]" Thu Jan 22 11:43:55 EST 2009:DEBUG:>> "Content-Type: application/x-www-form-urlencoded[\r][\n]" Thu Jan 22 11:43:55 EST 2009:DEBUG:>> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]" Thu Jan 22 11:43:55 EST 2009:DEBUG:>> "Host: qaaejb03.qa.appriss.com:13080[\r][\n]" Thu Jan 22 11:43:55 EST 2009:DEBUG:>> "Content-Length: 0[\r][\n]" Thu Jan 22 11:43:55 EST 2009:DEBUG:>> "[\r][\n]" Thu Jan 22 11:43:55 EST 2009:DEBUG:<< "HTTP/1.1 404 Not Found[\r][\n]" Thu Jan 22 11:43:55 EST 2009:DEBUG:<< "HTTP/1.1 404 Not Found[\r][\n]"1.1KViews0likes0Comments