Hello,
I'm asking for your help in providing me with the following information please ..
I would like to retrieve data from database and display it in portal section.. Is there any way to call a custom web service in the portal section?
I added the handler method below but didn't work.
methods: { onGetServiceName: function() { var type = "RH"; var serviceData = { type: type }; /* Call the service method. */ ServiceHelper.callService("UsrGetTileService", "GetTileServiceName", function(response) { var result = response.GetTileServiceNameResult; return result; }, serviceData, this); } }, diff: /**SCHEMA_DIFF*/[ {"operation": "insert", "name": "element21", "parentName": "GridDataContainer1", "propertyName": "items", "values": { "itemType": Terrasoft.ViewItemType.LABEL, "caption": {"bindTo": "onGetServiceName"}, "classes": {"labelClass": ["content__title2"]}, "enabled": true, "visible": true, "items": [] }, "index": 1 }, ]/**SCHEMA_DIFF*/,
Thank you,
Mouna.
Like
Hi Mouna,
To properly call the service from portal you need to:
1) Add the following assemblies as a reference to your service class:
using Terrasoft.Web.Common; using Terrasoft.Web.Common.ServiceRouting;
2) Specify routing for SSP (portal users) users and leave regular users routing:
[DefaultServiceRoute, SspServiceRoute] [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] public class UsrAnonymousConfigurationService: BaseService { ...
3) Make sure that your method in the service uses the POST request since ServiceHelper.callService sends the POST query by default.
As a result the service call will be properly completed from the portal.
Best regards,
Oscar
Hello Oscar ,
Could you please confirm the following code is correct or not?
namespace Terrasoft.Configuration.UsrGetTileService { using System; using System.ServiceModel; using System.ServiceModel.Web; using System.ServiceModel.Activation; using System.Runtime.Serialization; using Terrasoft.Core; using Terrasoft.Core.DB; using Terrasoft.Common; using Terrasoft.Web.Common; using Terrasoft.Web.Common.ServiceRouting; using Terrasoft.Core.Entities; [DefaultServiceRoute, SspServiceRoute] [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] public class UsrGetTileService: BaseService { [OperationContract] [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] public string GetTileServiceName(string type) { var myQuery = new Select(UserConnection) .Column("Name") .From("ServiceItem") .Where("UsrServiceType.Name") .IsEqual(Column.Parameter(type)) as Select; string result = myQuery.ExecuteScalar<string>(); return result; } } }
Thank you in advance for your help .
Best regards,
Mouna.
Mouna RACHIDI,
Hello,
If this code doesn't return error messages when publishing it then it's correct. If something doesn't work after that then you need to catch the result on the client-side where you call the service and see which result is returned.
Best regards,
Oscar