Possible causes for two of eight WCF REST endpoints not found? - wcf

Any idea why the last two URI templates report endpoint not found?
v1/version
v1/locations/{id}
v1/locations/{id}/signals
v1/locations&q={searchText}
v1/locations/signals/{signalIds}
v1/signals/{id}
v1/locations/{id}/visits
v1/locations/{locationId}/visits/{id}
All the previous 6 routes work fine, but when I added the last 2 routes, they respond with 404 "Endpoint not found" WCF framework messages. All 8 routes are GET methods, and I've verified with Fiddler that I am indeed using GET verbs. I can't see what is different from the other REST methods that are still working.
Test URL that successfully gets Location Id=2
GET http://localhost:57004/AppsService.svc/v1/locations/2
returning this correct JSON:
{
"Id": 2,
"Identifier": "L85",
"Name": "The Huge Lake",
"Signals": null
}
Here is a test URL from that attempts to get all "Visit" objects from Location ID=2
GET http://localhost:57004/AppsService.svc/v1/locations/2/visits
That URL fails with a 404 framework exception:
<HTML>
<HEAD>
<STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE>
<TITLE>Service</TITLE>
</HEAD>
<BODY>
<DIV id="content">
<P class="heading1">Service</P>
<BR/>
<P class="intro">Endpoint not found.</P>
</DIV>
</BODY>
</HTML>
Here is the full service interface code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using WebAppsService.Models;
namespace WebAppsService
{
[ServiceContract]
public interface IAppsService
{
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "v1/version")]
string GetVersion();
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "v1/locations/{id}")]
Location GetLocation(string id);
// DCSR-specific Location APIs
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "v1/locations/{id}/signals")]
List<Signal> GetLocationSignals(string id);
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "v1/locations&q={searchText}")]
List<Location> GetLocations(string searchText);
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "v1/locations/signals/{signalIds}")]
List<Location> GetLocationsContainingSignals(string signalIds);
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "v1/locations/{id}/visits")]
List<Visit> GetVisits(string id);
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "v1/locations/{locationId}/visits/{id}")]
Visit GetVisit(string locationId, string id);
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "v1/signals/{id}")]
Signal GetSignal(string id);
}
}
Any ideas?

Found the problem: me.
After I had debugged endpoint #6, I changed the project's OutputPath property from the default of "bin" to "$(SolutionDir)\$Configuration)", a pattern we use for all our projects.
It turns out that when you debug a web project from VS, it always looks in the relative "bin\" folder for the assemblies when it launches the project via IIS or the Cassini standalone web server. The project's OutputPath property is just ignored without complaint.
So I was left debugging a stale version of my assembly that only contained routes to the first 6 endpoints. sheesh

Related

How I set a value in input-select (React.js field) with selenium c#?

people.
I'm not getting the input-select value (React.js field) with selenium c#. The field get values of services.
Obs: I has try fill field with SendKeys command, but I don't right.
It's HTML code:
<div class="Select selectbox-select Select--single is-clearable is-searchable"><div class="Select-control"><span class="Select-multi-value-wrapper" id="react-select-2--value"><div class="Select-placeholder">Selecione...</div><div class="Select-input" style="display: inline-block;"><style>input#undefined::-ms-clear {display: none;}</style><input role="combobox" aria-expanded="false" aria-owns="" aria-haspopup="false" aria-activedescendant="react-select-2--value" value="" style="width: 5px; box-sizing: content-box;"><div style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-size: 16px; font-family: roboto-regular, sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal; text-transform: none;"></div></div></span><span class="Select-arrow-zone"><span class="Select-arrow"></span></span></div></div>
<div class="Select selectbox-select Select--single is-clearable is-searchable has-value"><div class="Select-control"><span class="Select-multi-value-wrapper" id="react-select-2--value"><div class="Select-value"><span class="Select-value-label" role="option" aria-selected="true" id="react-select-2--value-item">000001 - EST GO</span></div><div class="Select-input" style="display: inline-block;"><style>input#undefined::-ms-clear {display: none;}</style><input role="combobox" aria-expanded="false" aria-owns="" aria-haspopup="false" aria-activedescendant="react-select-2--value" value="" style="width: 5px; box-sizing: content-box;"><div style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-size: 16px; font-family: roboto-regular, sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal; text-transform: none;"></div></div></span><span class="Select-clear-zone" title="Clear value" aria-label="Clear value"><span class="Select-clear">×</span></span><span class="Select-arrow-zone"><span class="Select-arrow"></span></span></div></div>
It's my code:
//ParametersPage.cs
public void preencherCampoProduto(string produto)
{
inputSelectProduto.Clicks();
IWebElement dropdownValue = retornaXpathCamposInputSelect(produto);
dropdownValue.Clicks();
}
public IWebElement retornaXpathCamposInputSelect(string valor)
{
return driver.FindElement(By.XPath("//div[contains(text(),'" + valor + "')]"));
}
//ParametersTest.cs
[TestMethod]
public void OLE_testParametrosPreencherConvenio()
{
autenticacao.RealizarAutenticacao(usuarioCorreto, senhaCorreta);
paginaInicial.acessarMenuRemuneracaoCadastroListagem();
parametro.preencherCampoConvenio("005045 - CARBEL");
//Assert.IsTrue(alerta.MensagemValidacao().Contains(MSG_RelatorioDataInicioFimForaLimite));
}
Thank, people!!!
try using Actions Class:
IWebElement myElement = Driver.Instance.FindElement(By.XPath("//*[#id='field_" + SetEnvironmentJourney.EnvironmentControlId + "_" + elementId + "']"));
Actions act = new Actions(Driver.Instance);
act.MoveToElement(myElement).Click().Build().Perform();
IWebElement myItem = myElement.FindElement(By.XPath("//div[contains(text(),'" + p + "')]"));
act.Click(myItem).Build().Perform();

SOAP web service returning html code on iOS 10

I am trying to use the SOAp web service in my code and its not working as expected. The same code works fine prior to iOS 10.
Has anybody faced the same issue?
My code looks like this:
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:#"CFBundleShortVersionString"];
NSString *msg=[NSString stringWithFormat:#"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n"
"<GetConfiguration xmlns=\"http://example.com/webservices/\">\n"
"<app_version>%#</app_version>\n"
"</GetConfiguration>\n"
"</soap:Body>\n"
"</soap:Envelope>\n",version];
NSURL * getUrl=[NSURL URLWithString:GET_CONFIGURATION_URL];
[Logger Log:GET_CONFIGURATION_URL];
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:getUrl];
NSString *msgLength=[NSString stringWithFormat:#"%lu",(unsigned long)[msg length]];
[theRequest addValue:#"application/json;charset=utf-8" forHTTPHeaderField:#"Content-Type"];
[theRequest addValue:#"http://example.com/webservices/GetConfiguration" forHTTPHeaderField:#"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:#"Content-Length"];
[theRequest setHTTPMethod:#"GET"];
[theRequest setHTTPBody:[msg dataUsingEncoding:NSUTF8StringEncoding]];
NSError *error = nil;
NSURLResponse *theResponse =[[NSURLResponse alloc]init];
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];//I also used AFJSONResponseSerializer but no success.
NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:theRequest completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(#"Error: %#", error);
} else {
NSLog(#"%# %#", response, responseObject);
}
}];
[dataTask resume];
And I get the response embedded in <html> ... </html> which is in fact the code from server.
I am unable to get rid of this error.
Edit, the response is as follows:
<html>
<head><link rel="alternate" type="text/xml" href="/webservices/AppWebService.asmx?disco" />
<style type="text/css">
BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; }
#content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; }
A:link { color: #336699; font-weight: bold; text-decoration: underline; }
A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; }
A:active { color: #336699; font-weight: bold; text-decoration: underline; }
A:hover { color: cc3300; font-weight: bold; text-decoration: underline; }
P { color: #000000; margin-top: 0px; margin-bottom: 12px; font-family: Verdana; }
pre { background-color: #e5e5cc; padding: 5px; font-family: Courier New; font-size: x-small; margin-top: -5px; border: 1px #f0f0e0 solid; }
td { color: #000000; font-family: Verdana; font-size: .7em; }
h2 { font-size: 1.5em; font-weight: bold; margin-top: 25px; margin-bottom: 10px; border-top: 1px solid #003366; margin-left: -15px; color: #003366; }
h3 { font-size: 1.1em; color: #000000; margin-left: -15px; margin-top: 10px; margin-bottom: 10px; }
ul { margin-top: 10px; margin-left: 20px; }
ol { margin-top: 10px; margin-left: 20px; }
li { margin-top: 10px; color: #000000; }
font.value { color: darkblue; font: bold; }
font.key { color: darkgreen; font: bold; }
font.error { color: darkred; font: bold; }
.heading1 { color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal; background-color: #003366; margin-top: 0px; margin-bottom: 0px; margin-left: -30px; padding-top: 10px; padding-bottom: 3px; padding-left: 15px; width: 105%; }
.button { background-color: #dcdcdc; font-family: Verdana; font-size: 1em; border-top: #cccccc 1px solid; border-bottom: #666666 1px solid; border-left: #cccccc 1px solid; border-right: #666666 1px solid; }
.frmheader { color: #000000; background: #dcdcdc; font-family: Verdana; font-size: .7em; font-weight: normal; border-bottom: 1px solid #dcdcdc; padding-top: 2px; padding-bottom: 2px; }
.frmtext { font-family: Verdana; font-size: .7em; margin-top: 8px; margin-bottom: 0px; margin-left: 32px; }
.frmInput { font-family: Verdana; font-size: 1em; }
.intro { margin-left: -15px; }
</style>
<title>
WebService Web Service
</title></head>
<body>
<div id="content">
<p class="heading1">WebService</p><br>
<span>
<p class="intro">Click here for a complete list of operations.</p>
<h2>GetConfiguration</h2>
<p class="intro"></p>
<h3>Test</h3>
The test form is only available for requests from the local machine.
<span>
<h3>SOAP 1.1</h3>
<p>The following is a sample SOAP 1.1 request and response. The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>
<pre>POST /webservices/AppWebService.asmx HTTP/1.1
Host: MY_HOST_URL_HERE
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>
SOAPAction: "http://example.com/webservices/GetConfiguration"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetConfiguration xmlns="http://example.com/webservices/">
<app_version><font class=value>string</font></app_version>
</GetConfiguration>
</soap:Body>
</soap:Envelope></pre>
<pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetConfigurationResponse xmlns="http://example.com/webservices/">
<GetConfigurationResult><font class=value>string</font></GetConfigurationResult>
</GetConfigurationResponse>
</soap:Body>
</soap:Envelope></pre>
</span>
<span>
<h3>SOAP 1.2</h3>
<p>The following is a sample SOAP 1.2 request and response. The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>
<pre>POST /webservices/AppWebService.asmx HTTP/1.1
Host: MY_HOST_URL_HERE
Content-Type: application/soap+xml; charset=utf-8
Content-Length: <font class=value>length</font>
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetConfiguration xmlns="http://example.com/webservices/">
<app_version><font class=value>string</font></app_version>
</GetConfiguration>
</soap12:Body>
</soap12:Envelope></pre>
<pre>HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: <font class=value>length</font>
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetConfigurationResponse xmlns="http://example.com/webservices/">
<GetConfigurationResult><font class=value>string</font></GetConfigurationResult>
</GetConfigurationResponse>
</soap12:Body>
</soap12:Envelope></pre>
</span>
</span>
</body>
</html>

WCF Service always returning discovery page when run locally

Using the WCF Test Client I get this when trying to invoke a method:
The content type text/html; charset=UTF-8 of the response message does
not match the content type of the binding (text/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: '#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em;
MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR:
000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY:
Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px;
BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px;
FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid;
PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY:
Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px;
PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px;
MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH:
100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma;
BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT:
-15px}TagService Service
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IDataTagService.GetTagDefinitions(String projectID, Nullable`1 tagType)
at DataTagServiceClient.GetTagDefinitions(String projectID, Nullable`1 tagType)
Which appears to me to be the discovery page. This works when deployed, but not locally? This also used to work locally, but somehow has started displaying this behavior. I'm not sure what could have changed to make this suddenly break.
Edit: I've narrowed it down to this:
<security mode="Transport">
if I change it to none and use an http url, it works, but I'd like my local copy to mirror production so does anyone have any idea how I can get to the root cause of this?
Edit: I've uninstalled and reinstalled IIS, ran the applications to get asp.net and wcf working with IIS, enabled ssl, and am right back to where I started. ARGH!
This was caused by securitySwitch not being turned off, or at least not having a configuration. Putting
<secureWebPages mode="Off" ignoreHandlers="None">
</secureWebPages>
resolved the problem, and is overwritten by a web.release.config transform.
it was previously just <secureWebPages />
http://code.google.com/p/securityswitch/

400 error with Fiddler POST to REST service endpoint

I have a simple REST service endpoint that is failing when I POST using Fiddler 2. Endpoints that dont require input parameters succeed. Only passing in data causes failure. Im using the web server integrated into VS 2010.
Details:
Global.asax entries:
private void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("Employee", new WebServiceHostFactory(), typeof(Employee)));
RouteTable.Routes.Add(new ServiceRoute("Provider", new WebServiceHostFactory(), typeof(Provider)));
}
Web Service:
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class Provider : BaseMvpWebService<ProviderPresenter>, IProvider
[WebInvoke(Method="POST", RequestFormat=WebMessageFormat.Json, UriTemplate="", ResponseFormat=WebMessageFormat.Json, BodyStyle=WebMessageBodyStyle.Wrapped)]
public ProviderListWrap FilteredList(GeneralSearchView filtersearch)
{ ... }
Web Config Entries:
<system.serviceModel>
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Parameter Type Definition:
[DataContract]
public class GeneralSearchView : IGeneralSearchView
{
[DataMember]
public string ProviderListing { get; set; }
[DataMember]
public string FundingSource { get; set; }
[DataMember]
public string ProviderType { get; set; }
[DataMember]
public string ServiceType { get; set; }
[DataMember]
public string UserZipCode { get; set; }
[DataMember]
public string SearchRadius { get; set; }
[DataMember]
public string SearchCounty { get; set; }
}
POSTing via Fiddler 2:
POST http://localhost:19099/Provider/
Request Headers
User-Agent: Fiddler
Content-Type: application\json
Host: localhost:19099
Content-Length: 43
Request Body
{"filtersearch":{"ProviderListing":"True"}}
Raw Response
HTTP/1.1 400 Bad Request
Server: ASP.NET Development Server/10.0.0.0
Date: Fri, 29 Jun 2012 17:31:35 GMT
X-AspNet-Version: 4.0.30319
Content-Length: 1770
Set-Cookie: ASP.NET_SessionId=qgvgtxlcvdouut2qgq40u4eh; path=/; HttpOnly
Cache-Control: private
Content-Type: text/html
Connection: Close
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Request Error</title>
<style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
</head>
<body>
<div id="content">
<p class="heading1">Request Error</p>
<p xmlns="">The server encountered an error processing the request. Please see the <a rel="help-page" href="http://localhost:19099/Provider/help">service help page</a> for constructing valid requests to the service.</p>
</div>
</body>
</html>
Any ideas/feedback would be appreciated.
Thanks!
I'm thinking you may have a syntax issue with your content type slash.
Try:
Content-Type: application/json
If not, are there any other details in the response? Just a 400 bad request?

WCF Rest service POST method fails in Fiddler

I'm using WCF Restservice to authenticate user. I have a POST method and works fine using jquery but fails on Fiddler test. I get 415 Unsupported Media Type.
Here is my code
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "Login", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public string Login(string userName, string password)
{
string valid;
// Log in user
int authenticatedId = AuthenticateManager.Authenticate(userName, password);
if (authenticatedId != -1)
{
valid = "Welcome " + userName + "!";
}
else
{
valid = "Login failed!";
}
return valid;
}
This is what I'm passing in Fiddler body
[{ "userName":"dusshyi",
"password":"subram1" }]
This is what fiddler generating
<HTML><HEAD><STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE>
<TITLE>Service</TITLE></HEAD><BODY>
<DIV id="content">
<P class="heading1">Service</P>
<BR/>
<P class="intro">Endpoint not found.</P>
</DIV>
</BODY></HTML>
Please help!
Have you set the Content-Type of the request to application/json in Fiddler's Request body editor?
I had the same problem this morning...
What fixed it for me was to click on the "Composer" tab, then add the following to the "Request Headers" section:
Content-Type: application/x-www-form-urlencoded
Without this line, I noted that the log showed it was attempting to call my REST Service with a Content-Type of "text/html", and the Service wouldn't get called.
This would even happen if I added the line:
Content-Type: application/json
However, after adding the line "Content-Type: application/x-www-form-urlencoded", Fiddler would now call the service with a Content Type of "application/json", and the web service was called correctly. Strange...
I've created a complete walkthough of creating a JSON WCF Web Service, and testing it with Fiddler, on the following page:
http://mikesknowledgebase.com/pages/Services/WebServices-Page1.htm
Fiddler Web Debugger:Composer section; settings
Parsed
POST,../Service.svc/Login,HTTP/1.1
Request Header:
User-Agent: Fiddler
Content-Type: application/json;charset=UTF-8
Host: localhost:15021
Content-Length: 43
Request Body:
{"username":"ABC","password":"pwd"}
and then execute