include::../shared-doc/attributes.adoc[]

= resteasy-jaxrs-client: External JAX-RS Client
:author: Blaine Mincey
:level: Intermediate
:technologies: JAX-RS, CDI
:prerequisites: link:helloworld-rs/README{outfilesuffix}[helloworld-rs]

[abstract]
The `resteasy-jaxrs-client` quickstart demonstrates an external JAX-RS RestEasy client, which interacts with a JAX-RS Web service that uses CDI and JAX-RS.

:standalone-server-type: default
:archiveType: war

== What is it?

The `resteasy-jaxrs-client` quickstart demonstrates an external JAX-RS RestEasy client which interacts with a JAX-RS Web service that uses CDI and JAX-RS in {productNameFull}.

This client "calls" the HelloWorld JAX-RS Web Service that was created in the link:../helloworld-rs/README.adoc[helloworld-rs] quickstart. See the *Prerequisite* section below for details on how to build and deploy the link:../helloworld-rs/README.adoc[helloworld-rs] quickstart.

// System Requirements
include::../shared-doc/system-requirements.adoc[leveloffset=+1]
// Start the {productName} Standalone Server
include::../shared-doc/start-the-standalone-server.adoc[leveloffset=+1]

[[prerequisites]]
== Prerequisites

IMPORTANT: This quickstart depends on the deployment of the `helloworld-rs` quickstart for its test. Before running this quickstart, see the link:../helloworld-rs/README.adoc[helloworld-rs] README file for details on how to deploy it.

You can verify the deployment of the link:../helloworld-rs/README.adoc[helloworld-rs] quickstart by accessing the following content:

* The XML content can be viewed by accessing the following URL: http://localhost:8080/helloworld-rs/rest/xml
* The JSON content can be viewed by accessing this URL: http://localhost:8080/helloworld-rs/rest/json

== Run the Client

. xref:start_the_eap_standalone_server[Start the {productName} server with the standalone default profile] as described above.
. Make sure the `helloworld-rs` quickstart has been deployed on the server as noted in the xref:prerequisites[Prerequisites] section above.
. Open a terminal and navigate to the root directory of this quickstart.
. Type the following command to run the client:
+
[source,options="nowrap"]
----
$ mvn clean package exec:java
----

== Investigate the Console Output

This command will compile the example and execute a test to make two separate requests to the Web Service. Towards the end of the Maven build output, you
should see the following if the execution is successful:

[source,options="nowrap"]
----
===============================================
URL: http://localhost:8080/helloworld-rs/rest/xml
MediaType: application/xml

*** Response from Server ***

<xml><result>Hello World!</result></xml>

===============================================
===============================================
URL: http://localhost:8080/helloworld-rs/rest/json
MediaType: application/json

*** Response from Server ***

{"result":"Hello World!"}
===============================================
----

// Run the Quickstart in Red Hat Developer Studio or Eclipse
include::../shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc[leveloffset=+1]

// Additional Red Hat Developer Studio instructions
. Before you run this quickstart, make sure you import, deploy, and test the `helloworld-rs` quickstart as described in the xref:prerequisites[Prerequisites] section of this file.

. Import this quickstart into {JBDSProductName}.

. Build and run the quickstart project.

** Right-click on the *{artifactId}* project and choose *Run As* –> *Maven build*.
** Enter *clean package exec:java* for the *Goals* and click *Run*.
** The client output displays in the *Console* window.
. To undeploy the `helloworld-rs` quickstart, right-click on the *helloworld-rs* project and choose *Run As* –> *Maven build*. Enter *wildfly:undeploy* for the *Goals* and click *Run*.
