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?
Related
I have setup a Firebase Web Login with Email/Password sign in locally on my computer. I want to implement it on my domain, which is hosted by a web hosting company, so my domain and all it's catalogues are password protected.
Is this possible? Where/how do I configure this?
I have supplied my current setup as a snippet.
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
document.getElementById('signed-in').style.display = "block";
document.getElementById('sign-in').style.display = "none";
} else {
// No user is signed in.
document.getElementById('signed-in').style.display = "none";
document.getElementById('sign-in').style.display = "initial";}
});
const form = document.getElementById("sign-in-form");
form.addEventListener("submit", login);
function login(event) {
event.preventDefault();
let email = document.getElementById("email").value;
let password = document.getElementById("password").value;
firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
document.getElementById('error-message').textContent = errorMessage;
document.getElementById('error-message-div').style.display = "block";
});
}
body, html {
font-family: 'Nunito', sans-serif;
color: #999;
}
a {
color: #57b846;
text-decoration: none;
}
a:hover {
color: black;
}
#wrapper {
margin: 0;
position: absolute;
padding-bottom: 50px;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 500px;
border-radius: 20px;
box-shadow: 0px 3px 20px 0px; #000;
}
#sign-in-header {
padding: 10px;
color: white;
font-weight: 700;
text-align: center;
background-color: #57b846;
border-radius: 20px 20px 0 0;
}
#sign-in-body {
box-sizing: border-box;
padding: 50px 50px 0 50px;
}
input {
outline: none;
box-sizing: border-box;
font-weight: 600;
font-size: 15px;
color: #1b3815;
line-height: 1.2;
width: 100%;
height: 55px;
background: #ebebeb;
border: none;
border-radius: 25px;
padding: 0 35px 0 35px;
}
#email {
margin-bottom: 15px;
}
input[type=submit] {
color: white;
background-color: #57b846;
padding: 0 35px 0 35px;
margin-bottom: 15px;
cursor: pointer;
margin-top: 20px;
}
input[type=submit]:hover {
background-color: #2e7522;
}
#forgot-password {
text-align: right;
}
#signed-in {
display: none;
}
#error-message-div {
box-sizing: border-box;
font-weight: 600;
font-size: 15px;
color: #D8000C;
width: 100%;
background: #FFBABA ;
border: none;
padding: 10px;
border-radius: 5px;
}
#error-message-div {
display: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - The Meadow</title>
<link href="https://fonts.googleapis.com/css?family=Nunito:400,600,700&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<section>
<div id="wrapper">
<div id="sign-in">
<div id="sign-in-header">
<h1>Sign In</h1>
</div>
<div id="sign-in-body">
<form id="sign-in-form">
<input type="text" id="email" name="email" placeholder="E-mail"><br>
<input type="password" id="password" name="password" placeholder="Password"><br><br>
<div id="forgot-password">Forgot Username / Password?</div>
<input type="submit" value="SIGN IN">
</form>
<div id="error-message-div"><strong><span id="error-message"></span></strong></div>
</div>
</div>
<div id="signed-in">You are signed in</div>
</div>
</section>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.9.1/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.9.1/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.9.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.9.1/firebase-firestore.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyBHoY2Vjhw6fbI6abd_osRzbkfgAZA5yt4",
authDomain: "fir-web-login-3b6c2.firebaseapp.com",
databaseURL: "https://fir-web-login-3b6c2.firebaseio.com",
projectId: "fir-web-login-3b6c2",
storageBucket: "fir-web-login-3b6c2.appspot.com",
messagingSenderId: "569718654639",
appId: "1:569718654639:web:51b3518dc6a0096c58765a",
measurementId: "G-G034W12YF0"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
<script src="index.js"></script>
</body>
</html>
Firebase Authentication can be used on any hosting provider.
It can also be used with any custom domain, no matter where you registered that domain. Just be sure to add the custom domain to the list of Authorized domains in the Firebase Authentication console.
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>
Our server returns ads to the publisher's app (android/iOS apps). Let's consider this case where the returned ad is an HTML with img tags containing remote images (resources stored in third party servers of ad networks). Something like this -
<!DO CTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>Untitled Document</title>
<style> #ad{ margin: 0px auto 0 auto; width: 308px; padding: 5px; height: 38px; border: 1px solid #ddd; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; background-color:#fff; text-align:left; } #ad h3{ padding: 0; margin: 0; color:#0067FF; font-weight: normal; font-size: 12px; } #ad a { color:#009C00; font-size: 10px; text-decoration:none; margin: 0; padding: 0; } #ad p.description { margin: 0; padding: 0; font-size: 8px; margin-bottom: 10px; } .ad_label{ margin: 0 auto 0 auto; text-align: center; color: #a09f9f; font-size: 12px; padding: 3px 0 0 0; } </style>
</head>
<body>
<div id="ad">
<h3>Junk-A-Car</h3>
yp.com/reviews
<p class="description">Find Local Automobile Salvage Need Help? Click Here!</p>
</div>
<img src="http://imp.admarketplace.net/imp?id=7R7wxEzkiFdwxr3NJGbzfQbX4BkW4BkXfYbW1C\WfQ\W4p\W4pH+7RcdIG7+GmwqgClkfZldfQ8XfQ2Xfp2XfpbW4Z8nxnEZGmzYI=EYgCbnHF3QJre+GmwqgClrfpf+fCDW7ncQHmzdJR3KiF2zfQld4C2nimE+jmzYIczvIpkY4Zq+fp8Yfp2nxr7kgCbnxGEwxRwKj=EYJCdQHG7Z7nckxZkX1CbZfQxZ1pHnHncZIEzQx=fzfBaafpbnHF4kjFcTGm4WHZkX5QLWftInIFEqGr4wxRIwxQdw5GNuJtkkfBIdxr7KImEVGmwqgGTOxY8PfCDX5t7Q8Q\kfZ2T8n4V8Q\Y5t7q8Q\dfplT8R\O1QlXfQfrKBIWjF7KiF2zfCb+4Q2nHnwqI=EYGmwqgCby" width="1" height="1" />
</body>
</html>
<img src="http://54.204.70.10/fam/view.php?p=__pid=4e17aeb00411789d__sid=102175__bid=1259380__cb=e56d08f1c9__h=1431522124__acp=800660a03aab58e96ec93211c5fc5db6__s=f398b7b975fb896b27fed55d213f6687" alt="" width="1" height="1" />
Questions
Do the images resources get cached, by default, on client side and the same get rendered on subsequent ad requests? If not, can it be enforced from server side, by passing "necessary" headers?
I tried testing with fiddler, and always observed "200 Ok" status being displayed for same images.
How do I know when a cached image is loaded?
Updates
Updated ad response format - HTML format.
The server generatng the HTTP protocol response is responsible for sending cache control headers along with it indicating whether it is permitted to be cached and if so whether the server needs to be informed before each use.
This blog begginners guide is a good place to start for details. Then move on to the RFC 7234 caching specification itself
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
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