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
Related
While customizing a Shopify page, I've added a dynamic button with the class of only
{% if section.settings.button_label != blank and section.settings.button_link != blank %}
<a href="{{ section.settings.button_link }}" class="btn">
{{ section.settings.button_label | escape }}
</a>
{% endif %}
However, when the page loads, it has now appended .text-link to my button classes, overriding the styling of the button.
a.btn.text-link {
-webkit-appearance: none;
background-color: #2c2d36;
background-image: none;
border: 1px solid transparent;
border-bottom: 1px solid #2c2d36;
border-radius: 0;
box-sizing: border-box;
color: #fff;
cursor: pointer;
display: inline-block;
font-family: Futura,sans-serif;
font-size: .8125em;
font-weight: 700;
letter-spacing: .1em;
line-height: 1.42;
margin: 0;
padding: 8px 10px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
transition: background-color .4s ease-out;
user-select: none;
vertical-align: middle;
white-space: normal;
width: auto;
}
Anyone have a sense of where I should be looking to stop this from appending to my single class?
Link: https://shop.creekretreat.com/pages/services
(Group of buttons on first image/text section)
Thanks in advance, much appreciated.
K
There is a JS function in your theme.js which is doing this:
theme.styleTextLinks = function() {
$('.rte').find('a:not(:has(img))').addClass('text-link');
};
This function is called in the theme.init method:
theme.init = function() {
theme.initCache();
theme.setBreakpoints();
theme.fitNav();
theme.cartInit();
theme.afterCartLoad();
theme.checkoutIndicator();
theme.returnLink();
theme.styleTextLinks(); <----- here
......
You will need to update the JS to fit your needs or remove this logic all together.
I want to create tooltip with vue's style binding. I am thinking to use attr() function from CSS which takes attribute value which is a reactive object dynamicColor. The code which I have now is:
<div class="test">
<span class="marker" :style="{'background': dynamicColor}" :color="dynamicColor">
smallText
</span>
</div>
<style>
div.test span.marker {
position: absolute;
width: 28px;
height: 15px;
border-radius: 2px;
display: block;
top: -25px;
font-size: 10px;
text-align: center;
}
div.test span.marker::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 6px;
border-style: solid;
border-color: attr(color) transparent transparent transparent;
}
</style>
But it does not work. I don't want to use bootstrap due to some reasons. I tried to look if I can find for pseudo selector in vue style binding but could not find much. Any ideas on how to achieve this? Thanks.
As suggested by #Stephan-v in comments, I added separate element for arrow. The final code looks like something below:
<div class="test">
<span class="markertip" :style="{'border-color': dynamicColor + ' transparent transparent transparent'}"></span>
<span class="marker" :style="{'background': dynamicColor}">
smallText
</span>
</div>
<style>
div.test span.marker {
position: absolute;
width: 28px;
height: 15px;
border-radius: 2px;
display: block;
top: -25px;
font-size: 10px;
text-align: center;
}
div.test span.markertip {
content: "";
position: absolute;
top: -45%;
margin-left: -5px;
border-width: 6px;
border-style: solid;
}
</style>
I'm hoping someone would be able to help me with my query. I've done quite a bit of research online and haven't found any particular solution to it yet.
While running my test case, I sometimes encounter an HTML popup that I'm unable to handle in my script. It is very random (well based on customer behaviour while they are traversing the site) and can popup at any time during the customer journey. Sometimes it doesn't popup at all. When it appears only then an entry is visible inside the DOM.
Basically, it is a livechat window (LivePerson to be precise) suggesting customers that an agent is available to help them complete their order if they wish to do so.
Here is a screenshot:
popup screenshot
The below is available in Firebug when I inspect the element:
<div id="LPMcontainer-1483053256847-0" class="LPMcontainer LPMoverlay" style="margin: -143px 0px 0px -285px; padding: 0px; border-style: solid; border-width: 0px; outline-color: rgb(106, 159, 177); outline-width: 2px; font-style: normal; font-weight: normal; font-variant: normal; list-style: outside none none; letter-spacing: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: normal; word-spacing: normal; background-repeat: repeat-x; background-position: left bottom; background-color: transparent; border-color: transparent; width: 571px; height: 287px; cursor: pointer; display: block; z-index: 107158; position: fixed; top: 50%; bottom: auto; left: 50%; right: auto;">
<div role="button" tabindex="0"><img src="https://www./content/dam/tcom/apps/live-person/live-person-chat-bundles-top.jpg" id="LPMimage-1483053256849-2" alt="" class="LPMimage" style="margin: 0px; padding: 0px; border-style: none; border-width: 0px; outline-color: rgb(106, 159, 177); outline-width: 2px; font-style: normal; font-weight: normal; font-variant: normal; list-style: outside none none; letter-spacing: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: normal; word-spacing: normal; position: absolute; z-index: 600; left: 0px; top: 0px;">
</div>
<img src="https://www./content/dam/tcom/apps/live-person/live-person-chat-bottom.jpg" id="LPMcloseButton-1483053256847-1" alt="" class="LPMcloseButton" style="margin: 0px; padding: 0px; border-style: none; border-width: 0px; outline-color: rgb(106, 159, 177); outline-width: 2px; font-style: normal; font-weight: normal; font-variant: normal; list-style: outside none none; letter-spacing: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: normal; word-spacing: normal; position: absolute; cursor: pointer; z-index: 9999; left: 0px; top: 194px;" data-lp-event="close" role="button" tabindex="0">
</div>
It appears in all browsers.
I'd like to handle it in either of the following ways:
Stop it from loading at all (again due to random nature ).
OR
While the script is being executed, as soon as the window appears, it presses 'No thanks' button (id="LPMcloseButton-1483053256847-1" in the above code) and then continue executing the rest of the steps. Please note that id is dynamic in nature, i.e it's unique every time.
Your help would be highly appreciated.
It may not be random. Some sites that I write automation for have something like this also. After some investigation I found that the dialog always popped up after 30 seconds... it just seemed random because I could be on any page when the 30s was up. After more investigation I found that the site looked for a cookie and if it wasn't found, the dialog would be triggered. I found the cookie that was created after the dialog was closed and created it at the start of the script so that it would no longer open.
I would suggest that you look for an existing cookie that was created for that site and see what's in it. Then browse to the site, wait for the dialog to pop up, and close it. See what changes... if the cookie changes or a new cookie is added, etc. then just mimic that behavior before browsing the site.
NOTE: In my case, I had to intentionally browse to a missing page on the domain, e.g. somesite.com/someerrorpage, to create the cookie without the timer starting. Then I just navigated to the site and continued the script.
I'd say the easiest way to get around this is to create a webdriver wrapper that for every call you would send to webdriver, first check if the dialog is present. If it's present, close it, otherwise send the action over to webdriver.
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>
I am trying to access REST service hosted on console application from ajax GET/POST. As there will be different ports used in two applications , I have configured REST service to handle cross origin requests. I have tried every available solution , still I am unable to access the service from ajax and getting 405.
I am sharing Raw request-response stream captured by http analyser.
OPTIONS /Service/Contacts?_145***************** HTTP/1.1
Accept: */*
Origin: http:localhost:1053
Access-Control-Request-Method: GET
Access-Control-Request-Headers: access-control-allow-origin, access-control-allow-methods
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: bhawesh-pc:8000
DNT: 1
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: 0
HTTP/1.1 405 Method Not Allowed
Allow: POST, GET
Content-Type: text/html; charset=UTF-8
Server: Microsoft-HTTPAPI/2.0
Access-Control-Allow-Origin: *
Access-Control-Request-Method: POST,GET,PUT,DELETE,OPTIONS
Access-Control-Allow-Headers: X-Requested-With,Content-Type
Date: Tue, 05 Jan 2016 17:57:44 GMT
Content-Length: 1565
<?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>Service</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">Service</p>
<p>Method not allowed.</p>
</div>
</body>
</html>
REST service configuration are based on http://enable-cors.org/server_wcf.html and http://www.khalidabuhakmeh.com/rest-http-verbs-and-iis-express
This is not a valid HTTP GET request:
Access-Control-Request-Method: GET
Access-Control-Request-Headers: access-control-allow-origin, access-control-allow-methods
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: bhawesh-pc:8000
DNT: 1
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: 0
The first line of a GET request should be:
GET /wanted_resource HTTP/1.1
So, if the server looks at the requested method at the beginning of the header, it sees this:
Access-Control-...
and will return a 405 Method Not Allowed.
Also, with GET, no Content-Length header is needed. It is better to remove that line.
I resolved the problem by these guidelines :
Try to avoid preflight request more Information ( In my case , I removed custom headers from request.)
Do not set withCredentials property to true in client request if you have
set Access-Control-Allow-Origin : * on service.
But , this solves only GET request problem. In the POST , I was getting the same problem , but this solution worked like magic.