net.sf.xtvdclient.xtvd
Class SOAPRequest

java.lang.Object
  extended by net.sf.xtvdclient.xtvd.SOAPRequest

public class SOAPRequest
extends java.lang.Object

This class builds a SOAP request that targets the TMS XTVD webservice and fetches the resulting XML document. The following code sample shows ways of using this class:

  String userName = "scott";
  String password = "tiger";
  SOAPRequest soapRequest = new SOAPRequest( userName, password );

  int numberOfDays = 3;
  Calendar start = Calendar.getInstance();
  Calendar end = Calendar.getInstance();
  end.add( Calendar.DAY_OF_YEAR, numberOfDays );
  StringWriter writer = new StringWriter( 65536 );
  soapRequest.getData( start, end, writer );
  String data = writer.toString();

  start.add( Calendar.DAY_OF_YEAR, numberOfDays );
  end.add( Calendar.DAY_OF_YEAR, numberOfDays * 2 );
  String fileName = "/tmp/xtvd.xml";
  soapRequest.getDataFile( start, end, fileName );

  Xtvd xtvd = new Xtvd();
  soapRequest.getData( start, end, xtvd );
 

Since:
ddclient version 1.2

Field Summary
static java.lang.String CLOSE_SOAP_BODY
          The closing SOAP Body to use to wrap the request.
static java.lang.String CLOSE_SOAP_ENVELOPE
          The closing SOAP Envelope to use to wrap the request.
static java.lang.String END_OF_LINE
          The system specific end of line character.
static java.lang.String SOAP_BODY
          The SOAP Body to use to wrap the request.
static java.lang.String SOAP_ENVELOPE
          The SOAP Envelope to use to wrap the request.
static java.lang.String WEBSERVICE_URI
          The URI for the TMS XTVD web service.
static java.lang.String XML_HEADER
          The XML header to use to wrap the request.
 
Constructor Summary
SOAPRequest()
          Default constructor.
SOAPRequest(java.lang.String userName, java.lang.String password)
          Create a new instance of the class with the specified values for userName and password.
SOAPRequest(java.lang.String userName, java.lang.String password, java.lang.String uri)
          Create a new instance of the class with the specified values for userName, password and webserviceURI.
 
Method Summary
 void getData(java.util.Calendar start, java.util.Calendar end, java.io.Writer writer)
          Connect to the webservice and download the XTVD document using the specified parameters.
 void getData(java.util.Calendar start, java.util.Calendar end, Xtvd xtvd)
          Connect to the webservice and download the XTVD document using the specified parameters.
 void getDataFile(java.util.Calendar start, java.util.Calendar end, java.lang.String file)
          Connect to the webservice and download the XTVD document using the specified parameters and write the document to the specified file.
 java.io.Writer getLog()
          Returns log.
 java.lang.String getUserName()
          Returns userName.
 java.lang.String getWebserviceURI()
          Returns webserviceURI.
 void setLog(java.io.Writer log)
          Set log.
 void setPassword(java.lang.String password)
          Set password.
 void setUserName(java.lang.String userName)
          Set userName.
 void setWebserviceURI(java.lang.String uri)
          Set webserviceURI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

END_OF_LINE

public static final java.lang.String END_OF_LINE
The system specific end of line character.


WEBSERVICE_URI

public static final java.lang.String WEBSERVICE_URI
The URI for the TMS XTVD web service. "http://datadirect.webservices.zap2it.com/tvlistings/xtvdService"

See Also:
Constant Field Values

XML_HEADER

public static final java.lang.String XML_HEADER
The XML header to use to wrap the request.

See Also:
Constant Field Values

SOAP_ENVELOPE

public static final java.lang.String SOAP_ENVELOPE
The SOAP Envelope to use to wrap the request.

See Also:
Constant Field Values

CLOSE_SOAP_ENVELOPE

public static final java.lang.String CLOSE_SOAP_ENVELOPE
The closing SOAP Envelope to use to wrap the request. "</SOAP-ENV:Envelope>"

See Also:
Constant Field Values

SOAP_BODY

public static final java.lang.String SOAP_BODY
The SOAP Body to use to wrap the request.

See Also:
Constant Field Values

CLOSE_SOAP_BODY

public static final java.lang.String CLOSE_SOAP_BODY
The closing SOAP Body to use to wrap the request.

See Also:
Constant Field Values
Constructor Detail

SOAPRequest

public SOAPRequest()
            throws DataDirectException
Default constructor. Initialises the webserviceURI with the value in WEBSERVICE_URI, and the sdf class fields. Note: You must set the authentication credentials for the class using the setUserName(String) and setPassword(String) mutator methods if you use this form of the constructor.

Throws:
DataDirectException - If a MalformedURLException is caught while creating a new URL.

SOAPRequest

public SOAPRequest(java.lang.String userName,
                   java.lang.String password)
            throws DataDirectException
Create a new instance of the class with the specified values for userName and password. Use this constructor if the request is to be made to the default (production) webservice.

Parameters:
userName - The userName to use for accessing the webservices.
password - The password associated with the user.
Throws:
DataDirectException - If a MalformedURLException is caught while creating a new URL.

SOAPRequest

public SOAPRequest(java.lang.String userName,
                   java.lang.String password,
                   java.lang.String uri)
            throws DataDirectException
Create a new instance of the class with the specified values for userName, password and webserviceURI.

Parameters:
userName - The userName to use for accessing the webservices.
password - The password associated with the user.
uri - The URI for the webservice.
Throws:
DataDirectException - If a MalformedURLException is caught while creating a new URL with the uri parameter.
Method Detail

getDataFile

public void getDataFile(java.util.Calendar start,
                        java.util.Calendar end,
                        java.lang.String file)
                 throws DataDirectException
Connect to the webservice and download the XTVD document using the specified parameters and write the document to the specified file.

Parameters:
start - The date-time from which data is requested.
end - The date-time till which data is requested.
file - The fully qualified name of the file to which the XTVD document is to be written.
Throws:
DataDirectException - If errors are encountered while interacting with the web service or while writing to the specified file.
See Also:
getData(Calendar, Calendar, Writer)

getData

public void getData(java.util.Calendar start,
                    java.util.Calendar end,
                    java.io.Writer writer)
             throws DataDirectException
Connect to the webservice and download the XTVD document using the specified parameters. Parse the XTVD response and write it to the specified Writer.

Parameters:
start - The date-time from which data is requested.
end - The date-time till which data is requested.
writer - The Writer to which the XML data is to be written.
Throws:
DataDirectException - If errors are encountered while interacting with the web service.
See Also:
sendDownloadRequest(Calendar, Calendar), readSOAPResponse(Writer)

getData

public void getData(java.util.Calendar start,
                    java.util.Calendar end,
                    Xtvd xtvd)
             throws DataDirectException
Connect to the webservice and download the XTVD document using the specified parameters. Parse the XTVD document and populate the instance variables in the specified Xtvd object.

Parameters:
start - The date-time from which data is requested.
end - The date-time till which data is requested.
xtvd - The Xtvd to which the XML data is to be written.
Throws:
DataDirectException - If errors are encountered while interacting with the web service.
Since:
ddclient version 1.2
See Also:
sendDownloadRequest(Calendar, Calendar), readSOAPResponse(Xtvd)

getUserName

public final java.lang.String getUserName()
Returns userName.

Returns:
The value/reference of/to userName.

setUserName

public final void setUserName(java.lang.String userName)
Set userName.

Parameters:
userName - The value to set.

setPassword

public final void setPassword(java.lang.String password)
Set password.

Parameters:
password - The value to set.

getWebserviceURI

public final java.lang.String getWebserviceURI()
Returns webserviceURI.

Returns:
The string representation of webserviceURI

setWebserviceURI

public final void setWebserviceURI(java.lang.String uri)
                            throws DataDirectException
Set webserviceURI.

Parameters:
uri - The value to set.
Throws:
DataDirectException - If errors are encountered while creating a new URL instance.

getLog

public final java.io.Writer getLog()
Returns log.

Returns:
The value/reference of/to log.

setLog

public final void setLog(java.io.Writer log)
Set log.

Parameters:
log - The value to set.