For troubleshooting reasons sometimes is needed what exactly SOAP message is sent to AIF service. So we get a lot of questions how can we track such a message. The problem is not directly connected to Dynamics AX because using following method you can track every service included AIF Web service.

The easy way to get SOAP message can be:

1. Create C# client as described in: http://msdn.microsoft.com/en-us/library/cc652581.aspx

2. Then add traces information to app.config created automatically for your application (as mentioned http://bloggingabout.net/blogs/chilberto/pages/wcf-service-trace.aspx). So my app.config look following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>  <system.diagnostics>
   <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true" >
        <listeners>
          <add name="xml"/>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="xml"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\logs\Log.svclog" />
    </sharedListeners>
  </system.diagnostics>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_SalesOrderService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Message">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="">
                            <extendedProtectionPolicy policyEnforcement="Never" />
                        </transport>
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" establishSecurityContext="true" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://server.europe.corp.microsoft.com/MicrosoftDynamicsAXAif50/salesorderservice.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_SalesOrderService"
                contract="ServiceReferenceAIF.SalesOrderService" name="WSHttpBinding_SalesOrderService">
                <identity>
                    <userPrincipalName value="USER@domain" />
                </identity>
            </endpoint>
        </client>
      <!-- add trace logging -->
      <diagnostics wmiProviderEnabled="true">
        <messageLogging
             logEntireMessage="true"
             logMalformedMessages="true"
             logMessagesAtServiceLevel="true"
             logMessagesAtTransportLevel="true"
             maxMessagesToLog="3000"
       />
      </diagnostics>
    </system.serviceModel>
</configuration> 

3. Run C# program in C:\logs\ there will be file Log.svclog created

4. In C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin you can find SvcTraceViewer.exe you can just double click it to open then you can load the log created.

5. You will see all tracing information and also SOAP envelope

 

--author: Czesława Langowska
--editor: Czesława Langowska
--date: 06-12-2010