Hi,
I am trying to set up an anonymous webservice. It works fine if you are authenticated but will not work anonymously. We are on cloud instance so I had to get support to register it, so I'm not able to see exactly what they did on the back end and they will not show me.
https:///0/rest/UsrMPF.svc/ipf?p=c8443763-8d5a-4692-a19f-6a406e29319a&s=10
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.
I have also tried it using this alternate link, same issue but different error.
https:///0/ServiceModel/UsrMPF.svc/ipf?p=c8443763-8d5a-4692-a19f-6a406e29319a&s=10
The server encountered an error processing the request. The exception message is 'Object reference not set to an instance of an object.'. See server logs for more details. The exception stack trace is:
at Terrasoft.Configuration.UsrAnonWebServ.UsrMPF.ipf(String p, Int32 s) at SyncInvokeipf(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at Terrasoft.Web.Common.ServiceModel.ThreadContextInitializer.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
I will post my code below. Any ideas on what could be missing?
namespace Terrasoft.Configuration.UsrAnonWebServ { using System; using System.ServiceModel; using System.ServiceModel.Web; using System.ServiceModel.Activation; using Terrasoft.Core; using Terrasoft.Web.Common; using Terrasoft.Core.Entities; [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] public class UsrMPF: BaseService { private SystemUserConnection _systemUserConnection; private SystemUserConnection SystemUserConnection { get { return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection); } } [OperationContract] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] public string ipf(string p, int s){ /* Specify the user on whose behalf to process the HTTP request. */ SessionHelper.SpecifyWebOperationIdentity(HttpContextAccessor.GetInstance(), SystemUserConnection.CurrentUser); var entity = UserConnection.EntitySchemaManager.GetInstanceByName("UsrManifestPassengers"); var assignersEntity = entity.CreateEntity(UserConnection); if (assignersEntity.FetchFromDB(p)) { assignersEntity.SetColumnValue("UsrCustomerFeedback", s); assignersEntity.Save(); //return "Thank you for your feedback."; return SystemUserConnection.CurrentUser.ToString(); } return "Your feedback did not submit successfully. Please try again."; } } }
Like
These were the instructions I had sent support.
So I need you create the svc file in ..\Terrasoft.WebApp\ServiceModel. It should be called UsrMPF.svc The file needs the following record: <% @ServiceHost Service = "Terrasoft.Configuration.UsrAnonWebServ.UsrMPF" Debug = "true" Language = "C#" %> Add the following record to the ..\Terrasoft.WebApp\ServiceModel\http\services.config and ..\Terrasoft.WebApp\ServiceModel\https\services.config <services> ... <service name="Terrasoft.Configuration.UsrAnonWebServ.UsrMPF"> <endpoint name="UsrMPFEndPoint" address="" binding="webHttpBinding" bindingConfiguration="[Custom encoding]" behaviorConfiguration="RestServiceBehavior" bindingNamespace="http://Terrasoft.WebApp.ServiceModel" contract="Terrasoft.Configuration.UsrAnonWebServ.UsrMPF" /> </service> </services> Update the web.config file: <configuration> ... <location path="ServiceModel/UsrMPF.svc"> <system.web> <authorization> <allow users="*" /> </authorization> </system.web> </location> ... </configuration> and <configuration> ... <appSettings> ... <add key="AllowedLocations" value="[Previous values];ServiceModel/UsrMPF.svc" /> ... </appSettings> ... </configuration> Restart Creatio in IIS.
Dear Heather,
Thanks for posting your question!
For security reasons, we kindly advise our users not to share the URLs of the instances.
To get a consultation on setting up a Webservice, please contact your manager, and we'll find a solution for you.
Thank you in advance!
Best regards,
Anastasiia