Hi Ruchira,

We want to carch the exception according to connection refused exception
from the jaggery side . Due to logging of this  exception from Hostobject
We couldn't remove this exception come from the console.

Is there any way of check a server is up and running from jaggery side . If
there's a way we can avoid exception come from the console.

Thanks
Tharindu

On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha <ruch...@wso2.com> wrote:

> What is the issue with going try/catch blocks?
>
> /Ruchira
>
> On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna <tharin...@wso2.com
> > wrote:
>
>> Hi all,
>>
>> According to public jira [1]  how can we handle connection refused
>> exception come from this issue . This come from the send method.
>>
>> code snippest for this issue
>>
>>>
>>> try{
>>> var xhr = new XMLHttpRequest();
>>> var site = require("/site/conf/site.json");
>>> var endpoint =
>>> site.workflows.applicationWorkFlowServerURL+"AuthenticationAdmin";
>>> xhr.open("POST", endpoint);
>>> var payload = '<soap:Envelope xmlns:soap="
>>> http://www.w3.org/2003/05/soap-envelope"; xmlns:aut="
>>> http://authentication.services.core.carbon.wso2.org";><soap:Header/><soap:Body><aut:login><aut:username>'
>>> + username + '</aut:username><aut:password>' + password +
>>> '</aut:password><aut:remoteAddress>localhost</aut:remoteAddress></aut:login></soap:Body></soap:Envelope>';
>>> xhr.send(payload);
>>> var cookie = (xhr.getAllResponseHeaders());
>>> log.info(xhr.readyState);
>>> //session.put("workflowCookie",cookie.split(";")[0].split(":")[1]);
>>> var sessionCookie = xhr.getResponseHeader("Set-Cookie");
>>> session.put("workflowCookie",sessionCookie);
>>> }catch (e) {
>>> // log.error(e.message);
>>> }
>>
>>
>> Exception come from the following jaggery hostobject code
>>
>> private static void executeRequest(Context cx, XMLHttpRequestHostObject
>>> xhr) throws ScriptException {
>>> try {
>>> xhr.httpClient.executeMethod(xhr.method);
>>> xhr.statusLine = xhr.method.getStatusLine();
>>> xhr.responseHeaders = xhr.method.getResponseHeaders();
>>> updateReadyState(cx, xhr, HEADERS_RECEIVED);
>>> byte[] response = xhr.method.getResponseBody();
>>> if (response.length > 0) {
>>> xhr.responseText = new String(response);
>>> }
>>> Header contentType = xhr.method.getResponseHeader("Content-Type");
>>> if (contentType != null) {
>>> xhr.responseType = contentType.getValue();
>>> }
>>> updateReadyState(cx, xhr, DONE);
>>> } catch (IOException e) {
>>> log.error(e.getMessage(), e);
>>> throw new ScriptException(e);
>>> } finally {
>>> xhr.method.releaseConnection();
>>> }
>>> }
>>
>> XMLHttpRequestHostObject.java
>>
>> [1] - https://wso2.org/jira/browse/APIMANAGER-3139
>>
>> Thanks and regards
>>
>>
>> *Tharindu Dharmarathna*Associate Software Engineer
>> WSO2 Inc.; http://wso2.com
>> lean.enterprise.middleware
>>
>> mobile: *+94779109091 <%2B94779109091>*
>>
>
>
>
> --
>
> *Ruchira Wageesha**Associate Technical Lead*
> *WSO2 Inc. - lean . enterprise . middleware |  wso2.com <http://wso2.com>*
>
> *email: ruch...@wso2.com <ruch...@wso2.com>,   blog:
> ruchirawageesha.blogspot.com <http://ruchirawageesha.blogspot.com>,
> mobile: +94 77 5493444 <%2B94%2077%205493444>*
>



-- 

*Tharindu Dharmarathna*Associate Software Engineer
WSO2 Inc.; http://wso2.com
lean.enterprise.middleware

mobile: *+94779109091*
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to