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
ba401de1
Commit
ba401de1
authored
Aug 04, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Klient8_Dispatch_SoapMessage
parent
bb3f718c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
Klient8_Dispatch_SoapMessage.java
...a/klient_niskopoziomowy/Klient8_Dispatch_SoapMessage.java
+57
-0
No files found.
OgloszeniaKlient/src/main/java/ogloszenia/klient_niskopoziomowy/Klient8_Dispatch_SoapMessage.java
0 → 100644
View file @
ba401de1
package
ogloszenia
.
klient_niskopoziomowy
;
import
jakarta.xml.soap.*
;
import
jakarta.xml.ws.Dispatch
;
import
jakarta.xml.ws.Service
;
import
org.w3c.dom.NodeList
;
import
javax.xml.XMLConstants
;
import
javax.xml.namespace.QName
;
import
javax.xml.transform.Source
;
import
javax.xml.transform.stream.StreamSource
;
import
java.io.IOException
;
import
java.io.StringReader
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
public
class
Klient8_Dispatch_SoapMessage
{
public
static
final
String
NS_URI
=
"http://soap.ogloszenia/"
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Startujemy..."
);
int
szukaneId
=
3
;
try
{
URL
wsdlUrl
=
new
URL
(
"http://localhost:8080/OgloszeniaSerwer/Ogloszenia?wsdl"
);
QName
serviceName
=
new
QName
(
NS_URI
,
"OgloszeniaService"
);
QName
portName
=
new
QName
(
NS_URI
,
"OgloszeniaPort"
);
MessageFactory
mf
=
MessageFactory
.
newInstance
();
Service
service
=
Service
.
create
(
wsdlUrl
,
serviceName
);
Dispatch
<
SOAPMessage
>
dispatch
=
service
.
createDispatch
(
portName
,
SOAPMessage
.
class
,
Service
.
Mode
.
MESSAGE
);
System
.
out
.
println
(
"Mam Dispatchera "
+
dispatch
);
SOAPMessage
request
=
mf
.
createMessage
();
SOAPBody
requestBody
=
request
.
getSOAPBody
();
SOAPBodyElement
readOne
=
requestBody
.
addBodyElement
(
new
QName
(
NS_URI
,
"readOne"
,
"o"
));
SOAPElement
parametr
=
readOne
.
addChildElement
(
new
QName
(
"id"
));
parametr
.
setTextContent
(
String
.
valueOf
(
szukaneId
));
request
.
writeTo
(
System
.
out
);
System
.
out
.
println
(
"\n\nWysyłam zapytanie"
);
SOAPMessage
result
=
dispatch
.
invoke
(
request
);
System
.
out
.
println
(
"Mam wynik: "
+
result
);
result
.
writeTo
(
System
.
out
);
SOAPBody
resultBody
=
result
.
getSOAPBody
();
NodeList
znalezione
=
resultBody
.
getElementsByTagNameNS
(
XMLConstants
.
NULL_NS_URI
,
"cena"
);
if
(
znalezione
.
getLength
()
>
0
)
{
System
.
out
.
println
(
"\n\nCena: "
+
znalezione
.
item
(
0
).
getTextContent
());
}
System
.
out
.
println
(
"Gotowe"
);
}
catch
(
SOAPException
|
IOException
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