Good question. Recently I created a .Net Core WebApi project and it is working fine. Here is what I did:
Finally, here is an example of me calling the Core Service. Note, all methods in the Proxy are using Async. If you need to call a method without Async, then put .Result at the end of the call to the Core Service. But, I suggest to try to implement Task and Await as much as possible. I had to do this while requesting a PageData object:
PageData page = (PageData)client.ReadAsync(pageUri, new ReadOptions()).Result;
And here is the code to call the Core Service, and below it, 2 methods in the reference.cs file (in the Connected Services section of the Project)
[HttpGet]
[Route("getapiversion")]
public async Task<ActionResult<string>> GetApiVersion()
{
CoreServiceClient client = new CoreServiceClient(CoreServiceClient.EndpointConfiguration.basicHttp, CoreServiceClient.TridionEnvironment.qa);
try
{
string userName = "tridionUser";
string password = "tridionPw";
string domain = "domain";
NetworkCredential creds = new NetworkCredential(userName, password, domain);
client.ClientCredentials.Windows.ClientCredential = creds;
return await client.GetApiVersionAsync();
}
catch(Exception)
{
return this.StatusCode(StatusCodes.Status500InternalServerError, "Issues connecting to Tridion");
}
}
// In Reference.cs
private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration, TridionEnvironment environment)
{
if ((endpointConfiguration == EndpointConfiguration.basicHttp))
{
if (environment == TridionEnvironment.qa)
{
return new System.ServiceModel.EndpointAddress("http://TridionCMS/webservices/CoreService2013.svc/basicHttp");
}
else if (environment == TridionEnvironment.dev)
{
return new System.ServiceModel.EndpointAddress("http://TridionCMS/webservices/CoreService2013.svc/basicHttp");
}
else if (environment == TridionEnvironment.prod)
{
return new System.ServiceModel.EndpointAddress("https://TridionCMS/webservices/CoreService2013.svc/basicHttp");
}
else
{
// default is QA
return new System.ServiceModel.EndpointAddress("http://TridionCMS/webservices/CoreService2013.svc/basicHttp");
}
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
public enum EndpointConfiguration
{
basicHttp,
}
public enum TridionEnvironment
{
dev,
qa,
prod
}