Thread: Problem in Java-WS library WaveformService stream method

Started: 2014-09-05 18:36:44
Last activity: 2014-09-05 18:36:44
Topics: Web Services
Hello,

there seems to be a bug in the WaveformService stream method.

Extending the waveform reading example from the tutorial to save the
response in a miniseed file results in a NullPointerException:

WaveformService waveFormService = serviceUtil.getWaveformService();
WaveformCriteria criteria = new WaveformCriteria();
criteria.add(network, station, location, channel, startDate, endDate);
FileOutputStream os = new FileOutputStream("test.mseed");
waveFormService.stream(os, criteria);
os.close();

The attached diff fixes the problem. However it looks like there is
unnecessary code duplication in the library. A preferable solution
IMHO would be to merge the methods fetch and stream.

Best Regards,
Benjamin Sick

--
Dipl.-Ing. Benjamin Sick
Institut für Geophysik
Universität Stuttgart

Email: benjamin.sick<at>geophys.uni-stuttgart.de
Website: http://www.geophys.uni-stuttgart.de/mitarbeiter/sick_benjamin.html
Phone: +49 711 685-87422
Fax: +49 711 685-87401
Index: WaveformService.java
===================================================================
--- WaveformService.java (Revision 3895)
+++ WaveformService.java (Arbeitskopie)
@@ -332,11 +332,21 @@
HttpURLConnection connection = null;
InputStream inputStream = null;
try {
- connection = this.getConnection(new URL(this.baseUrl));
+ URL url = null;
+ if (this.authenticate) {
+ url = new URL(baseUrl + "queryauth");
+ } else {
+ url = new URL(baseUrl + "query");
+ }
+ connection = this.getConnection(url);

connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
+ connection.setRequestMethod("POST");
connection.setDoOutput(true);
+ connection.setDoInput(true);
+ connection.setUseCaches(false);
+ connection.setAllowUserInteraction(false);
connection.connect();

OutputStream outputStream = connection.getOutputStream();

  • Thank you Benjamin for the report. We will be releasing a new version very soon (early next week) and will address this bug for sure. Yazan



    On Sep 5, 2014, at 2:36 AM, Benjamin Sick <benjamin.sick<at>geophys.uni-stuttgart.de> wrote:

    Hello,

    there seems to be a bug in the WaveformService stream method.

    Extending the waveform reading example from the tutorial to save the
    response in a miniseed file results in a NullPointerException:

    WaveformService waveFormService = serviceUtil.getWaveformService();
    WaveformCriteria criteria = new WaveformCriteria();
    criteria.add(network, station, location, channel, startDate, endDate);
    FileOutputStream os = new FileOutputStream("test.mseed");
    waveFormService.stream(os, criteria);
    os.close();

    The attached diff fixes the problem. However it looks like there is
    unnecessary code duplication in the library. A preferable solution
    IMHO would be to merge the methods fetch and stream.

    Best Regards,
    Benjamin Sick

    --
    Dipl.-Ing. Benjamin Sick
    Institut für Geophysik
    Universität Stuttgart

    Email: benjamin.sick<at>geophys.uni-stuttgart.de
    Website: http://www.geophys.uni-stuttgart.de/mitarbeiter/sick_benjamin.html
    Phone: +49 711 685-87422
    Fax: +49 711 685-87401
    <iris_java_ws_waveformservice_fix.diff>_______________________________________________
    webservices mailing list
    webservices<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/webservices



11:42:26 v.b3198453