|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.serviceclients.webclient.WebServiceClient
public class WebServiceClient
WebServiceClient provides helpers to communicate with webservices via timed connections (time out is adjustable).
The helper methods do the following:
The DDS helpers submit requests to the DDS Search Web Services and returns
responses as Document
.
The DCS helpers support the following repository services:
$Id: WebServiceClient.java,v 1.23 2009/03/20 23:33:58 jweather Exp $
Field Summary | |
---|---|
protected static boolean |
debug
Description of the Field |
Constructor Summary | |
---|---|
WebServiceClient(String baseWebServiceUrl)
Constructor for the WebServiceClient object. |
Method Summary | |
---|---|
String |
doGetId(String collection)
Requests an id from DCS getId web service. |
String |
doPutRecord(String recordXml,
String xmlFormat,
String collection)
|
String |
doPutRecord(String recordXml,
String xmlFormat,
String collection,
String status,
String statusNote)
Generate an ID and insert it in the recordXML before calling the PutRecord web service |
String |
doPutRecord(String recordXml,
String xmlFormat,
String collection,
String id,
String status,
String statusNote)
Assumes id is already placed in the xmlRecord. |
Document |
doSearch(String queryStr)
|
String |
getBaseUrl()
|
GetRecordResponse |
getRecord(String id)
Submits a request to the GetRecord DDS Web Service and returns response as a Document . |
URL |
getRequestUrl()
Gets the requestUrl attribute of the WebServiceClient object |
protected Document |
getResponseDoc()
retreives the contents of the requestUrl field as a Document |
static Document |
getResponseDoc(URL url)
Static version of getResponseDoc. |
static String |
getResponseError(Document doc)
Gets the responseError attribute of the WebServiceClient class |
static String |
getResponseError(String s)
Searches the response string for error elements and returns the contents of the error if one is found. |
protected String |
getResponseStr()
Submits a Web Service and returns the result as a string. |
static String |
getTimedURL(URL url)
Uses a TimedURLConnection to get the repsonse
from the web service (the request is a URL), which is returned as a String. |
static Document |
getTimedXmlDocument(URL url)
gets the contents of a URL via getTimedURL(URL) and then parses
the contents into a dom4j Document, which is returned |
int |
getTimeOutSecs()
|
static void |
main(String[] args)
The main program for the WebServiceClient class |
static void |
setDebug(boolean db)
Sets the debug attribute |
void |
setRequestUrl(String verb,
String argStr)
Sets the requestUrl attribute of the WebServiceClient object |
void |
setRequestUrl(URL url)
Sets the requestUrl attribute of the WebServiceClient object |
void |
setTimeOutSecs(int i)
|
static String |
stuffId(String recordXml,
String xmlFormat,
String id)
Place the provided ID into the provided recordXml. |
Document |
urlCheck(String s)
Submit a request (query) to the UrlCheck Web service and return the response as a Document . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static boolean debug
Constructor Detail |
---|
public WebServiceClient(String baseWebServiceUrl)
Example baseWebServiceUrls:
baseWebServiceUrl
- url of Web ServiceMethod Detail |
---|
public String getBaseUrl()
public void setTimeOutSecs(int i)
public int getTimeOutSecs()
public Document urlCheck(String s) throws WebServiceClientException
Document
. The UrlCheck service returns
items that match the query. the query is a url and may contain asterisks as
wildcards.
s
- query to be submitted to UrlCheck
service.
WebServiceClientException
- Description of the Exceptionpublic Document doSearch(String queryStr) throws WebServiceClientException
WebServiceClientException
public static String stuffId(String recordXml, String xmlFormat, String id) throws Exception
recordXml
- Description of the Parameterid
- Description of the Parameter
Exception
- Description of the Exceptionpublic String doPutRecord(String recordXml, String xmlFormat, String collection, String status, String statusNote) throws WebServiceClientException
recordXml
- xml record to be putxmlFormat
- metadata format of xml record (e.g., "adn")collection
- destination collection (e.g., "dcc")
WebServiceClientException
- Description of the Exceptionpublic String doPutRecord(String recordXml, String xmlFormat, String collection) throws WebServiceClientException
WebServiceClientException
public String doPutRecord(String recordXml, String xmlFormat, String collection, String id, String status, String statusNote) throws WebServiceClientException
recordXml
- xml record to be putxmlFormat
- metadata format of xml record (e.g., "adn")collection
- destination collection (e.g., "dcc")id
- xml record id
WebServiceClientException
- Description of the Exceptionpublic String doGetId(String collection) throws WebServiceClientException
collection
- Description of the Parameter
WebServiceClientException
- If unable to generate an IDpublic GetRecordResponse getRecord(String id) throws WebServiceClientException
Document
. The GetRecord service returns an ADN record
wrapped in a XML response.
id
- id of the record to get
WebServiceClientException
- Description of the Exceptionpublic void setRequestUrl(URL url)
url
- The new requestUrl valuepublic URL getRequestUrl()
public void setRequestUrl(String verb, String argStr)
verb
- The new requestUrl valueargStr
- The new requestUrl valueprotected String getResponseStr() throws WebServiceClientException
WebServiceClientException
- Description of the Exceptionpublic static String getResponseError(String s)
s
- Web service response as string
protected Document getResponseDoc() throws WebServiceClientException
Document
WebServiceClientException
- if unsuccessful retrieving url or
parsing docpublic static Document getResponseDoc(URL url) throws WebServiceClientException
url
- Description of the Parameter
WebServiceClientException
- Description of the Exceptionpublic static String getResponseError(Document doc)
doc
- Description of the Parameter
public static String getTimedURL(URL url) throws WebServiceClientException
TimedURLConnection
to get the repsonse
from the web service (the request is a URL), which is returned as a String.
url
- Description of the Parameter
WebServiceClientException
- Description of the Exceptionpublic static Document getTimedXmlDocument(URL url) throws WebServiceClientException, DocumentException
getTimedURL(URL)
and then parses
the contents into a dom4j Document, which is returned
url
- url to retrieve
WebServiceClientException
- Description of the Exception
DocumentException
- Description of the Exceptionpublic static void main(String[] args)
args
- The command line argumentspublic static void setDebug(boolean db)
db
- The new debug value
|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |