Page 1 of 1
Save to URL - REST Interface?
Posted: Fri Apr 23, 2010 7:10 pm
by ted.habermann
Saw the "Save to URL" feature and was hoping for a REST interface... Just got FTP/DAV... Seems like there was a rest interface in the past??? Possible in the future?
Re: Save to URL - REST Interface?
Posted: Mon Apr 26, 2010 5:18 pm
by adrian
Hello,
The 'Save to URL' has always been used for saving files to FTP/WebDAV repositories.
Can you provide more details as to what you were expecting regarding the REST interface?
Regards,
Adrian
Re: Save to URL - REST Interface?
Posted: Thu Apr 29, 2010 3:43 pm
by ted.habermann
Adrian,
My understanding of this is a bit limited, but I would expect the interface to make a post request to a URL which would include the content of the XML. In general we would be doing this with small XML components...
This URL is a get request for a component:
http://www.ngdc.noaa.gov/docucomp/iso/8 ... 8C5AB460D1
we would like to get this URL, edit the XML, then put it back to the same URL...
Thanks,
Ted
Re: Save to URL - REST Interface?
Posted: Thu Apr 29, 2010 4:47 pm
by sorin_ristache
Such simple cases are already possible in Oxygen. The
Open URL action allows you to get the content of that URL (a <gmd:CI_ResponsibleParty> element) and open it in an editor panel. When you want to save the modifications to the same URL just run the
Save action from the toolbar button or from the shortcut Ctrl-S.
Regards,
Sorin
Re: Save to URL - REST Interface?
Posted: Sat May 08, 2010 12:24 am
by russ.baker
I am the developer on this project. I'm trying to use a RESTful webservice to supply the xml and then consume it. When I was debugging my application, I clicked the "save" button, and then put breakpoints in my web service (basically an HttpServlet). The doPost method was not hit.
Is the "save" button process using a HTTP "POST" to the webservice, or what is it doing? I'm confused as to why I'm not seeing my servlet not being hit. Also, if I want to update the document, I want to be able to set values in the request header to let my RESTful webservice know what to do with the XML.
Thanks in advance
Re: Save to URL - REST Interface?
Posted: Sat May 08, 2010 12:43 am
by russ.baker
One more thing I forgot to mention. When I did use the "save" button, the response I got from Oxygen was "Cannot save file. 405 Method not allowed..." But I know that I can push xml to my url via a curl command. So I really need to know how the XML is getting pushed back to the URL that we got it from.
Re: Save to URL - REST Interface?
Posted: Sat May 08, 2010 7:07 am
by russ.baker
sorin wrote:
Such simple cases are already possible in Oxygen. The
Open URL action allows you to get the content of that URL (a <gmd:CI_ResponsibleParty> element) and open it in an editor panel. When you want to save the modifications to the same URL just run the
Save action from the toolbar button or from the shortcut Ctrl-S.
Regards,
Sorin
I had no trouble opening an XML document from my web service, but when I tried to run the
Save action from the toolbar button, I got a "405 Bad Request" as a response. I had my debugger running on my web service that was accepting requests from the URL, and the request did not even make it to the web service.
Is the XML sent as an HTTP POST, or is it using something else? If we're sending the XML to a RESTful web service, is there a way to place header values in the request?
Re: Save to URL - REST Interface?
Posted: Mon May 10, 2010 10:18 am
by sorin_ristache
Hello,
russ.baker wrote:Is the XML sent as an HTTP POST, or is it using something else? If we're sending the XML to a RESTful web service, is there a way to place header values in the request?
The XML is sent as a HTTP PUT because it is a WebDAV client not a generic HTTP client. You can implement a small HTTP client that sends the request using HTTP POST as a
custom protocol plugin that provides a Java URL handler for HTTP URLs.
Regards,
Sorin
Re: Save to URL - REST Interface?
Posted: Mon May 10, 2010 6:50 pm
by russ.baker
What I ended up doing was to implement the "doPut" method in my servlet, and I saw the request. Now the "doPut" method will handle my "update" requests from Oxygen.
So now that we have a way to open and update an xml file from a web service, can we implement the "doPost" method to insert a new XML document?
Re: Save to URL - REST Interface?
Posted: Mon May 10, 2010 7:50 pm
by russ.baker
I just ran a test to see how the XML is saved if we are trying to do an insert (new document saved to a url) and it looks like Oxygen uses the "PUT" method for inserts too.
I would like to tell the difference between the insert and update in my servlet, but I'm not seeing anything in the request that can help me. Can we use a different method (say POST) or again, put something in the request header so that we know that we are either doing an update or insert?
Re: Save to URL - REST Interface?
Posted: Tue May 11, 2010 11:25 am
by sorin_ristache
Hello,
The WebDAV client of Oxygen does not use the POST method because this method is not used by the WebDAV protocol. If you need POST you will have to implement an
Oxygen plugin for your own custom protocol (for example rest:// or myHttp:// or russProto:// etc). It should be a
Java protocol handler (implementation of java.net.URLStreamHandler) with a
java.net.URLConnection implementation that connects to your HTTP server when asked to provide the input stream and output stream of a URL. Oxygen will get these input stream and output stream from the URL handler when a URL prefixed with the custom protocol is opened or saved in Oxygen.
Regards,
Sorin