Dynamics 365 SOAP Logger

Leave a comment

The SOAP Logger is a tool that is located in the CRM SDK at: SDK\SampleCode\CS\Client\SOAPLogger

You will see the files:

Open the solution in Visual Studio. Update any references. Open the SOAPLogger.cs file. You will see:

Find the run procedure:

This procedure will run a command and then write to an output.txt file the SOAP request and response. Add some code, for example all accounts that contain “a”:

var query = new QueryExpression("account");
query.Criteria.AddCondition("name", ConditionOperator.Equal, "Microsoft");
slos.RetrieveMultiple(query);

Build and run the solution. You will be prompted to enter your server details. The code will then run:

Now go to your debug folder. You will see an ouput file has been created.

The output file will contain request and response details.

HTTP REQUEST
--------------------------------------------------
POST https://xxxxxxx.api.crm.dynamics.com/XRMServices/2011/Organization.svc/web
Content-Type: text/xml; charset=utf-8
SOAPAction: http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/RetrieveMultiple

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
 <RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
 <query i:type="a:QueryExpression" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
 <a:ColumnSet>
 <a:AllColumns>false</a:AllColumns>
 <a:Columns xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
 </a:ColumnSet>
 <a:Criteria>
 <a:Conditions>
 <a:ConditionExpression>
 <a:AttributeName>name</a:AttributeName>
 <a:Operator>Equal</a:Operator>
 <a:Values xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
 <b:anyType i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">Microsoft</b:anyType>
 </a:Values>
 <a:EntityName i:nil="true" />
 </a:ConditionExpression>
 </a:Conditions>
 <a:FilterOperator>And</a:FilterOperator>
 <a:Filters />
 </a:Criteria>
 <a:Distinct>false</a:Distinct>
 <a:EntityName>account</a:EntityName>
 <a:LinkEntities />
 <a:Orders />
 <a:PageInfo>
 <a:Count>0</a:Count>
 <a:PageNumber>0</a:PageNumber>
 <a:PagingCookie i:nil="true" />
 <a:ReturnTotalRecordCount>false</a:ReturnTotalRecordCount>
 </a:PageInfo>
 <a:NoLock>false</a:NoLock>
 </query>
 </RetrieveMultiple>
 </s:Body>
</s:Envelope>
--------------------------------------------------

Response:

HTTP RESPONSE
--------------------------------------------------
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
 <RetrieveMultipleResponse xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
 <RetrieveMultipleResult xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
 <a:Entities>
 <a:Entity>
 <a:Attributes xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
 <a:KeyValuePairOfstringanyType>
 <b:key>accountid</b:key>
 <b:value i:type="c:guid" xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/">d3ae1b3a-8bd2-e411-80ef-c4346bac7be8</b:value>
 </a:KeyValuePairOfstringanyType>
 </a:Attributes>
 <a:EntityState i:nil="true" />
 <a:FormattedValues xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
 <a:Id>d3ae1b3a-8bd2-e411-80ef-c4346bac7be8</a:Id>
 <a:KeyAttributes xmlns:b="http://schemas.microsoft.com/xrm/7.1/Contracts" xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
 <a:LogicalName>account</a:LogicalName>
 <a:RelatedEntities xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
 <a:RowVersion>600729</a:RowVersion>
 </a:Entity>
 </a:Entities>
 <a:EntityName>account</a:EntityName>
 <a:MinActiveRowVersion>-1</a:MinActiveRowVersion>
 <a:MoreRecords>false</a:MoreRecords>
 <a:PagingCookie>&lt;cookie page="1"&gt;&lt;accountid last="{D3AE1B3A-8BD2-E411-80EF-C4346BAC7BE8}" first="{D3AE1B3A-8BD2-E411-80EF-C4346BAC7BE8}" /&gt;&lt;/cookie&gt;</a:PagingCookie>
 <a:TotalRecordCount>-1</a:TotalRecordCount>
 <a:TotalRecordCountLimitExceeded>false</a:TotalRecordCountLimitExceeded>
 </RetrieveMultipleResult>
 </RetrieveMultipleResponse>
 </s:Body>
</s:Envelope>
--------------------------------------------------

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

Leave a Reply

Your email address will not be published. Required fields are marked *