Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_java2b_20250412
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
alx_java2b_20250412
Commits
c30e795b
Commit
c30e795b
authored
May 11, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
programy klienckie w wersji asynchronicznej
parent
14683884
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
150 additions
and
4 deletions
+150
-4
async-binding.xml
PC25-KlientSoap/async-binding.xml
+13
-0
notatki.txt
PC25-KlientSoap/notatki.txt
+8
-0
DBException_Exception.java
.../src/main/java/sklep/generated/DBException_Exception.java
+1
-1
RecordNotFound_Exception.java
...c/main/java/sklep/generated/RecordNotFound_Exception.java
+1
-1
Sklep.java
PC25-KlientSoap/src/main/java/sklep/generated/Sklep.java
+28
-1
SklepService.java
...lientSoap/src/main/java/sklep/generated/SklepService.java
+1
-1
Klient4_Async.java
...-KlientSoap/src/main/java/sklep/klient/Klient4_Async.java
+42
-0
Klient5_AsyncHandler.java
...Soap/src/main/java/sklep/klient/Klient5_AsyncHandler.java
+56
-0
No files found.
PC25-KlientSoap/async-binding.xml
0 → 100644
View file @
c30e795b
<bindings
xmlns:wsdl=
"http://schemas.xmlsoap.org/wsdl/"
xmlns=
"https://jakarta.ee/xml/ns/jaxws"
>
<bindings
node=
"wsdl:portType[@name='Sklep']/wsdl:operation[@name='readProductsByPrice']"
>
<enableAsyncMapping>
true
</enableAsyncMapping>
</bindings>
<!-- wersja obejmująca wszystkie operacje:
<bindings node="wsdl:portType[@name='Sklep']/wsdl:operation">
<enableAsyncMapping>true</enableAsyncMapping>
</bindings>
-->
</bindings>
PC25-KlientSoap/notatki.txt
View file @
c30e795b
...
@@ -17,3 +17,11 @@ wersja Linux:
...
@@ -17,3 +17,11 @@ wersja Linux:
wersja Windows - przykładowo:
wersja Windows - przykładowo:
C:\Tools\wildfly-35.0.1.Final\bin\wsconsume.bat -k -n -s src\main\java -p sklep.generated "http://localhost:8080/PC25-SoapSerwer/Sklep?wsdl"
C:\Tools\wildfly-35.0.1.Final\bin\wsconsume.bat -k -n -s src\main\java -p sklep.generated "http://localhost:8080/PC25-SoapSerwer/Sklep?wsdl"
Dodatkowe opcje dla tego generowania można opisać w pliku (tuaj async-binding.xml)
zgodnym ze schemą
https://jakarta.ee/xml/ns/jaxws/wsdl_customizationschema_3_0.xsd
i wskazać ten plik z opcją -b
/opt/java/wildfly-35.0.1.Final/bin/wsconsume.sh -k -n -s src/main/java -b async-binding.xml -p sklep.generated "http://localhost:8080/PC24-SklepSoap/Sklep?wsdl"
PC25-KlientSoap/src/main/java/sklep/generated/DBException_Exception.java
View file @
c30e795b
...
@@ -6,7 +6,7 @@ import jakarta.xml.ws.WebFault;
...
@@ -6,7 +6,7 @@ import jakarta.xml.ws.WebFault;
/**
/**
* This class was generated by Apache CXF 4.0.6
* This class was generated by Apache CXF 4.0.6
* 2025-05-1
0T16:48:10.040
+02:00
* 2025-05-1
1T10:17:25.006
+02:00
* Generated source version: 4.0.6
* Generated source version: 4.0.6
*/
*/
...
...
PC25-KlientSoap/src/main/java/sklep/generated/RecordNotFound_Exception.java
View file @
c30e795b
...
@@ -6,7 +6,7 @@ import jakarta.xml.ws.WebFault;
...
@@ -6,7 +6,7 @@ import jakarta.xml.ws.WebFault;
/**
/**
* This class was generated by Apache CXF 4.0.6
* This class was generated by Apache CXF 4.0.6
* 2025-05-1
0T16:48:09.949
+02:00
* 2025-05-1
1T10:17:24.930
+02:00
* Generated source version: 4.0.6
* Generated source version: 4.0.6
*/
*/
...
...
PC25-KlientSoap/src/main/java/sklep/generated/Sklep.java
View file @
c30e795b
...
@@ -5,12 +5,15 @@ import jakarta.jws.WebParam;
...
@@ -5,12 +5,15 @@ import jakarta.jws.WebParam;
import
jakarta.jws.WebResult
;
import
jakarta.jws.WebResult
;
import
jakarta.jws.WebService
;
import
jakarta.jws.WebService
;
import
jakarta.xml.bind.annotation.XmlSeeAlso
;
import
jakarta.xml.bind.annotation.XmlSeeAlso
;
import
jakarta.xml.ws.AsyncHandler
;
import
jakarta.xml.ws.RequestWrapper
;
import
jakarta.xml.ws.RequestWrapper
;
import
jakarta.xml.ws.Response
;
import
jakarta.xml.ws.ResponseWrapper
;
import
jakarta.xml.ws.ResponseWrapper
;
import
java.util.concurrent.Future
;
/**
/**
* This class was generated by Apache CXF 4.0.6
* This class was generated by Apache CXF 4.0.6
* 2025-05-1
0T16:48:10.059
+02:00
* 2025-05-1
1T10:17:25.033
+02:00
* Generated source version: 4.0.6
* Generated source version: 4.0.6
*
*
*/
*/
...
@@ -59,6 +62,30 @@ public interface Sklep {
...
@@ -59,6 +62,30 @@ public interface Sklep {
int
id
int
id
)
throws
RecordNotFound_Exception
,
DBException_Exception
;
)
throws
RecordNotFound_Exception
,
DBException_Exception
;
@WebMethod
(
operationName
=
"readProductsByPrice"
)
@RequestWrapper
(
localName
=
"readProductsByPrice"
,
targetNamespace
=
"http://soap.sklep/"
,
className
=
"sklep.generated.ReadProductsByPrice"
)
@ResponseWrapper
(
localName
=
"readProductsByPriceResponse"
,
targetNamespace
=
"http://soap.sklep/"
,
className
=
"sklep.generated.ReadProductsByPriceResponse"
)
public
Response
<
sklep
.
generated
.
ReadProductsByPriceResponse
>
readProductsByPriceAsync
(
@WebParam
(
name
=
"min"
,
targetNamespace
=
""
)
java
.
math
.
BigDecimal
min
,
@WebParam
(
name
=
"max"
,
targetNamespace
=
""
)
java
.
math
.
BigDecimal
max
);
@WebMethod
(
operationName
=
"readProductsByPrice"
)
@ResponseWrapper
(
localName
=
"readProductsByPriceResponse"
,
targetNamespace
=
"http://soap.sklep/"
,
className
=
"sklep.generated.ReadProductsByPriceResponse"
)
@RequestWrapper
(
localName
=
"readProductsByPrice"
,
targetNamespace
=
"http://soap.sklep/"
,
className
=
"sklep.generated.ReadProductsByPrice"
)
public
Future
<?>
readProductsByPriceAsync
(
@WebParam
(
name
=
"min"
,
targetNamespace
=
""
)
java
.
math
.
BigDecimal
min
,
@WebParam
(
name
=
"max"
,
targetNamespace
=
""
)
java
.
math
.
BigDecimal
max
,
@WebParam
(
name
=
"asyncHandler"
,
targetNamespace
=
""
)
AsyncHandler
<
sklep
.
generated
.
ReadProductsByPriceResponse
>
asyncHandler
);
@WebMethod
@WebMethod
@RequestWrapper
(
localName
=
"readProductsByPrice"
,
targetNamespace
=
"http://soap.sklep/"
,
className
=
"sklep.generated.ReadProductsByPrice"
)
@RequestWrapper
(
localName
=
"readProductsByPrice"
,
targetNamespace
=
"http://soap.sklep/"
,
className
=
"sklep.generated.ReadProductsByPrice"
)
@ResponseWrapper
(
localName
=
"readProductsByPriceResponse"
,
targetNamespace
=
"http://soap.sklep/"
,
className
=
"sklep.generated.ReadProductsByPriceResponse"
)
@ResponseWrapper
(
localName
=
"readProductsByPriceResponse"
,
targetNamespace
=
"http://soap.sklep/"
,
className
=
"sklep.generated.ReadProductsByPriceResponse"
)
...
...
PC25-KlientSoap/src/main/java/sklep/generated/SklepService.java
View file @
c30e795b
...
@@ -11,7 +11,7 @@ import jakarta.xml.ws.Service;
...
@@ -11,7 +11,7 @@ import jakarta.xml.ws.Service;
/**
/**
* This class was generated by Apache CXF 4.0.6
* This class was generated by Apache CXF 4.0.6
* 2025-05-1
0T16:48:10.098
+02:00
* 2025-05-1
1T10:17:25.066
+02:00
* Generated source version: 4.0.6
* Generated source version: 4.0.6
*
*
*/
*/
...
...
PC25-KlientSoap/src/main/java/sklep/klient/Klient4_Async.java
0 → 100644
View file @
c30e795b
package
sklep
.
klient
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
jakarta.xml.ws.Response
;
import
sklep.generated.Product
;
import
sklep.generated.ReadProductsByPriceResponse
;
import
sklep.generated.Sklep
;
import
sklep.generated.SklepService
;
public
class
Klient4_Async
{
public
static
void
main
(
String
[]
args
)
{
BigDecimal
min
=
BigDecimal
.
valueOf
(
2000
);
BigDecimal
max
=
BigDecimal
.
valueOf
(
3000
);
System
.
out
.
println
(
"Początek programu"
);
SklepService
service
=
new
SklepService
();
Sklep
sklep
=
service
.
getSklepPort
();
System
.
out
.
println
(
"Klient gotowy do pracy"
);
try
{
System
.
out
.
println
(
"Wysyłam zapytanie"
);
Response
<
ReadProductsByPriceResponse
>
response
=
sklep
.
readProductsByPriceAsync
(
min
,
max
);
System
.
out
.
println
(
"Wysłałem zapytanie i mam obiekt reponse: "
+
response
);
// strategia odpytywania:
while
(!
response
.
isDone
())
{
System
.
out
.
println
(
"czekam na wynik"
);
Thread
.
sleep
(
10
);
}
List
<
Product
>
products
=
response
.
get
().
getProduct
();
for
(
Product
product
:
products
)
{
System
.
out
.
println
(
product
.
getProductName
()
+
" za "
+
product
.
getPrice
());
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Błąd: "
+
e
);
}
System
.
out
.
println
(
"Koniec programu"
);
}
}
PC25-KlientSoap/src/main/java/sklep/klient/Klient5_AsyncHandler.java
0 → 100644
View file @
c30e795b
package
sklep
.
klient
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Future
;
import
jakarta.xml.ws.Response
;
import
sklep.generated.Product
;
import
sklep.generated.ReadProductsByPriceResponse
;
import
sklep.generated.Sklep
;
import
sklep.generated.SklepService
;
public
class
Klient5_AsyncHandler
{
public
static
void
main
(
String
[]
args
)
{
BigDecimal
min
=
BigDecimal
.
valueOf
(
2000
);
BigDecimal
max
=
BigDecimal
.
valueOf
(
3000
);
System
.
out
.
println
(
"Początek programu"
);
SklepService
service
=
new
SklepService
();
Sklep
sklep
=
service
.
getSklepPort
();
System
.
out
.
println
(
"Klient gotowy do pracy"
);
System
.
out
.
println
(
"Wysyłam zapytanie"
);
// jako ostatni parametr przekazujemy AsyncHandler określając, co zrobić po otrzymaniu wyniku
// Od Javy 8 najłatwiej przekazać to w formie wyrażenia lambda
// ten kod wykona się w innym wątku po zakończeniu zadania
Future
<?>
future
=
sklep
.
readProductsByPriceAsync
(
min
,
max
,
response
->
{
try
{
List
<
Product
>
products
=
response
.
get
().
getProduct
();
for
(
Product
product
:
products
)
{
System
.
out
.
println
(
product
.
getProductName
()
+
" za "
+
product
.
getPrice
());
}
}
catch
(
InterruptedException
e
)
{
System
.
out
.
println
(
"interrupted"
);
}
catch
(
ExecutionException
e
)
{
System
.
out
.
println
(
"Błąd w wykonaniu: "
+
e
);
}
});
for
(
int
i
=
1
;
i
<=
50
;
i
++)
{
System
.
out
.
println
(
"lalala, robię coś inngo"
);
}
System
.
out
.
println
(
"teraz poczekam na koniec zlecenia"
);
try
{
future
.
get
();
Thread
.
sleep
(
100
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"Koniec main"
);
}
}
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