Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_20230801
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_20230801
Commits
59970b7b
Commit
59970b7b
authored
Aug 03, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Klient Dispatcher
parent
d8fdb78d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
Klient4_DispatcherZahardkodowany.java
...ient_niskopoziomowy/Klient4_DispatcherZahardkodowany.java
+34
-0
Utils.java
...src/main/java/ogloszenia/klient_niskopoziomowy/Utils.java
+19
-0
No files found.
OgloszeniaKlient/src/main/java/ogloszenia/klient_niskopoziomowy/Klient4_DispatcherZahardkodowany.java
0 → 100644
View file @
59970b7b
package
ogloszenia
.
klient_niskopoziomowy
;
import
jakarta.xml.ws.Dispatch
;
import
jakarta.xml.ws.Service
;
import
ogloszenia.generated.OgloszeniaService
;
import
javax.xml.namespace.QName
;
import
javax.xml.transform.Source
;
import
javax.xml.transform.stream.StreamSource
;
import
java.io.StringReader
;
public
class
Klient4_DispatcherZahardkodowany
{
static
final
String
trescXML
=
"""
<o:readOne xmlns:o="
http:
//soap.ogloszenia/">
<
id
>
1
</
id
>
</
o:
readOne
>
""";
public static void main(String[] args) {
System.out.println("
Startujemy
...
");
OgloszeniaService service = new OgloszeniaService();
QName portName = OgloszeniaService.OgloszeniaPort;
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
System.out.println("
Mam
Dispatchera
" + dispatch);
Source src = new StreamSource(new StringReader(trescXML));
System.out.println("
Wysy
ł
am
zapytanie
");
Source result = dispatch.invoke(src);
System.out.println("
Mam
wynik:
" + result);
Utils utils = new Utils();
utils.wypiszTransformerem(result);
System.out.println("
Gotowe
"
);
}
}
OgloszeniaKlient/src/main/java/ogloszenia/klient_niskopoziomowy/Utils.java
0 → 100644
View file @
59970b7b
package
ogloszenia
.
klient_niskopoziomowy
;
import
javax.xml.transform.*
;
import
javax.xml.transform.stream.StreamResult
;
public
class
Utils
{
private
TransformerFactory
tf
=
TransformerFactory
.
newInstance
();
public
void
wypiszTransformerem
(
Source
src
)
{
try
{
Transformer
transformer
=
tf
.
newTransformer
();
transformer
.
setOutputProperty
(
OutputKeys
.
INDENT
,
"yes"
);
StreamResult
res
=
new
StreamResult
(
System
.
out
);
transformer
.
transform
(
src
,
res
);
}
catch
(
TransformerException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
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