Using my Fake SOAP request with WCF

soap

#1

I am trying to use a mock server to return soap requests back to me.

I have my WCF application to invoke these mock requests.

But when I see the response of the request, I get a System.ServiceModel.ProtocolException exception.

But I can see part of my fake request response in the error message.

"The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. 

The first 1024 bytes of the response were: '<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:v2=\"http://mil.dod.af.A1.personnel.dataservices.accessions/v2.0\" xmlns:mil=\"http://mil.dod.af.A1.personnel.dataservices.cleartext\">\r\n   <soap:Header/>\r\n   <soap:Body>\r\n      <v2:retrieveCommissionAgreementResponse>\r\n         <!--Zero or more repetitions:-->\r\n         <CommisionAgreement Id=\"\">\r\n            <!--Optional:-->\r\n            <v2:Adn>\r\n               <!--Optional:-->\r\n               <mil:Code></mil:Code>\r\n               <!--Optional:-->\r\n               <mil:Value></mil:Value>\r\n            </v2:Adn>\r\n            <!--Optional:-->\r\n            <v2:CompCategory>\r\n               <!--Optional:-->\r\n               <mil:Code></mil:Code>\r\n               <!--Optional:-->\r\n               <mil:Value></mil:Value>\r\n            </v2:CompCategory>\r\n            <!--Optional:-->\r\n            <v2:EffectiveBeginDate>2010-01-01</v2:EffectiveBeginDate>\r\n            <!--Optional:-->\r\n            <v2:SourceOfCommission>\r\n               <!--Optional:--'."

The content type is shown as text/html instead of application/soap+xml


#2

I figured it out by making the Example Response header to have the Content-Type as Application/Soap+xml.