com.jmrosengard.xmlbroker.broker
Class HttpClient
java.lang.Object
|
+--com.jmrosengard.xmlbroker.broker.HttpClient
- public class HttpClient
- extends java.lang.Object
A trivial HTTP client. Only (some of) the POST method is
implemented, using java.net.Socket. Note that the higher-level java.net.URL
object do not fit into the SOAP model, and is therefore not used.
Field Summary |
private java.lang.String |
body
|
private int |
bodySize
|
private java.io.BufferedReader |
inBuf
|
private java.io.PrintWriter |
outBuf
|
private java.lang.String |
portName
|
private java.net.Socket |
sock
|
private java.lang.String |
statusCode
|
private java.net.URL |
url
|
Method Summary |
protected int |
getContentLength()
Calculates the "Content-Length" field of the request HTTP header. |
protected java.lang.String |
getHeader()
Returns the SOAP-HTTP POST header
Content-Type is set to text/xml (XML specifications)-
charset is set to utf-8 (XML specifications)-
SOAPAction is set to the destination SOAP port (SOAP specifications)
|
java.lang.String |
getHttpResource(java.lang.String urlStr,
java.lang.String portName,
java.lang.String body)
connects to the URI uri, and returns the body of the HTTP response. |
java.lang.String |
getStatusCode()
Returns the "Status-Code" field of the response HTTP header. |
static void |
main(java.lang.String[] args)
For testing only |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
inBuf
private java.io.BufferedReader inBuf
outBuf
private java.io.PrintWriter outBuf
sock
private java.net.Socket sock
bodySize
private int bodySize
body
private java.lang.String body
url
private java.net.URL url
statusCode
private java.lang.String statusCode
portName
private java.lang.String portName
HttpClient
public HttpClient()
getContentLength
protected int getContentLength()
- Calculates the "Content-Length" field of the request HTTP header.
(Each character is 1 byte long in UTF-8)
getHeader
protected java.lang.String getHeader()
- Returns the SOAP-HTTP POST header
- Content-Type is set to text/xml (XML specifications)-
- charset is set to utf-8 (XML specifications)-
- SOAPAction is set to the destination SOAP port (SOAP specifications)
getStatusCode
public java.lang.String getStatusCode()
- Returns the "Status-Code" field of the response HTTP header.
getHttpResource
public java.lang.String getHttpResource(java.lang.String urlStr,
java.lang.String portName,
java.lang.String body)
- connects to the URI uri, and returns the body of the HTTP response.
See http://www.ietf.org/rfc/rfc2068.txt
for the HTTP 1.1 RFC.
main
public static void main(java.lang.String[] args)
- For testing only