SOAP Web Service Tutorials - Herong's Tutorial Examples - v5.13, by Herong Yang
Capturing HTTP Request Generated by the HttpURLConnection Class
This section provides a tutorial example on how to capture the HTTP request generated by a HttpURLConnection program to call the NumberToWords SOAP 1.1 Web service provided by dataaccess.com.
To test HttpURLConnection11.java, I need to use the NumberToWords Web service provided by dataaccess.com/webservicesserver/numberconversion.wso?op=NumberToWords.
Here is a SOAP 1.1 request example, soap_1_1_NumberToWords_req.xml:
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/"> <ubiNum>104</ubiNum> </NumberToWords> </soap:Body> </soap:Envelope>
The first test was performed locally with my SocketServerTest.java program running in a command line window:
herong> java SocketServerTest http_1_0_server.res server.req Listening at 8888
In another command line window, HttpURLConnection11.java was executed:
herong> java HttpURLConnection11 http://localhost:8888 \ NumberToWords soap_1_1_NumberToWords_req.xml res.xml
Back to the server window:
herong> java SocketServerTest http_1_0_server.res server.req Listening at 8888 <Ctrl-C> Connection received from /127.0.0.1 Bytes received: 522 herong> more server.req POST / HTTP/1.1 Content-type: text/xml; charset=utf-8 SOAPAction: NumberToWords User-Agent: Java/10.0.1 Host: localhost:8888 Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Connection: keep-alive Content-Length: 283 <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/"> <ubiNum>104</ubiNum> </NumberToWords> </soap:Body> </soap:Envelope>
The HTTP request generated by HttpURLConnection11.java looks very good.
Remember to press Ctrl-C to create connect on the server side.
Table of Contents
Introduction to SOAP (Simple Object Access Protocol)
SOAP Message Transmission and Processing
SOAP MEP (Message Exchange Patterns)
PHP SOAP Extension Client Programs
PHP SOAP Extension Server Programs
PHP SOAP Web Service Example - getTemp
Perl SOAP::Lite - SOAP Server-Client Communication Module
Perl Socket Test Program for HTTP and SOAP
Perl SOAP::Lite for NumberToWords SOAP 1.1 Web Service
Perl SOAP::Lite for SOAP 1.2 Web Services
►Java Socket and HttpURLConnection for SOAP
SocketRequestResponse.java - Socket Client Testing Program
SocketRequestResponseServer.java - Socket Server Testing Program
Capturing the HTTP Request from a Browser
"read(byteBuf) = -1" Not Working
Using java.net.HttpURLConnection to Send SOAP Messages
Using HttpURLConnection to Call SOAP 1.1
►Capturing HTTP Request Generated by the HttpURLConnection Class
Calling NumberToWords SOAP 1.1 Web Service
Using HttpURLConnection to Call SOAP 1.2
Calling NumberToWords SOAP 1.2 Web Service
SAAJ - SOAP with Attachments API for Java
SoapUI - SOAP Web Service Testing Tool
WS-Security - SOAP Message Security Extension
WS-Security X.509 Certificate Token
Perl SOAP::Lite for GetSpeech SOAP 1.1 Web Service
Perl SOAP::Lite 0.710 for SOAP 1.2 Web Services
Perl SOAP::Lite 0.710 for WSDL