Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Unable to authenticate(?) with Native Endpoint: BadContextToken

Posted on by Microsoft Employee

I'm trying (very hard) to implement a SOAP client for the MDGP using a couple of PHP libraries, as a means to synchronize information with PHP services.

From what I could infer from the basic documentation (focused on Microsoft developers only) and sparse Google results (should I use Bing instead?), I included WSA headers, then implemented NTLM, then saw the GP server doesn't like the way cURL handles NTLM and took it out, and moved into WSSE authentication.

However, I still receive the same response as usual (when one response even comes, as faulty XML usually yields an empty and generic 400 response): BadContextToken, mentioning the action (taken from the Native WSDL file) could be wrong, or the security context token could be invalid or expired.

Currently, this is the list of additional "features" I'm packing on my XML payload, transported through plain HTTP:

  • WSA header with action, to, message-id and reply-to
  • WSSE with username, password digest, nonce and created timestamp

Would someone knowledgeable on the SOAP dialect used by MDGP be able to verify what's wrong with my request? Here follows a sample XML (stripped of server address and other sensitive data):

POST /Dynamics/GPService/GPService HTTP/1.1
Host: xyz-server.com:48620
Content-Length: 1596
Content-Type: application/soap+xml; charset="utf-8"; action="schemas.microsoft.com/.../GetCustomerList"

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="www.w3.org/.../soap-envelope" xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:ns1="schemas.datacontract.org/.../Microsoft.Dynamics.Common" xmlns:ns2="schemas.datacontract.org/.../Microsoft.Dynamics.GP" xmlns:ns3="schemas.microsoft.com/.../01" xmlns:wsa="www.w3.org/.../addressing">
  <env:Header>
    <wsa:Action>schemas.microsoft.com/.../GetCustomerList&lt;/wsa:Action>
    <wsa:To>xyz-server.com/.../GPService&lt;/wsa:To>
    <wsa:MessageID>uuid:72ce1a62-40e3-e3dc-3c97-c7cc2c997b56</wsa:MessageID>
    <wsa:ReplyTo>
      <wsa:Address>schemas.xmlsoap.org/.../anonymous&lt;/wsa:Address>
    </wsa:ReplyTo>
    <wsse:Security xmlns:wsse="docs.oasis-open.org/.../oasis-200401-wss-wssecurity-secext-1.0.xsd" env:mustUnderstand="1">
      <wsse:UsernameToken>
        <wsse:Username>PROPER.DOMAIN\PROPER_USER</wsse:Username>
        <wsse:Password Type="docs.oasis-open.org/.../oasis-200401-wss-username-token-profile-1.0">d1g3stP4ssw0rd==</wsse:Password>
        <wsse:Nonce>sha1-nonce-here</wsse:Nonce>
        <wsu:Created xmlns:wsu="docs.oasis-open.org/.../oasis-200401-wss-wssecurity-utility-1.0.xsd">2018-02-07T03:27:31Z</wsu:Created>
      </wsse:UsernameToken>
      <wsu:Timestamp xmlns:wsu="docs.oasis-open.org/.../oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <wsu:Created>2018-02-07T03:27:31Z</wsu:Created>
        <wsu:Expires>2018-02-07T04:27:31Z</wsu:Expires>
      </wsu:Timestamp>
    </wsse:Security>
  </env:Header>
  <env:Body>
    <ns3:GetCustomerList>
      <ns3:criteria>
        <ns1:columns xsi:nil="true"/>
        <ns1:convertToUpperCaseRestriction xsi:nil="true"/>
        <ns1:restrictions xsi:nil="true"/>
        <ns2:ClassId xsi:nil="true"/>
        <ns2:CorporateAccountId xsi:nil="true"/>
        <ns2:CreatedDate xsi:nil="true"/>
        <ns2:Id xsi:nil="true"/>
        <ns2:IsActive xsi:nil="true"/>
        <ns2:IsOnHold xsi:nil="true"/>
        <ns2:LastModifiedDate>
          <ns1:From xsi:nil="true"/>
          <ns1:GreaterThan>2018-01-01T00:00:00+00:00</ns1:GreaterThan>
          <ns1:LessThan xsi:nil="true"/>
          <ns1:To xsi:nil="true"/>
        </ns2:LastModifiedDate>
        <ns2:ModifiedDate xsi:nil="true"/>
        <ns2:Name xsi:nil="true"/>
        <ns2:PhoneNumber xsi:nil="true"/>
        <ns2:SalespersonId xsi:nil="true"/>
        <ns2:State xsi:nil="true"/>
      </ns3:criteria>
      <ns3:context xsi:nil="true"/>
    </ns3:GetCustomerList>
  </env:Body>
</env:Envelope>

*This post is locked for comments

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans