title: MS Dynamics SOAP endpoint call (Active Directory auth)
body: <p>I have an onPremise Dynamics CRM instance setup with HTTP and AD authentication, without any ADFS.</p>
  
  <p>I'm willing to do a basic web service call (with NTLM) : </p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:con="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays"&gt;
     &lt;soap:Header/&gt;
     &lt;soap:Body&gt;
        &lt;ser:Retrieve&gt;
           &lt;!--Optional:--&gt;
           &lt;ser:entityName&gt;?&lt;/ser:entityName&gt;
           &lt;!--Optional:--&gt;
           &lt;ser:id&gt;?&lt;/ser:id&gt;
           &lt;!--Optional:--&gt;
           &lt;ser:columnSet&gt;
              &lt;!--Optional:--&gt;
              &lt;con:AllColumns&gt;?&lt;/con:AllColumns&gt;
              &lt;!--Optional:--&gt;
              &lt;con:Columns&gt;
                 &lt;!--Zero or more repetitions:--&gt;
                 &lt;arr:string&gt;?&lt;/arr:string&gt;
              &lt;/con:Columns&gt;
           &lt;/ser:columnSet&gt;
        &lt;/ser:Retrieve&gt;
     &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>...But it seems I'm missing something since I get this response :</p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"&gt;
     &lt;s:Header&gt;
        &lt;a:Action s:mustUnderstand="1"&gt;http://www.w3.org/2005/08/addressing/soap/fault&lt;/a:Action&gt;
     &lt;/s:Header&gt;
     &lt;s:Body&gt;
        &lt;s:Fault&gt;
           &lt;s:Code&gt;
              &lt;s:Value&gt;s:Sender&lt;/s:Value&gt;
              &lt;s:Subcode&gt;
                 &lt;s:Value xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;a:InvalidSecurity&lt;/s:Value&gt;
              &lt;/s:Subcode&gt;
           &lt;/s:Code&gt;
           &lt;s:Reason&gt;
              &lt;s:Text xml:lang="en-US"&gt;An error occurred when verifying security for the message.&lt;/s:Text&gt;
           &lt;/s:Reason&gt;
        &lt;/s:Fault&gt;
     &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>My guess so far is I'm missing something in the SOAP header but I don't know why, maybe something to do server side?
  Maybe someone would have a clue?</p>
  
  <pre><code>[2016-03-01 11:12:02.248] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread:  146 |Category: Platform.Sdk |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: a9210b00-7f84-43dc-a794-d8f9697c8b53 | ServiceModelTraceRedirector.TraceData  ilOffset = 0x45
  &gt;&lt;TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error"&gt;&lt;TraceIdentifier&gt;http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ThrowingException.aspx&lt;/TraceIdentifier&gt;&lt;Description&gt;Throwing an exception.&lt;/Description&gt;&lt;AppDomain&gt;/LM/W3SVC/2/ROOT-2-131012583114393978&lt;/AppDomain&gt;&lt;Exception&gt;&lt;ExceptionType&gt;System.ServiceModel.Security.MessageSecurityException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/ExceptionType&gt;&lt;Message&gt;Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties.   This can occur if the service is configured for security and the client is not using security.&lt;/Message&gt;&lt;StackTrace&gt;   at System.ServiceModel.Security.SecurityStandardsManager.CreateReceiveSecurityHeader(Message message, String actor, SecurityAlgorithmSuite algorithmSuite, MessageDirection direction)
  &gt;   at System.ServiceModel.Security.MessageSecurityProtocol.CreateSecurityHeader(Message message, String actor, MessageDirection transferDirection, SecurityStandardsManager standardsManager)
  &gt;   at System.ServiceModel.Security.MessageSecurityProtocol.ConfigureReceiveSecurityHeader(Message message, String actor, SecurityProtocolCorrelationState[] correlationStates, SecurityStandardsManager standardsManager, IList`1&amp;amp;amp; supportingAuthenticators)
  &gt;   at System.ServiceModel.Security.SymmetricSecurityProtocol.VerifyIncomingMessageCore(Message&amp;amp;amp; message, String actor, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)
  &gt;   at System.ServiceModel.Security.MessageSecurityProtocol.VerifyIncomingMessage(Message&amp;amp;amp; message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)
  &gt;   at System.ServiceModel.Channels.SecurityChannelListener`1.ServerSecurityChannel`1.VerifyIncomingMessage(Message&amp;amp;amp; message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationState)
  &gt;   at System.ServiceModel.Channels.SecurityChannelListener`1.SecurityReplyChannel.ProcessReceivedRequest(RequestContext requestContext, TimeSpan timeout)
  &gt;   at System.ServiceModel.Channels.SecurityChannelListener`1.ReceiveItemAndVerifySecurityAsyncResult`2.OnInnerReceiveDone()
  &gt;   at System.ServiceModel.Channels.SecurityChannelListener`1.ReceiveItemAndVerifySecurityAsyncResult`2.InnerTryReceiveCompletedCallback(IAsyncResult result)
  &gt;   at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
  &gt;   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
  &gt;   at System.Runtime.InputQueue`1.AsyncQueueReader.Set(Item item)
  &gt;   at System.Runtime.InputQueue`1.Dispatch()
  &gt;   at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
  &gt;   at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
  &gt;   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
  &gt;
  </code></pre>
  
  <p>It means the incoming message should have a security header, which wasn't in the SOAP request, that's true.</p>
  
  <p>Then I don't know what kind of security header I should add to my SOAP request.</p>