Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20230403
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
20230403
Commits
41a0b40d
Commit
41a0b40d
authored
May 26, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Klient REST JAXB
parent
99310bb9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
pom.xml
PC34-RestKlient/pom.xml
+5
-0
P07_RestClient_JAXB.java
.../src/main/java/sklep/klient_rest/P07_RestClient_JAXB.java
+32
-0
No files found.
PC34-RestKlient/pom.xml
View file @
41a0b40d
...
...
@@ -38,5 +38,10 @@
<artifactId>
resteasy-client
</artifactId>
<version>
6.2.4.Final
</version>
</dependency>
<dependency>
<groupId>
org.jboss.resteasy
</groupId>
<artifactId>
resteasy-jaxb-provider
</artifactId>
<version>
6.2.4.Final
</version>
</dependency>
</dependencies>
</project>
PC34-RestKlient/src/main/java/sklep/klient_rest/P07_RestClient_JAXB.java
0 → 100644
View file @
41a0b40d
package
sklep
.
klient_rest
;
import
jakarta.ws.rs.client.Client
;
import
jakarta.ws.rs.client.ClientBuilder
;
import
jakarta.ws.rs.core.Response
;
import
sklep.model.Product
;
import
sklep.model.ProductList
;
public
class
P07_RestClient_JAXB
{
public
static
void
main
(
String
[]
args
)
{
Client
client
=
ClientBuilder
.
newClient
();
Response
response
=
client
.
target
(
Ustawienia
.
ADRES_USLUGI
)
.
path
(
"products.xml"
)
.
request
().
buildGet
()
.
invoke
();
System
.
out
.
println
(
"Mam odpowiedź: "
+
response
);
System
.
out
.
println
(
"Status: "
+
response
.
getStatus
());
System
.
out
.
println
(
"C-Type: "
+
response
.
getMediaType
());
System
.
out
.
println
(
"Length: "
+
response
.
getLength
());
ProductList
products
=
response
.
readEntity
(
ProductList
.
class
);
System
.
out
.
println
(
"Otrzymane dane:"
);
for
(
Product
product
:
products
.
getProducts
())
{
System
.
out
.
println
(
product
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment