web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Why is Dynamics GP WebService returning: Security object does not exist. Key = 0 for a companykey ID set as (-1)

(0) ShareShare
ReportReport
Posted on by 35

Hi,

I have this issue trying to integrate a web application with Dynamics GP. I have followed the documentation for doing that but it returns an error. Going through the MicrosoftDynamicsWebServiceException Console reveals "Security object does not exist.  Key = 0" as the error, which means that there was communication with GP service but there is no company with key 0. I have gone through a lot of blogs including this community but the recommendations are not giving any solution, also I found no response that resolved the issue. I also came accross this popular response: https://mbs.microsoft.com/knowledgebase/KBDisplay.aspx?WTNTZSMNWUKNTMMYVLXUZLWUKKQPOVRVTLKUSRMOQVVYUKKXRVYRTTWLZTPWKURU to no avail. 

NB: I am not using ADAM for storage and the SQL check for company id returns the right ID (-1).  I'm running in a domain environment within a development machine.

The XML request is as follows:

<?xml version="1.0"?>
<RequestObjects>
  <Context xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/dynamics/2006/01">
    <OrganizationKey xsi:type="CompanyKey">
      <Id>0</Id>
    </OrganizationKey>
    <CurrencyType>Transactional</CurrencyType>
    <TenantName />
  </Context>
  <GLAccountCriteria xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <IsActive>
      <EqualValue xsi:nil="true" />
      <NotEqualValue xsi:nil="true" />
    </IsActive>
  </GLAccountCriteria>

</RequestObjects>

 

while my code is:

        Dim companyKey As CompanyKey
        Dim context As Context
        Dim GLAccountSummaryList() As GLAccountSummary
        Dim GLAccountCriteria As GLAccountCriteria
        Dim accountActiveRestriction As RestrictionOfNullableOfboolean

        ' Create an instance of the service
        Dim wsDynamicsGP As New DynamicsGPClient()

        ' Create a context with which to call the service
        context = New Context()

        ' Specify which company to use (sample company)
        companyKey = New CompanyKey()
        companyKey.Id = (-1)

        ' Set up the context
        context.OrganizationKey = CType(companyKey, OrganizationKey)
        'context.OrganizationKey = Nothing

        ' Set the criteria specifying wich accounts to retrieve
        GLAccountCriteria = New GLAccountCriteria()
        accountActiveRestriction = New RestrictionOfNullableOfboolean()
        accountActiveRestriction.EqualValue = True
        GLAccountCriteria.IsActive = accountActiveRestriction

        ' Retrieve the list of active accounts
        GLAccountSummaryList = wsDynamicsGP.GetGLAccountList(GLAccountCriteria, context)


        ' Display the total number of active accounts
        Dim message = New message
        message.ShowAlert(Me, "Total active accounts:" & GLAccountSummaryList.Length.ToString())

        ' Close the service
        If wsDynamicsGP.State <> CommunicationState.Faulted Then
            wsDynamicsGP.Close()
        End If

WebConfig:

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="GPWebService" closeTimeout="00:01:00" openTimeout="00:01:00"
          receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
          transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" proxyAddress="http://localhost:2000"
          textEncoding="utf-8" useDefaultWebProxy="false" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://SERVERNAME:48620/Dynamics/GPService/GPService"
        binding="wsHttpBinding" bindingConfiguration="GPWebService"
        contract="DynamicsGPService.DynamicsGP" name="GPWebService">
        <identity>
          <userPrincipalName value="Domain\UserID" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

I've been on this for a week now

Please help......

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    soma Profile Picture
    24,410 on at

    Please have a look on the below links.

    support.microsoft.com/.../943949

    community.dynamics.com/.../109765.aspx

    Hope this helps!!!

  • Olufemi Ogunlolu Profile Picture
    35 on at

    Thanks Somakarpagamoorthy,

    The first link you post is the same as the the one in my first post. I have gone through the steps:

    1. "Select INTERID as [Database Name], CMPANYID as [Scope Key] From SY01500" returns the right ID.

    2. I'm not using ADAM for Authorization Store.

    3. I have carried out this step more twice. Still no resolution.

    NB: Running the code below returns the number of companies in GP (I believe it works because its retrieving the information from Dynamics Database).

               ' Create an instance of the service

               Dim wsDynamicsGP As New DynamicsGPClient()

               ' Create a restriction object to query by company ID

               ' Query for all possible company ID values

               companyRestriction = New BetweenRestrictionOfNullableOfint()

              companyRestriction.From = -32768

               companyRestriction.To = 32767

               ' Create a company criteria object and add the restriction object

               companyCriteria = New CompanyCriteria()

               companyCriteria.Id = companyRestriction

               ' Retrieve the list of companies

               companyList = wsDynamicsGP.GetCompanyList(companyCriteria, context)

     

    Any other idea where the issue could be?

    Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans