Forum Discussion

jgehly's avatar
jgehly
New Contributor
12 years ago

REST Template Parameter parsing

The TEMPLATE parameter type for REST calls doesn't properly generate the URL.

I've watched the URL endpoint for what a REST request looks like when only using QUERY parameters, and it ends up looking something like this:

https://<hostname>/<service>?<param1=value1>&....<paramN=valueN> where <hostname> would be the DNS or IP address of the server running the RESTful services, and <service> is the URL extension to the exact service (for example /test/rest/getXMLDocs).


When working with TEMPLATE parameters, the URL should end up looking like:

https://<hostname>/<service>/{template}?<param1=value1>&....<paramN=valueN>. In my case the {template} parameter is a relative path to a file on the server (for example, /store/docs/testDocument.xml). The entire URL put together is a GET request for a specific file and resembles

https://<hostname>/test/rest/getXMLDocs/store/docs/testDocument.xml?request.preventCache=true

If I type the above into a browser, it will correctly return me the file I'm after. But in SoapUI what is generated in the request header is a URL that looks like this:

https://<hostname>/?request.peventCache=true


The absence of the <service> and {template} elements in the request is causing my endpoints to either reject the request as malformed or return an incorrect response because the web service thinks I am trying to call /index.

I am using SoapUI 4.5.2 free, but this problem may also exist in the Pro. I can't say whether this problem exists for http calls or for SOAP calls because all I'm using right now is RESTful services over https. I'm researching doing a work around by using a Groovy script to manually set the header to the correct URL, but I wanted to let you know that this problem is out there.

Edit: I've checked the error logs and there is an exception that comes back: java.net.URISyntaxException: Illegal character in path at index 55.... The index corresponds to the { which indicates the start of the template parameter in the url {file:.*}. I am not allowed to post my exact error log because the server URL contained in the log is considered proprietary.

Edit2: I've done more work and this actually not a major defect as I first thought. What happened is that SoapUI did not correctly parse the {file:.*} template parameter and instead read it as just "file" which caused the template to not be filled out correctly. The URL being submitted therefore contained a { in it, which caused the parser to throw the exception. Once I opened up the method resource window, selected the resource path, and hit enter, SoapUI immediately asked if I wanted to add "file:.*" as a TEMPLATE parameter. Once I did that and disabled URL encoding, everything worked peachily. There's still an issue with the parameter parsing, but it's a pretty minor one and easy to work around.
  • jgehly's avatar
    jgehly
    New Contributor
    That seems like the same issue since in both cases it's a template parameter with what looks like a Regex in it. I don't know for sure that JAX-RS was involved in the creation of the WADL, but neither can I rule it out, so I would say this is probably the same issue.