How to return page from service

Dear team,

 

we need to return some user-friendly result from anonymous service method, not Json or Xml. Use case is as follows: end user receives email with link, which is opened in browser. So we need to return some Html page from the method, or link to static content that will inform user about result of his action. Something in a way, as is implemented for the case-rating (see screenshot)

Is there a suggested method to implement such behavior? 

 

Thanks!

Like 0

Like

7 comments

Hi Iuliia, 

 

Alas, this is an unsafe approach to use an anonymous web-service to return an HTML-page. This may do harm to the user's data and safety. Could you please specify if an anonymous web-service is the only preferable method for you? 

 

Here is also an option to perform your task using a configuration web-service. Please find the instruction by the link below:

 

https://academy.creatio.com/documents/technic-sdk/7-16/creating-configu…

 

Please let us know if you need any additional assistence. 

 

Regards, 

Anastasiia

Anastasiia Markina,

for the task at hand it's preferable for us to use anonymous web-service. It will have limited endpoints for sure, and with action validation. Simplified business flow is that internal user receives some question with yes/no selection (two links, with user-specific id's for each case), clicks on one of them => application receives this answer and returns some message to the user that will notify him/her that the answer was stored successfully or not. We want to use anonymous web-service to improve user experience - not to force them to login to system for such actions. 

Thanks for you suggestion, but unfortunately I can't seem to the answer for my question here.  In example there is  ResponseFormat = WebMessageFormat.Json (or Xml) which is not suitable for task at hand - they are parsed in not user-friendly response by browser. 

What I was asking,  if there is a possibility to return any user-friendly response from the service method(could be as well redirection link to some statically stored image which will hold the message that user should receive). 

 

Best regards, Iuliia

Iuliia Diakiv,

 

We strongly discourage you from using an anonymous web-service to return any data as this may threaten the safety of the whole system. 

 

To show a user any readable page (HTML or an image), you can easily store it at the directory of your instance and call it from there as usual. 

 

Regards, 

Anastasiia

Anastasiia Markina,

ok, I got your consern about using anonymous web service. But how can I return link to html page from general service, which you've suggested to use in your first comment? I can't seem to find the solution myself

 

Regards, Iuliia

Iuliia Diakiv,

 

We have been looking for the correct solution for your purpose. The best way to return the HTML-page without authentication and without threatening to system safety, at the same time, is to create a static HTML page.

 

Please put it to your root project directory: Terrasoft.WebApp > Nui

Then, a user will be able to open it as a standard HTML web page.

 

Regards, 

Anastasiia

Hi Anastasiia Markina,

 

Could you please let me know how to call/ return the HTML page from the anonymous service?



Edit : Adding below code worked.

 

WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Redirect;

WebOperationContext.Current.OutgoingResponse.Headers.Add("Location", "http://localhost:97/0/Nui/ThankYouPage.html" );

Shivani Lakshman,

 

According to Anastasiia explanation we don't have practical examples of such implementation.

 

https://academy.creatio.com/documents/technic-sdk/7-16/creating-anonymo…

 

As mentioned in this article you may use couple of web services.

 

Alternatively, OData will be the most flexible to achieve most of required scenarios:

 

https://documenter.getpostman.com/view/10204500/SztHX5Qb?version=latest

 

As for example check this article how to get some data like files and you may change it according to your needed: 

 

https://community.creatio.com/questions/how-download-attachments-section

 

Hopefully it will be useful for you!

 

Regards, 

 

Bogdan L.

Show all comments