title: SoapUI/ WCF Self-Hosted Webservices/ and Fiddler
body: <p><strong>Background:</strong> Eventually a third party will install software on a server that will be communicating with my service on a different server. This third party has no emulation/testing software so they have given me their .wsdl and suggested that I use SoapUI to test their side of communication against my service. My service is a self-hosted (not on iis) written in VB but if you do have a code change suggestion it can be in C#.</p>
  
  <p><strong>Issue:</strong> I cannot get SoapUI to successfully send Soap encoded xml messages to my service. The end result I want is to have my breakpoint hit in my function in my WCFLibrary that is implementing my operation contract from my interface</p>
  
  <p><strong>More Information:</strong> After much trial and error I think I have my endpoints configured correctly. This is my first venture with WCF and before I started i followed the getting started tutorial on MSDN for the calculator. When I have that service running I can send a message and get a valid response from SoapUi but it doesn't hit the break point in visual studio which doesn't bode well for me. In my research I saw that people suggest using Fiddler to help troubleshoot this issue. I was able to get this work but the error that i see in fiddler is basically the same thing I see in SoapUI</p>
  
  <p>What I am trying to send to my service.</p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/"&gt;
      &lt;soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"&gt;
          &lt;wsa:Action&gt;**Redacted**&lt;/wsa:Action&gt;
          &lt;wsa:To&gt;http://localhost:8000/UnsolicitedListenerLib/Service1&lt;/wsa:To&gt;
      &lt;/soap:Header&gt;
      &lt;soap:Body&gt;
          &lt;tem:**Redacted**/&gt;
      &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>The Repsonse I am getting:</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://schemas.xmlsoap.org/ws/2005/02/sc"&gt;a:BadContextToken&lt;/s:Value&gt;
                  &lt;/s:Subcode&gt;
              &lt;/s:Code&gt;
              &lt;s:Reason&gt;
                  &lt;s:Text xml:lang="en-US"&gt;The message could not be processed. This is most likely because the action **Redacted** is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.&lt;/s:Text&gt;
              &lt;/s:Reason&gt;
          &lt;/s:Fault&gt;
      &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p><strong>What I am confused on:</strong> So the key part of this error message is the "The message could not be processed. This is most likely because the action '<strong>Redacted</strong> is incorrect"
  Why would it be looking at <strong>Redacted</strong> for this <strong>Redacted</strong> action? - That will be inplace eventually when the third party installs their software <em>but my perception was SoapUI reads in the WSDL in order to know what actions to have and then doesn't use it anymore and just fires the Soap messages that I ask for at the endpoint that I am telling it to.</em> I am starting to think I am wrong about this then. Also the only difference between the test service and my service is the content type. The test service has a content type of "text/xml; charset=utf-8" and mine is "application/soap+xml; charset=utf-8" </p>
  
  <p><strong>I have also tried:</strong> When I saw that error message I thought well maybe I need to make my a wsdl based on my service. So I used the SDK tool to make a wsdl on my service and then imported it to SoapUI and pointed to the endpoint to my running service but the response I got was a </p>
  
  <p>HTTP/1.1 415 Cannot process the message because the content type 'text/xml;charset=UTF-8' was not the expected type 'application/soap+xml; charset=utf-8'.
  Content-Length: 0
  Server: Microsoft-HTTPAPI/2.0
  Date: Fri, 03 Jan 2014 14:00:25 GMT</p>
  
  <p>Then I gave up goin down this path. </p>
  
  <p>Last Thing: Even if I am able to get this to work, will this still not hit my breakpoint in my service that is running? I ask this because like I said earlier, in the test wcf service that I made it didn't hit the break point when it gave me back a valid response.</p>
  
  <p>Here is the message / Valid response I am getting for the working test service</p>
  
  <p>Send:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mic="http://Microsoft.ServiceModel.Samples"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;mic:Add/&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>Receive:</p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;s:Body&gt;
          &lt;AddResponse xmlns="http://Microsoft.ServiceModel.Samples"&gt;
              &lt;AddResult&gt;0&lt;/AddResult&gt;
          &lt;/AddResponse&gt;
      &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>I can post my App.config / My interface if anyone think it will help but I won't until someone asks for it. </p>
  
  <p>App.Config for my WebService: (Altered and I commented out the original)</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;system.diagnostics&gt;
      &lt;sources&gt;
        &lt;!-- This section defines the logging configuration for My.Application.Log --&gt;
        &lt;source name="DefaultSource"
                switchName="DefaultSwitch"&gt;
          &lt;listeners&gt;
            &lt;add name="FileLog"/&gt;
            &lt;!-- Uncomment the below section to write to the Application Event Log --&gt;
            &lt;!--&lt;add name="EventLog"/&gt;--&gt;
          &lt;/listeners&gt;
        &lt;/source&gt;
      &lt;/sources&gt;
      &lt;switches&gt;
        &lt;add name="DefaultSwitch"
             value="Information"/&gt;
      &lt;/switches&gt;
      &lt;sharedListeners&gt;
        &lt;add name="FileLog"
             type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
             initializeData="FileLogWriter"/&gt;
        &lt;!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log --&gt;
        &lt;!--&lt;add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/&gt; --&gt;
      &lt;/sharedListeners&gt;
    &lt;/system.diagnostics&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true"/&gt;
    &lt;/system.web&gt;
    &lt;!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --&gt;
    &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="Service1Behavior"&gt;
            &lt;serviceMetadata httpGetEnabled="True"/&gt;&lt;serviceDebug includeExceptionDetailInFaults="False"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
          &lt;binding name="wsHttpBindingNoSecurity"&gt;
            &lt;security mode="None"&gt;
              &lt;transport clientCredentialType="None" /&gt;
              &lt;message establishSecurityContext="false" /&gt;
            &lt;/security&gt;
              &lt;/binding&gt;
        &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service name="UnsolicitedListenerLib.Service1" behaviorConfiguration="Service1Behavior"&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;!--&lt;add baseAddress="http://localhost:8732/Design_Time_Addresses/UnsolicitedListenerLib/Service1/"/&gt;--&gt;
              &lt;add baseAddress="http://localhost:8000/UnsolicitedListenerLib/Service1"/&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
          &lt;!--&lt;endpoint address="" binding="basicHttpBinding" contract="UnsolicitedListenerLib.UnsolictedListenerService.IService1"&gt;--&gt;
          &lt;endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingNoSecurity" contract="UnsolicitedListenerLib.UnsolictedListenerService.IService1"&gt;
             &lt;identity&gt;&lt;dns value="localhost"/&gt;&lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;!-- Metadata Endpoints --&gt;
          &lt;!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --&gt;
          &lt;!-- This endpoint does not use a secure binding and should be secured or removed before deployment --&gt;
          &lt;endpoint address="mex"
                    binding="mexHttpBinding"
                    contract="IMetadataExchange"/&gt;
        &lt;/service&gt;
      &lt;/services&gt;  
    &lt;/system.serviceModel&gt;
  
  &lt;startup&gt;&lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;&lt;/startup&gt;&lt;/configuration&gt;
  </code></pre>
  
  <p>App.Config for my (Host) Service: (Unaltered)</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
      &lt;system.diagnostics&gt;
          &lt;sources&gt;
              &lt;!-- This section defines the logging configuration for My.Application.Log --&gt;
              &lt;source name="DefaultSource" switchName="DefaultSwitch"&gt;
                  &lt;listeners&gt;
                      &lt;add name="FileLog"/&gt;
                      &lt;!-- Uncomment the below section to write to the Application Event Log --&gt;
                      &lt;!--&lt;add name="EventLog"/&gt;--&gt;
                  &lt;/listeners&gt;
              &lt;/source&gt;
          &lt;/sources&gt;
          &lt;switches&gt;
              &lt;add name="DefaultSwitch" value="Information"/&gt;
          &lt;/switches&gt;
          &lt;sharedListeners&gt;
              &lt;add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/&gt;
              &lt;!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log --&gt;
              &lt;!--&lt;add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/&gt; --&gt;
          &lt;/sharedListeners&gt;
      &lt;/system.diagnostics&gt;
  &lt;startup&gt;&lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;&lt;/startup&gt;&lt;/configuration&gt;
  </code></pre>
  
  <p>My client will be SoapUI - So I don't have a client service / client App.Config</p>
  
  <p><strong>EDIT</strong>
  I am now getting to the point where my soap message will bounce off my service and get rejected because it cannot deserialize it.</p>
  
  <pre><code>Raw Fiddler Headers
  POST /UnsolicitedListenerLib/Service1 HTTP/1.1
  Accept-Encoding: gzip,deflate
  Content-Type: application/soap+xml;charset=UTF-8;action="http://tempuri.org/IService1/orderstatus"
  Content-Length: 890
  Host: localhost:8000
  Connection: Keep-Alive
  User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
  </code></pre>
  
  <p><strong>Edit Because the Third Party did not want their XML message to be made public knowledge</strong></p>