Code Monkey home page Code Monkey logo

webserviceshell's Introduction

WebServiceShell (WSS)

Documentation

Introduction

The Web Service Shell (WSS) is a web service that can be configured via simple properties files to utilize external resources (either command-line programs or Java classes) to fulfill web service requests.

Goals

WSS was written with the goal of removing the barriers to creating a modern web service (under certain constraints) for delivering data. It allows command line, *nix-based, programs to be executed from a pre-written Java servlet. Moreover, WSS can be configured via properties files to execute any command line program (or script) conforming to its requirements.

WSS provides basic request parameter validation as well as HTTP authentication (via the servlet container). It also provides usage logging, operational logging, and various other mundane functions required of an HTTP server.

The WSS can also be configured to use a Java class rather than a command line program to fulfill the data retrieval. More details about using Java classes with the WSS can be found in the developer notes

webserviceshell's People

Contributors

mike-iris avatar yazan-iris avatar crotwell avatar mickvf avatar dependabot[bot] avatar

Stargazers

Cuda Chen avatar sssfeather avatar

Watchers

James Cloos avatar Chad Trabant avatar Nick Falco avatar

webserviceshell's Issues

Can formatTypes be extended to have a CSV type?

I am confused if the formatTypes are restricted to those in the list defined in the documentation, namely the ones included below. Is it possible to add a type of CSV?

When i put format=csv and have a handler that returns CSV data for our web service, the browser barfs with the error shown below:

This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.

even if I map CSV to text/plain the browser doesn't recognize the return from the WSS. Do I need to spoof the return of csv files somehow so they are sent to files instead? If so, how do I manage that with the WSS and my handler?

Note that my web service if used with wget or curl returns the CSV files just fine and if in the browser I say "View Source" on the given page, I see the CSV. There is something in the return headers that just isn't working for the browser to see it or send it to a file. What am I missing.

I currently have the following settings in my service.cfg file:

formatTypes - specifies a list of "formatType: mediaType" pairs

query.formatTypes =
xml: application/xml,
csv: text/plain,
text: text/plain,
json: application/json

Content-Disposition overrides for respective media types "text" and "miniseed"

#query.formatDispositions= \

text: inline; filename="mypart_${appName}_${UTC}.txt", \

miniseed: attachment; filename="a_miniseed_file.mseed"

query.formatDispositions=
text: attachment; filename="${appName}${UTC}.csv",
csv: attachment; filename="${appName}
${UTC}.csv",
zip: attachment; filename="data.zip"

List of "allowed?" format types extracted from HandlerRequirements.md write up:
formatType Media type
xml application/xml
mseed application/vnd.fdsn.mseed
text text/plain
texttree text/plain
json application/json
binary application/octet-stream

Type returned from fdsn event labeled as miniseed when it is actually QuakeML

I am trying to set up an event service using webserviceshell v. 2.4.9. I have followed the instructions in https://github.com/iris-edu/webserviceshell/blob/master/docs/Installation.md.
FYI, instead of using the directory /WSSHOME/, I have used /tomcat/. So the path is /tomcat/tomcat. I am also using port 8880. I have replaced the dataselect with event in the file names.

First I brought up http://silverdragon.isti.com:8880/fdsnws/event/1/query?eventid=70051933 and I was getting the following error: Error 400: doIrisProcessing - No type defined or unknown query parameter: eventid
http://silverdragon.isti.com:8880/fdsnws/event/1/query?eventid=70051933

I then set the relaxedValidation parameter in the service config file:
query.relaxedValidation=true
This took care of the Error 400, but now I am getting the file coming back from the fdsn event labeled as a miniseed file downloaded to my PC. When looking at the file as text, the file is in the correct format as a QuakeML file.

It looks like the formatTypes parameter is set correctly in the service config file:
application.wadl.formatTypes =
xml: application/xml

For some reason that is being ignored and all are coming back as mseed. I am not sure if there is some default. Even when I give it the additional argument format=xml, it still comes back as .mseed

Something is not correct in the formatTypes setting since it is being ignored.

I have attached the mseed file:
mseed.zip

I have attached the service config file:
service.cfg.zip

Origina client IP lost when webserviceshell lays behind haproxy

Hello,

I moved our webserviceshell instance (serving http://ws.resif.fr/fdnsws/dataselect/1and https://ws.resif.fr/fdsnws/station/1/) from a monotlythic deployment into a kubernetes cluster.

From there on, the IPADDRESS environment variabled passed to the CmdProcessor shows the haproxy address.

From the codebase, I see:

processBuilder.environment().put("IPADDRESS", WebUtils.getClientIp(ri.request));

and then :

private static String getXForwardIp(HttpServletRequest request) {
Enumeration<String> headers = request.getHeaders("x-forwarded-for");
if (headers == null) {
return null;
}

I'm not familiar with Java, but would it be possible to take also into account the HTTP headers x-original-forwarded-for in order to set up the real client IP in IPADDRESS ?

dmc_logging and dmc-usage-log

These two dependencies are not resolvable. Makes it hard to build externally, which makes it harder to submit patches or to compile code that depends on webserviceshell.

        <dependency>
            <groupId>edu.iris.dmc</groupId>
            <artifactId>dmc-usage-log</artifactId>
            <version>${dmc.usage.log.version}</version>
        </dependency>

        <dependency>
            <groupId>edu.iris</groupId>
            <artifactId>dmc_logging</artifactId>
            <version>${dmc_logging.version}</version>
        </dependency>

Per Rob Casey:

Hi Philip-

I've never attempted to build this one myself, but for our internal code, we have an IRIS (Sonatype) >Nexus server that may be picking up on those dependencies you are running into. It wasn't meant to be >built outside of the DMC.

dmc-usage-log and dmc_logging are internal dependencies. I am not sure why they are listed in the >POM, but since this code is distributed for external builds, are they simply ignored unless called for by the >application?

If you can find a way to strip out those dependencies from the code I shared with you, it should be fine.
There are some things that we specifically will not share with the public. The WSS is meant for public use,
though, so I find it interesting that you are running into this problem.

-Rob

support for modern Java

It seems to me that webserviceshell only supports Java 8. Are there any plans to support more recent versions of Java?

service.cfg file parses incorrectly if a space occurs after a continuation backslash

Preliminary investigation shows that Java's Properties load method handles a space after a backslash as a new line rather than a continuation. As might be expected, this leads to a property object that has unexpected, strangely named properties as well as list items missing from the original desired list. Also, the resulting property object may be mostly intact, depending where the extra space occurs, leading to difficult to diagnose errors.

The probably solution is probably to preprocess the service.cfg file and remove any characters after the \ and before the end of line.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.