如何追踪AIF网络服务的SOAP消息
为了排除故障,有时候需要知道发送到AIF服务的确切SOAP消息。因此我们收到很多关于如何追踪消息的问题。该问题并不直接和AX 相关,因为您可以使用以下方法追踪包括AIF网络服务在内的任何服务。
得到SOAP消息的一个简单方法如下:
1.根据链接创建C#客户端:https://msdn.microsoft.com/en-us/library/cc652581.aspx
2.然后在您程序自动生成的app.config中加入追踪信息(参见https://bloggingabout.net/blogs/chilberto/pages/wcf-service-trace.aspx )。如此我的app.config看上去如下:
<?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="https://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.运行C#程序,将会在C:\logs\生成Log.svclog文件
4.在C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin目录下您可以找到SvcTraceViewer.exe。双击它并加载刚生成的日志文件。
5.您将会看见所有的追踪信息以及SOAP信封。
原文地址: