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 AX (Archived)

Aif custom service error (wsHttpBinding)

(0) ShareShare
ReportReport
Posted on by

I'm facing a very strange issue with a custom AX 2012 R3 CU9 AIF WCF service.

My goal is to use my AX wcf service with wsHttpBinding + Basic authentication + TransactionFlow enabled.

This error occurs every time I try to add a service reference for this service in VS \ open a service link in a browser:

Object Server 01:  An error has occurred in the services framework.  Method: AifMessageInspector::AfterReceiveRequest.  Error: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Dynamics.Ax.Services.AxServiceOperationContext.InitializeSession()
   at Microsoft.Dynamics.Ax.Services.AxServiceOperationContext.InitializeContext()
   at Microsoft.Dynamics.Ax.Services.AxServiceOperationContext.Attach(OperationContext owner)
   at System.ServiceModel.ExtensionCollection`1.InsertItem(Int32 index, IExtension`1 item)
   at System.Collections.Generic.SynchronizedCollection`1.Add(T item)
   at Microsoft.Dynamics.Ax.Services.AifMessageInspector.AfterReceiveRequest(Message& request, IClientChannel channel, InstanceContext instanceContext)

IIS:

  • Enabled only Anonymous and Basic authentication
  • Created self-signed certificate and added it to Server certificates on the host, "Trusted Root Certification Authorities" and "Enterprise Trust" folders
  • Enabled https binding on this web-site with this certificate
  • Checked "Require SSL" option on the web-site

AX:

  • HTTP inbound port
  • Use 'Configure AOS' instead of 'Configure' option
  • Use wsHttpBinding with Transport security and TransportClientCredentialType = Basic
  • Full CIL regenerated

Web config (aos.config) that AX generates:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.diagnostics />
 <system.serviceModel>
        <diagnostics>
   <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
    logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
   <endToEndTracing propagateActivity="true" activityTracing="true"
    messageFlowTracing="true" />
  </diagnostics>
  <bindings>
   <wsHttpBinding>
    <binding name="wsHttpBindingTransportBasic" transactionFlow="true">
     <security mode="Transport">
      <transport clientCredentialType="Basic" />
     </security>
    </binding>
   </wsHttpBinding>
  </bindings>
        <behaviors>
   <serviceBehaviors>
    <behavior name="DefaultServiceGroupBehavior">
     <serviceMetadata httpGetEnabled="false" httpGetUrl="ax2012r2a/.../xppservice.svc"
      httpsGetEnabled="true" httpsGetUrl="ax2012r2a/.../xppservice.svc" />
     <serviceDebug includeExceptionDetailInFaults="true" />
     <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200"
      maxConcurrentInstances="200" />
     <useRequestHeadersForMetadataAddress />
    </behavior>
   </serviceBehaviors>
  </behaviors>
        <services>
   <service behaviorConfiguration="DefaultServiceGroupBehavior"
    name="Microsoft.Dynamics.Ax.Services.WCFService">
    <endpoint address="ax2012r2a/.../xppservice.svc"
     binding="wsHttpBinding" bindingConfiguration="wsHttpBindingTransportBasic"
     name="DefaultServiceGroupEndPoint" contract="Microsoft.Dynamics.Ax.Services.ServiceGroup" />
   </service>
  </services>
        <client>
   <endpoint address="ax2012r2a/.../xppservice.svc"
    binding="wsHttpBinding" bindingConfiguration="wsHttpBindingTransportBasic"
    contract="*" name="DefaultServiceGroupEndPoint" />
  </client>
    </system.serviceModel>
</configuration>

What could be happening?

Any help would be highly appreciated.

Thank you.

*This post is locked for comments

I have the same question (0)
  • Vilmos Kintera Profile Picture
    46,149 on at

    Microsoft has provided a blog article on this, check if it is helpful:

    blogs.msdn.microsoft.com/.../how-to-implement-basic-authentication-with-dynamics-ax-2012-web-services

  • Community Member Profile Picture
    on at

    In that article they use basicHttpBinding (which works), not wsHttpBinding. I need to use this type of binding because I need to use TransactionFlow and only netTcpBinding, netNamedPipeBinding, wsHttpBinding, wsDualHttpBinding, and wsFederationHttpBinding are transaction-aware.

  • Vilmos Kintera Profile Picture
    46,149 on at

    Maybe it does not work with the Basic authentication correctly. You could try to set TransportClientCredentialType=NTLM to verify if it is able to pass through user information correctly, just for the sake of troubleshooting with Windows Authentication=Enabled.

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 AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans