# Updating entities in WCF services

**URL:** <https://forum.litium.com/t/updating-entities-in-wcf-services/514>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [January 21, 2019, 7:52pm UTC](https://forum.litium.com/t/updating-entities-in-wcf-services/514 "2019-01-21T19:52:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![PontvsXlent](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@PontvsXlent](https://forum.litium.com/u/PontvsXlent)\
**Post date:** [January 21, 2019, 7:52pm UTC](https://forum.litium.com/t/updating-entities-in-wcf-services/514/1 "2019-01-21T19:52:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [January 22, 2019, 8:09am UTC](https://forum.litium.com/t/updating-entities-in-wcf-services/514/2 "2019-01-22T08:09:49Z")

</div>

If you [register your service](https://docs.litium.com/documentation/architecture/dependency-injection/service-registration) 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:

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

---

<div class="post-metadata">

**Author:** ![PontvsXlent](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@PontvsXlent](https://forum.litium.com/u/PontvsXlent)\
**Post date:** [January 22, 2019, 8:15am UTC](https://forum.litium.com/t/updating-entities-in-wcf-services/514/3 "2019-01-22T08:15:25Z")

</div>

> [@marten](#):
>
> If you [register your service](https://docs.litium.com/documentation/architecture/dependency-injection/service-registration) you should be able to use constructor injection.

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!

---

<div class="post-metadata">

**Author:** ![control](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@control](https://forum.litium.com/u/control)\
**Post date:** [May 4, 2022, 8:32am UTC](https://forum.litium.com/t/updating-entities-in-wcf-services/514/4 "2022-05-04T08:32:43Z")

</div>

I am having a similar issue, while creating currency.

I was trying to setup base for website.

Solution.Instance.SystemToken is null.

![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/859dde85b2a7b03781c169109f7be90b581a4076.png)

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

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [May 4, 2022, 11:07am UTC](https://forum.litium.com/t/updating-entities-in-wcf-services/514/5 "2022-05-04T11:07:52Z")

</div>

You should not use the token, instead you should use `SecurityContextService`:  
[Information in developer training](https://litiumdev-slides.svc.litiumlab.se/#83)

---

<div class="post-metadata">

**Author:** ![control](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@control](https://forum.litium.com/u/control)\
**Post date:** [May 4, 2022, 11:22am UTC](https://forum.litium.com/t/updating-entities-in-wcf-services/514/6 "2022-05-04T11:22:44Z")

</div>

Sure, thanks, this solved my issue.

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [May 4, 2022, 11:23am UTC](https://forum.litium.com/t/updating-entities-in-wcf-services/514/7 "2022-05-04T11:23:21Z")

</div>


