Dan, Thanks for this detailed sample. I enabled the log categories as in your email, and I can see my request is indeed a GET. I tried your sample and I get a POST with it. So it seems the problem is in my code.
BTW, if I use getRequestMethod() on the connection in your example (after the setRequestMethod call), I get GET, but from the logs POST seems to be used instead. I was not able to create a simple example, but I can package a little subset of the relevant sources if I can send them privately. Regards, -- Florent Georges http://www.fgeorges.org/ Dan Caprioara wrote: > Oxygen uses the Apache http client to read/write from WebDAV HTTP > servers. For this, a new implementation of the HTTPURLConnection > wraps > the Apache http client. Normally, the PUT method is used for storing > data on the servers and GET to retrieve it, but the POST method is > also > supported. > > This is how I tried to reproduce your problem, but without success: > > First of all, I have enabled the http logging. For this, I have > created > a log4j.properties file in the oXygen installation directory, with > the > following content: > > log4j.rootCategory= info, R > log4j.category.org.apache.commons=debug > log4j.category.httpclient=debug > # R is the standard output > log4j.appender.R=org.apache.log4j.ConsoleAppender > log4j.appender.R.layout=org.apache.log4j.PatternLayout > log4j.appender.R.layout.ConversionPattern=%r %p [ %t ] %c - %m%n > > I have then started oXygen using the startup scripts available in the > > installation directory. > > I have compiled the following java class, and added it as an > extension > to the transformation scenario. I have then tested with both Saxon B > and > Saxon 6.5: > > import java.io.InputStream; > import java.io.OutputStream; > import java.net.HttpURLConnection; > import java.net.URL; > > public class SaxonExtension { > > public static String post() { > try { > URL url = new URL("http://www.sync.ro/"); > HttpURLConnection conn = > (HttpURLConnection)url.openConnection(); > conn.setRequestMethod("POST"); > conn.connect(); > OutputStream os = conn.getOutputStream(); > os.write("some_parameter".getBytes()); > os.close(); > InputStream is = conn.getInputStream(); > int r = is.read(); > StringBuffer buf = new StringBuffer(); > while(r != -1) { > buf.append((char)r); > r = is.read(); > } > is.close(); > return buf.toString(); > } catch (Exception e) { > return e.toString(); > } > } > } > > > The following lines were written in the log: > > - >> "POST http://www.sync.ro/ HTTP/1.1[\r][\n]" > - >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]" > - >> "Host: www.sync.ro[\r][\n]" > - >> "Proxy-Connection: Keep-Alive[\r][\n]" > - >> "Content-Length: 6[\r][\n]" > - >> "[\r][\n]" > - >> "some_parameter" > > > Please send to support the log you obtain and eventually a Java > sample > showing the problem. > > As a workaround, you could create directly a > sun.net.www.protocol.http.HttpURLConnection object. > > Happy New Year! > Dan Caprioara > > > > Florent Georges wrote: > > Hi, > > > > Best wishes to the oXygen team and users. > > > > I have a Saxon extension in Java, that opens an HTTP connection > from > > a URL and set the HTTP method on it to POST: > > > > URL url = ...; > > HttpURLConnection conn = (HttpURLConnection) > url.openConnection(); > > conn.setRequestMethod("POST"); > > > > Unfortunately, the method is always GET, and there is no > exception > > raised in that code. I must admit it took a while to find the > cause. > > The code works well outside oXygen, and the object 'conn' is > actually > > of type ro.sync.net.protocol.http.WebdavHttpURLConnection when the > > transform is launched from within oXygen. > > > > Is it because of a bug in this class? Is there any way to work > > around this one? Outside of oXygen, in a standalone Sun JVM, the > > class is sun.net.www.protocol.http.HttpURLConnection, for what is > > worth noting... > > > > Un an nou fericit! > > > > > _______________________________________________ oXygen-user mailing list [email protected] http://www.oxygenxml.com/mailman/listinfo/oxygen-user
