+ Add post
Hello Community,
I have a PrestaShop website to allow my important customers to simplify their hardware orders. I am therefore in the process of developing a webservice to interface the two systems, the exchange of data being done in Json format.
The first feasibility tests were done in version 7.18.5 of Creatio with libraries
We have now moved to a new phase on a Creatio 8.0.5 and the USING of these libraries now cause problems when compiling...
Have you encountered this anomaly before? Do you have examples of Json deserialization code with other libraries?
Thank you in advance for your help.
Vincent
Like
Greetings, We have checked the information with our R&D team and it is as follows: Newtonsoft.Json; Newtonsoft.Json.Linq; Both of these should work with no problem with the new versions of Creatio, but System.Web.Script Needs some adjustments from your side, since you have an on-site system. The adjustments are as follows: Within the file \Terrasoft.WebApp\Terrasoft.Configuration\Terrasoft.Configuration.Dev.csproj Within this section: <ItemGroup Label=".NET references"> You should add this reference <Reference Include="System.Web.Extensions" /> And correctly use the beforementioned libraries (Newtonsoft.Json; Newtonsoft.Json.Linq;) in C# schemas
Hello Mykhailo Zeleniuk, Right now, my code is very simple (see screenshot), so I'm bothered by the compilation error... Especially since the same code worked in version 7.18.5.
Someone would have examples of Json deserialization code with other libraries than Newtonsoft ?
Thanks
LAVIGNE Vincent,
I did an example of a webservice that returns a JSON string result using only System; and System.Text.Json. The code is below:
namespace Terrasoft.Configuration.UsrCustomServiceNamespace { using System; using System.Text.Json; using System.ServiceModel; using System.ServiceModel.Web; using System.ServiceModel.Activation; using Terrasoft.Core; using Terrasoft.Web.Common; using Terrasoft.Core.Entities; public class SerializedObject { public string FirstPart { get; set; } public string SecondPart { get; set; } public string ThirdPart { get; set; } } [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] public class UsrCustomService: BaseService { private SystemUserConnection _systemUserConnection; private SystemUserConnection SystemUserConnection { get { return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection); } } [OperationContract] [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] public string ReturnCustomResult(string param1, string param2, string param3) { var objectToSerialize = new SerializedObject { FirstPart = param1, SecondPart = param2, ThirdPart = param3, }; string jsonString = JsonSerializer.Serialize(objectToSerialize); return jsonString; } } }
As a result calling this endpoint http://localhost:1026/0/ServiceModel/UsrCustomService.svc/ReturnCustomR… returned this result:
{"ReturnCustomResultResult":"{\"FirstPart\":\"test1\",\"SecondPart\":\"test2\",\"ThirdPart\":\"test3\"}"}
So you can this approach on your side as well.
And the test was performed in 8.0.6 full bundle application (sales + marketing + service) MS SQL.
Hello Oleg Drobina,
Thank you very much for your answer, I will try to adapt your example code to my case. Indeed, I want to retrieve a JSON which is in the body of the HTTP request, so do more of a "Deserialize" request.
If you have an example of code in this way too, I am interested.