Skip to content

Instantly share code, notes, and snippets.

@0xdevalias
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xdevalias/288dce6b353f2a72a7d4 to your computer and use it in GitHub Desktop.
Save 0xdevalias/288dce6b353f2a72a7d4 to your computer and use it in GitHub Desktop.
Because I couldn't find it easily on the net, simple notes on how to access Play Framework's seperated WS library

(Blog Post: http://blog.devalias.net/post/89810672067/play-framework-seperated-ws-library)

http://www.playframework.com/documentation/2.3.x/Highlights23

Play WS

Separate library

The WS client library has been refactored into its own library which can be used outside of Play. You can now have multiple WSClient objects, rather than only using the WS singleton.

Repositories

Maven:

<dependencies>
		<dependency>
			<groupId>com.typesafe.play</groupId>
			<artifactId>play-java-ws_2.10</artifactId>
			<version>2.3.0</version>
		</dependency>
	</dependencies>
	
	<repositories>
		<repository>
			<id>Typesafe Releases</id>
			<url>http://repo.typesafe.com/typesafe/releases/</url>
		</repository>
	</repositories>

There are also other options:

play-java-ws_2.10
play-java-ws_2.11
play-ws_2.10
play-ws_2.11

"There is no started application"

If you end up getting a "There is no started application" message when you try to use WS, you will need to do something like the following:

AsyncHttpClientConfig.Builder builder = new com.ning.http.client.AsyncHttpClientConfig.Builder();
NingWSClient wsClient = new play.libs.ws.ning.NingWSClient(builder.build());

// Instead of this
//WSRequestHolder ws = WS.url(url)

// Use this
WSRequestHolder ws = wsClient.url(url)

See the following for more details:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment