Updating entities in WCF services

We have a SOAP service that we would like to use for handling orderstatus and inventory integration with an ERP.
But we have a problem with the service injection. We can’t inject the services in the regular way like in the other regular MVC controllers and so on, and if we use the IoC to resolve the services we get a ‘Litium.Security.AuthorizationException’ when updating an entity.
Is there any good ways to solve this?

Litium version: 7.0.2

If you register your service you should be able to use constructor injection.

To edit entities in the new api you need to wrap your calls to use a token with required permissions:

using (Solution.Instance.SystemToken.Use())
{
   variantService.Update(variant);
}

We tried that, but it wouldn’t work. We got this error:
The service type provided could not be loaded as a service because it does not have a default (parameter-less) constructor. To fix the problem, add a default constructor to the type, or pass an instance of the type to the host.

However, using the IoC and then the code you supplied worked great!

I am having a similar issue, while creating currency.

I was trying to setup base for website.

Solution.Instance.SystemToken is null.

image

I have setup my accelerator, but I have not created any channels or website.
My plan is to create everything from code, so I started with language, which worked.
but now when I started with currency i get this exception.

Litium.Security.AuthorizationException: ‘Exception_WasThrown’

Litium 8.3.1

You should not use the token, instead you should use SecurityContextService:
Information in developer training

1 Like

Sure, thanks, this solved my issue.