EDIT:
Please post the error you get afterwards.

On Fri, Sep 23, 2016 at 5:11 PM, Sameera Medagammaddegedara <
[email protected]> wrote:

> Hi Denuwanthi,
>
> Can you please change your jag to the following:
>
> <%
>   try {
>    <Code above>
>  } catch (e) {
>     log.error(e);
>     response.status=500;
>     var msg = {};
>    msg.status = 500;
>     msg.error = "Failed invoking remote endpoint";
>     print(msg);
>  }
>
> %>
>
> On Fri, Sep 23, 2016 at 5:04 PM, Denuwanthi De Silva <[email protected]>
> wrote:
>
>> Hi,
>>
>> I have .jsp file, in which I want to invoke a jaggery api.
>>
>> The content inside .jsp file is as below:
>>
>> URL url = new URL(baseURL + *"/user-login/user/authenticate/add*?scope="
>> + URLEncoder.encode(scope, "UTF-8") + "&redirecturi=" + redirectUri +
>> "&clientid=" + clientId + "&acrvalue=" + arc + "&responsetype=" +
>> responseType + "&operator=" + operator + "&msisdn=" +
>> msisdn+"&nonce="+nonce+"&state="+state+"&baseUrl="+baseURL);
>>                             HttpURLConnection conn = (HttpURLConnection)
>> url.openConnection();
>>                             conn.setRequestMethod("GET");
>>                             conn.setRequestProperty("Accept",
>> "application/json");
>>                             if (conn.getResponseCode() != 200) {
>>                                 throw new RuntimeException("Failed : HTTP
>> error code : " + conn.getResponseCode());
>>                             }
>>
>> The jaggery.conf file contains the url mapping as follows:
>> {
>> "urlMappings": [
>>     {
>>             "url": *"/user/authenticate/add*",
>>             "path": "/sendAuthentication.jag"
>>         }
>> ]
>> }
>>
>> The sendAuthentication.jag content is as follows:
>> Inside the jaggery api file I call a JAX-RS webapp in the path
>> *'user-registration/webresources/endpoint/user/authenticate/add'*
>>
>>
>> <%
>> var METHOD = request.getMethod();
>> var log = new Log();
>> switch (METHOD) {
>> case 'GET':
>>     var baseUrl = request.getParameter('baseUrl');
>>     var scope = request.getParameter('scope');
>>     var redirectUri = request.getParameter('redirecturi');
>>     var clientId = request.getParameter('clientid');
>>     var arc = request.getParameter('acrvalue');
>>     var responseType = request.getParameter('responsetype');
>>     var operator = request.getParameter('operator');
>>     var msisdn = request.getParameter('msisdn');
>>     var nonce = request.getParameter('nonce');
>>     var state = request.getParameter('state');
>>     var url  = baseUrl+"/user-registration/we
>> bresources/endpoint/user/authenticate/add?scope=" + scope +
>> "&redirecturi=" + redirectUri + "&clientid=" + clientId + "&acrvalue=" +
>> arc + "&responsetype=" + responseType + "&operator=" + operator +
>> "&msisdn=" + msisdn+"&nonce="+nonce+"&state="+state;
>>     var response = get(url,{},"json");
>>     log.info(response);
>>     //log.info(response.data.);
>>
>> }
>> %>
>>
>>
>> The above approach did not work. When invoke the .jsp file it fails with
>> HTTP error code : 500 at conn.getResponseCode() != 200 condition check.
>>
>> Can anyone point me to a proper way to acheive calling to JAX-RS endpoint
>> through jaggery api, which in turn is called inside JSP file?
>>
>> Thanks,
>>
>> --
>> Denuwanthi De Silva
>> Senior Software Engineer;
>> WSO2 Inc.; http://wso2.com,
>> Email: [email protected]
>> Blog: https://denuwanthi.wordpress.com/
>>
>
>
>
> --
> Sameera Medagammaddegedara
> Software Engineer
>
> Contact:
> Email: [email protected]
> Mobile: + 94 077 255 3005
>



-- 
Sameera Medagammaddegedara
Software Engineer

Contact:
Email: [email protected]
Mobile: + 94 077 255 3005
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to