Child pages
  • HttpClient

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Wiki Markup
{div:style=display:none}
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.\\		\\		Enter additional information related to this 'class' inside the \{div} macro with 'id=description'{div}
{div:id=description}{div}\\ 

{table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[DeleteRequest]{td}{td}[#createDeleteRequest]\(url)
Creates a new delete request (a request to delete a resource on server).{td}{tr}{tbody}{tbody}{tr}{td}[GetRequest]{td}{td}[#createGetRequest]\(url)
Creates a new get request (retrieves whatever information is stored on specified url).{td}{tr}{tbody}{tbody}{tr}{td}[HeadRequest]{td}{td}[#createHeadRequest]\(url)
Creates a new head request (similar to get request, must not contain body content).{td}{tr}{tbody}{tbody}{tr}{td}[OptionsRequest]{td}{td}[#createOptionsRequest]\(url)
Creates a new options request (a request for information about communication options).{td}{tr}{tbody}{tbody}{tr}{td}[PostRequest]{td}{td}[#createPostRequest]\(url)
Create a new post request ( Origin server should accept/process the submitted data.{td}{tr}{tbody}{tbody}{tr}{td}[PutRequest]{td}{td}[#createPutRequest]\(url)
Creates a new put request (similar to post request, contains information to be submitted).{td}{tr}{tbody}{tbody}{tr}{td}[TraceRequest]{td}{td}[#createTraceRequest]\(url)
Creates a new trace request (debug request, server will just echo back).{td}{tr}{tbody}{tbody}{tr}{td}[Cookie]{td}{td}[#getCookie]\(cookieName)
Get a cookie by name.{td}{tr}{tbody}{tbody}{tr}{td}[Cookie]\[]{td}{td}[#getCookies]\()
Get all cookies from this client.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#setClientProxyCredentials]\(userName, password)
Set proxy credentials.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#setCookie]\(cookieName, cookieValue)
Add cookie to the this client.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#setCookie]\(cookieName, cookieValue, domain)
Add cookie to the this client.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#setCookie]\(cookieName, cookieValue, domain, path)
Add cookie to the this client.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#setCookie]\(cookieName, cookieValue, domain, path, maxAge)
Add cookie to the this client.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#setCookie]\(cookieName, cookieValue, domain, path, maxAge, secure)
Add cookie to the this client.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#setTimeout]\(msTimeout)
Sets a timeout in milliseconds for retrieving of data (when 0 there is no timeout).{td}{tr}{tbody}{table}\\ 

{table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=createDeleteRequest-String}{tr:id=name}{td}h6.createDeleteRequest{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[DeleteRequest]{span}{span:style=font-weight: bold;}createDeleteRequest{span}{span}\(url){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Creates a new delete request (a request to delete a resource on server).{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} url
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[DeleteRequest]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var client = plugins.http.createNewHttpClient();
var request = client.createDeleteRequest('http://www.servoy.com/delete.me');
var response = request.executeRequest();
var httpCode = response.getStatusCode(); // httpCode 200 is ok"
var content = response.getResponseBody();
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createGetRequest-String}{tr:id=name}{td}h6.createGetRequest{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[GetRequest]{span}{span:style=font-weight: bold;}createGetRequest{span}{span}\(url){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Creates a new get request (retrieves whatever information is stored on specified url).
If this url is a https ssl encrypted url which certificates are not in the java certificate store.
(Like a self signed certificate or a none existing root certificate)
Then for a smart client a dialog will be given, to give the user the ability to accept this certificate for the next time.
For a Web or Headless client the system administrator does have to add that certificate (chain) to the java install on the server.
See http://wiki.servoy.com/display/tutorials/Import+a+%28Root%29+certificate+in+the+java+cacerts+file{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} url
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[GetRequest]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var client = plugins.http.createNewHttpClient();
var request = client.createGetRequest('http://www.servoy.com');
var response = request.executeRequest();
var httpCode = response.getStatusCode(); // httpCode 200 is ok"
var content = response.getResponseBody();
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createHeadRequest-String}{tr:id=name}{td}h6.createHeadRequest{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[HeadRequest]{span}{span:style=font-weight: bold;}createHeadRequest{span}{span}\(url){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Creates a new head request (similar to get request, must not contain body content).{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} url
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[HeadRequest]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var client = plugins.http.createNewHttpClient();
var request = client.createHeadRequest('http://www.servoy.com');
var response = request.executeRequest();
var httpCode = response.getStatusCode(); // httpCode 200 is ok
var header = response.getResponseHeaders('last-modified');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createOptionsRequest-String}{tr:id=name}{td}h6.createOptionsRequest{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[OptionsRequest]{span}{span:style=font-weight: bold;}createOptionsRequest{span}{span}\(url){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Creates a new options request (a request for information about communication options).{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} url
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[OptionsRequest]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var client = plugins.http.createNewHttpClient();
var request = client.createOptionsRequest('http://www.servoy.com');
var methods = request.getAllowedMethods(request.executeRequest());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createPostRequest-String}{tr:id=name}{td}h6.createPostRequest{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[PostRequest]{span}{span:style=font-weight: bold;}createPostRequest{span}{span}\(url){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Create a new post request ( Origin server should accept/process the submitted data.)
If this url is a https ssl encrypted url which certificates are not in the java certificate store.
(Like a self signed certificate or a none existing root certificate)
Then for a smart client a dialog will be given, to give the user the ability to accept this certificate for the next time.
For a Web or Headless client the system administrator does have to add that certificate (chain) to the java install on the server.
See http://wiki.servoy.com/display/tutorials/Import+a+%28Root%29+certificate+in+the+java+cacerts+file{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} url
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[PostRequest]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var client = plugins.http.createNewHttpClient();
var poster = client.createPostRequest('https://twitter.com/statuses/update.json');
poster.addParameter('status',globals.textToPost);
poster.addParameter('source','Test Source');
poster.setCharset('UTF-8');
var httpCode = poster.executeRequest(globals.twitterUserName, globals.twitterPassword).getStatusCode(); // httpCode 200 is ok
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createPutRequest-String}{tr:id=name}{td}h6.createPutRequest{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[PutRequest]{span}{span:style=font-weight: bold;}createPutRequest{span}{span}\(url){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Creates a new put request (similar to post request, contains information to be submitted).{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} url
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[PutRequest]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var client = plugins.http.createNewHttpClient();
var request = client.createPutRequest('http://jakarta.apache.org');
request.setFile('UploadMe.gif');
var httpCode = putRequest.executeRequest().getStatusCode() // httpCode 200 is ok
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createTraceRequest-String}{tr:id=name}{td}h6.createTraceRequest{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[TraceRequest]{span}{span:style=font-weight: bold;}createTraceRequest{span}{span}\(url){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Creates a new trace request (debug request, server will just echo back).{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} url
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[TraceRequest]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var client = plugins.http.createNewHttpClient();
var response = request.executeRequest();
var httpCode = response.getStatusCode(); // httpCode 200 is ok"
var content = response.getResponseBody();
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getCookie-String}{tr:id=name}{td}h6.getCookie{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Cookie]{span}{span:style=font-weight: bold;}getCookie{span}{span}\(cookieName){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Get a cookie by name.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} cookieName
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Cookie]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var cookie = client.getCookie('JSESSIONID');
if (cookie != null)
{
	// do something
}
else
	client.setCookie('JSESSIONID', 'abc', 'localhost', '/', -1, false)
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getCookies}{tr:id=name}{td}h6.getCookies{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Cookie]\[]{span}{span:style=font-weight: bold;}getCookies{span}{span}\(){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Get all cookies from this client.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Cookie]\[]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var cookies = client.getHttpClientCookies()
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=setClientProxyCredentials-String_String}{tr:id=name}{td}h6.setClientProxyCredentials{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}void{span}{span:style=font-weight: bold;}setClientProxyCredentials{span}{span}\(userName, password){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Set proxy credentials.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} userName
\{[String]} password
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
client.setClientProxyCredentials('my_proxy_username','my_proxy_password');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=setCookie-String_String}{tr:id=name}{td}h6.setCookie{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}setCookie{span}{span}\(cookieName, cookieValue){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Add cookie to the this client.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} cookieName -- the name of the cookie
\{[String]} cookieValue -- the value of the cookie
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var cookieSet = client.setCookie('JSESSIONID', 'abc', 'localhost', '/', -1, false)
if (cookieSet)
{
	//do something
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=setCookie-String_String_String}{tr:id=name}{td}h6.setCookie{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}setCookie{span}{span}\(cookieName, cookieValue, domain){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Add cookie to the this client.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} cookieName -- the name of the cookie
\{[String]} cookieValue -- the value of the cookie
\{[String]} domain -- the domain
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var cookieSet = client.setCookie('JSESSIONID', 'abc', 'localhost', '/', -1, false)
if (cookieSet)
{
	//do something
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=setCookie-String_String_String_String}{tr:id=name}{td}h6.setCookie{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}setCookie{span}{span}\(cookieName, cookieValue, domain, path){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Add cookie to the this client.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} cookieName -- the name of the cookie
\{[String]} cookieValue -- the value of the cookie
\{[String]} domain -- the domain
\{[String]} path -- the path
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var cookieSet = client.setCookie('JSESSIONID', 'abc', 'localhost', '/', -1, false)
if (cookieSet)
{
	//do something
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=setCookie-String_String_String_String_Number}{tr:id=name}{td}h6.setCookie{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}setCookie{span}{span}\(cookieName, cookieValue, domain, path, maxAge){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Add cookie to the this client.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} cookieName -- the name of the cookie
\{[String]} cookieValue -- the value of the cookie
\{[String]} domain -- the domain
\{[String]} path -- the path
\{[Number]} maxAge -- maximum age of cookie
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var cookieSet = client.setCookie('JSESSIONID', 'abc', 'localhost', '/', -1, false)
if (cookieSet)
{
	//do something
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=setCookie-String_String_String_String_Number_Boolean}{tr:id=name}{td}h6.setCookie{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}setCookie{span}{span}\(cookieName, cookieValue, domain, path, maxAge, secure){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Add cookie to the this client.{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} cookieName -- the name of the cookie
\{[String]} cookieValue -- the value of the cookie
\{[String]} domain -- the domain
\{[String]} path -- the path
\{[Number]} maxAge -- maximum age of cookie
\{[Boolean]} secure -- true if it is a secure cookie, false otherwise
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var cookieSet = client.setCookie('JSESSIONID', 'abc', 'localhost', '/', -1, false)
if (cookieSet)
{
	//do something
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=setTimeout-}{tr:id=name}{td}h6.setTimeout{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}void{span}{span:style=font-weight: bold;}setTimeout{span}{span}\(msTimeout){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Sets a timeout in milliseconds for retrieving of data (when 0 there is no timeout).{div}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}msTimeout
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
client.setTimeout(1000)
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}