com.wingfoot.soap.transport
Class J2SEHTTPTransport

java.lang.Object
  |
  +--com.wingfoot.soap.transport.J2SEHTTPTransport
All Implemented Interfaces:
Transport

public class J2SEHTTPTransport
extends java.lang.Object
implements Transport

Class to aid in making SOAP calls over HTTP using J2SE.

Since:
0.90

Constructor Summary
J2SEHTTPTransport(java.lang.String url, java.lang.String soapAction)
          Creates an instance of HTTPTransport with the url and port number specified.
 
Method Summary
 void addHeader(java.lang.String name, java.lang.String value)
          Method to specify HTTP Header(s).
 byte[] call(byte[] payload)
          Makes a HTTP connection the the URL and port specified.
 void getResponse(boolean shouldGetResponse)
          Method to specify if the HTTP call should wait for a response from the service.
 void setSOAPAction(java.lang.String soapAction)
          Provides the ability to set the soapAction.
 void useSession(boolean usage, java.lang.String cookieName)
          Identifies if the session has to be maintained.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

J2SEHTTPTransport

public J2SEHTTPTransport(java.lang.String url,
                         java.lang.String soapAction)
Creates an instance of HTTPTransport with the url and port number specified. This class is immutable.
Parameters:
url - the URL to connect to.
SOAPAction - the value for SOAPAction HTTP header. If null, the header is set to "".
Since:
0.90
Method Detail

useSession

public void useSession(boolean usage,
                       java.lang.String cookieName)
Identifies if the session has to be maintained. Since HTTP is a stateless protocol, cookies are a popular way to maintain state across multiple requests. For J2EE based servers, the JSESSIONID cookie is used to maintain state. For other platforms, the cookie name might be different. This method takes the cookieName that is sent back to the server.
Parameters:
usage - boolean that identifies if a session has to be maintained; true indicates that the cookie sent back by the server is sent back to the server thereby maintaining state; false indicates the cookie is not sent back; default is false
cookieName - the name of the cookie that is used to maintain the state; if null JSESSIONID is used.

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
               throws SOAPException
Method to specify HTTP Header(s). These headers are in addition to the following HTTP headers always sent to the server: Content-Language - always set to "en-US" Content-Type - always set to "text/xml" Content-Length - set to the length of the SOAP payload SOAPAction - the SOAPAction specified in the constructor; "" is a null was passed to the constructor.
Parameters:
name - the name of the HTTP header; cannot be null
value - the value of the header; cannot be null
Throws:
SOAPException - if the key or value is null
Since:
1.01

getResponse

public void getResponse(boolean shouldGetResponse)
Method to specify if the HTTP call should wait for a response from the service. If the boolean is set to false, the XML payload is sent and the response is not retrieved or parsed. Default is true (i.e. retrieves response).

Please use this option with care. It has been noticed that a connection is not made to the server until explicitly opening an InputStream to the server; hence setting the boolean to false will not parse the data but the call is blocked until the server responds.

Parameters:
shouldGetResponse - true if a response is to be retrieved (default); false if response is not to be retrieved.
Since:
0.90

call

public byte[] call(byte[] payload)
            throws SOAPException,
                   java.io.IOException,
                   java.net.MalformedURLException
Makes a HTTP connection the the URL and port specified.
Specified by:
call in interface Transport
Parameters:
payload - the SOAP message as a byte array.
Returns:
a byte array with the response from the server; null if shouldGetResponse is false;
Throws:
java.io.IOException - if any error occurs during connection to the server.
SOAPException - if the response is not XML.

setSOAPAction

public void setSOAPAction(java.lang.String soapAction)
Provides the ability to set the soapAction. Useful if the a Transport instance is to be used across calls but the soapAction has to be changed.
Parameters:
soapAction - the new soapAction.


Copyright(c) Wingfoot Software (www.wingfoot.com). All Rights Reserved.

KXML is a XML parser by Lutris Technologies