I know there is no such code defined by standards, but is there any standard error code used generally by people for browser version not supported, and if not, which is the nearest match that can be used for such scenarios: 415, 406, 501
If you are in control of the intended client you can just invent your own status code. Else if the client is a web browser it won't make a big difference what you choose but 501 seam like the closest match.
Related
I have a SOAP endpoint and will be having more than 1000 request messages which have different values for the request parameters but same operation of SOAP Message. I want to execute them in a sequence if the previous request that got triggered was 200 OK?
Is there any way to do this without JAVA program? Is there any client that will help me?
I assume you already have some sort of loop in your test case that reads your variable properties from a file or perhaps Excel and feeds them into your SOAP request. Ready API/soapUI Pro gives you this functionality, but for open source soapUI you'll have to write your own Groovy test steps.
Then, you can use a soapUI Compliance, Status and Standards assertion to check you've received a valid or invalid HTTP status code and react accordingly.
Is there any way to do this without JAVA program? Is there any client
that will help me?
After re-reading the question, it seems to me you're not yet using SoapUI, though it has been tagged as a SoapUI question. It happens quite a lot on here where people are askign general SOAP questions, but tag SoapUI. BTW, Craig's answer should be accepted if you are using SoapUI.
In terms of options, you have lots....
Code. You can use Python, C#, Java, Javascript, etc. etc. to create a program that will call your endpoint. Any programming language will have the libraries to call web services. So, if you do know a language, you could use that.
SoapUI. There is a free version, which will allow you to call web services. In your question, you want to call the same service over and over with different parameters. In testing speak, this is a data-driven test. These can be achieved in the free SoapUI, but it is a fiddle. However, the full-licensed version offers data-driven tests out of the box. I use these all the time. Very easy to set-up. If you use SoapUI, then Craig's answer about using Assertions would stop the test if you got a status code other than a 200.
Postman. this is another free tool, which I have used a little. I haven't tried data-driven tests, but I'm sure the docs will tell you if they're supported. If you try Postman, then you ought to look at Danny Dainton's excellent tutorial on GitHub
JMeter. Another free tool. This is primarily used for performance and load testing, but would still meet your needs.
I am just wondering , is there a way by which i could figure out if website is using perl . Like i can tell with built with that it uses wordpress or php .
You cannot ask a web site what language it's implemented in. There are no rules that say a ".php" URL has to be running PHP (though it probably is), that is all decided on the server side. There's no guarantee that a site which says "Powered By Wordpress" is indeed using by Wordpress. In general, it's poor security to give away information about your implementation details as an attacker can use that to select a known attack.
However, there's plenty of ways to guess.
One of the simplest ways to tell is to look at the URL. Does it end in a ".pl"? Its probably Perl (or you're looking at a Polish domain).
If you look at the response headers, sometimes the web server will clearly identify itself as using Perl. For example, you can use curl -I to request just the HTTP headers from the server and look at the "Server" and "X-Powered-By" headers.
$ curl -I http://perldancer.org
HTTP/1.1 200 OK
Date: Wed, 27 Mar 2013 05:04:14 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Server: Perl Dancer 1.311
Content-Length: 19849
X-Powered-By: Perl Dancer 1.311
Probably using Perl. Though again, the "Server" and "X-Powered-By" fields are purely informational and used for statistics gathering. Basically it's bragging. The server is not required to be telling the truth. In fact, it's a minor security issue that they advertise it.
If the web page identifies what technology it's using, for example http://blogs.perl.org says it's Powered By Movable Type, you can look and see if it's written in Perl.
Sometimes you can get hints from small details in the HTML and other content. Sometimes they clearly state in comments what is used to output the HTML. Sometimes you can guess based on certain form fields. Sometimes you can tell from the cookie names and values. Sometimes you can tell from how it creates JSON, XML, YAML or RSS output. Sometimes the generating software will identify itself in image and PDF headers.
There are tools such as nmap which will guess the operating system based on very small details of how it implements its networking protocols, but I don't know of such a thing for detecting the implementation language of a web site.
And, as Collin suggested, you can try to make the server spew out an error message.
But you can't ever really know. This is the beauty of the web as a universal communication protocol, it doesn't matter what it's written in.
Not in a general sense. If the person creating the website doesn't leak information about their implementation, you won't be able to find out.
If you can cause an error somehow, sometimes the generated error messages will give you clues to the implementation.
I am in the process of scoping the development of an iPhone app for a client. Among other things, the app will allow users to browse through and place orders on specific (tangible) products.
The client has a website that currently does a similar thing and due to their limited budget and the fact that the website runs on a third-party proprietary platform which they have no control over, we are investigating possible alternatives to building a web service.
On the website, user registration and authentication, as well as order placing is done through POST requests via secure HTTP. The response is always a formatted HTML page which will contain strings indicating whether the request was successful or not, and if there was an error, what the error is etc.
So provided I can replicate the POST requests on the phone, and parse the HTML responses to read the results of each request, do you think this is an acceptable alternative to building a web service to handle this?
Apart from the possibility of pages changing (which we can manage) and the fact that I will probably have to download and parse a relatively large HTML response, are there any other drawbacks to this solution and is there anything else that I might be missing?
Many thanks in advance for your thoughts.
Cheers,
Rog
You could create an intermediary server that will communicate with the client server, and on it expose some REST web services with json (small overhead and easy to handle) responses that will be consumed by the iPhone app.
So, you're going to parse HTML and formulate POSTs off a third-party server, and pray that they don't even so much as rename a form field.
Your question is in two parts:
Do I think that a miracle is an acceptable solution? I don't.
Do I think that aside from the fact a miracle is required, are there any other drawbacks? None that I can think of.
You didn't ask, but this is a terrible course of action. Two suggestions.
I spy an assumption that the providers of the third-party platform aren't interested in enabling third-party applications by providing an API. They have a very good business reason for this, which is that it promotes platform lock-in. Reach out to their support department and have a talk with them.
You have to sell the client on building an intermediary web service. To at least try to mitigate the damage that changes on this third-party platform can do to your app, I recommend that you build and operate a proxy that receives requests from your applications, and proxies them over to the third-party platform. You should build into this client-server protocol a means for returning "we are in maintenance mode, go away" messages to apps, for that inevitable day when the third-party server changes something that breaks your app (they swapped the billing and shipping address pages, for instance) and you have to rush through an update through Apple to deal with it.
The proxy could be written in something more flexible and easy to bash stuff out in, such as PHP, Python, Perl, or Ruby. It could be hosted at Amazon in a micro instance.
p.s. This question is inappropriately tagged objective C.
HTML is the worst because of parsing (1-2secs per page), memory, and changes, but you already know that. Check in advance that ALL the data you need is exposed on the HTML.
If you use an intermediary server you are moving work elsewhere and you have another server to maintain. I would only do that if memory is an issue. Check How To Choose The Best XML Parser for Your iPhone Project for memory/performance/xpath support. libxml2 is a good option, but it depends on your needs. And maybe you'll want to check ASIHTTPRequest features before using the SDK.
I think utilising the web language of JSON would contribute to the diminishing of the parsing time. By building a REST service that, when sent a GET request, returns the correct information for easy sorting, you could then display the output a lot faster than that of parsing straight HTML.
I prefer JSON over XML, but everyone has their personal preference. You should look at a few very good libraries that are built specifically for parsing purposes of both XML and JSON.
For XML I recommend using the inbuilt libxml parser. Albeit, this can sometimes deem very difficult to use. A simple Google search will bring up a heap of results that relate specifically to what parser should be used depending on what task is to be completed.
As for a JSON parser, I recommend SBJSON. I am currently using it one of the biggest projects I have undertaken and it is definitely working perfectly for my use.
If you need a good way to connect to a RESTful web service, you should try LRResty.
Don't go for a parsing solution on the iPhone for 4 reasons:
Server can change their design and break your application (AppStore submition is long) + They can also detect that the request are sent from an application based on user agent which you have to update the application to change it.
Some of the requests might be made thru Javascript so you not only have to parse (X)HTML but also Javascript request (which can be in the form of XMLHttpRequest, but don't have to)
Long term evolution of the mobile market : maybe your client want (or will want) an application for android, Blackberry, Bada OS (Samsung), Symbian (Nokia/ OVIStore), Java Mobile or Windows Phone 7?
Of course network traffic, Memory and CPU needed to parse HTML (look the time it takes to the browser to do it?)
Regarding the traffic, if the application will not have a huge traffic you can home-host your proxy. Or you can find some provider to host it for you. I guess you won't need more than a couple of Megabytes of storage but maybe traffic. For less than 100€/year you can find some with unlimited traffic (like OVH Pro plan or Infomaniak). But if you want to go Java have a look at Google App Engine : you pay only if your traffic is important and if your application generate many CPU Cycles. If not : you don't have to pay. And it's hosted on Google server : reliable.
If the client is open, you could consider the paypal API.
Does anybody know of an implementation of a REST client that embraces the constraint of Hypermedia as the Engine of Application State (HATEOAS)?
The Sun Cloud API seems to be a good candidate, judging from the way it's documented and a statement by the author to the effect that Ruby, Java, and Python implementations were in the works. But so far I've found no trace of the code.
I'm looking for anything - even a partial implementation would be helpful.
The very first thing you should look at is the common web browser. It is the standard for a client that embraces HATEOAS (at least to some degree).
This is how Hypermedia works. It's so simple that it's almost painful:
you point your browser to http://pigs-are-cool.org/
the browser loads the HTML page, images, CSS and so on.
At this point, the application (your browsing experience) is at a specific URI.
The browser is showing the content of that URI
you see a link in the application
you click the link
the browser follows the link
at this point, the application is at a different URI
The browser is showing the content of the new URI
Now for a short explanation of how the two terms relate to the web browsing experience:
Hypermedia = HTML pages with the embedded links
Application state = What you're seeing in the browser at any point in time.
So HATEOAS actually describes what happens in a web browser when you go from web page to web page:
HTML pages with embedded links drive what you see in the browser at any point in time
The term HATEOAS is just an abstraction of this browsing experience.
Other examples of RESTful client applications include:
RSS and Feed readers. They traverse links given to them by users
Most AtomPub blog clients. They need merely a URI to a services document, and from there they find out where to upload images and blog posts, search and so on.
Probably Google Gadgets (and similar), but they're merely browsers in a different skin.
Web crawlers are also RESTful clients, but they're a niche market.
Some characteristics of RESTful client software:
The client works with with any server, given that it is primed with some URI and the server responds with an expected result (e.g. for an atom blog client, an Atom services document).
The client knows nothing about how the server designs its URIs other than what it can find out at runtime
The client knows enough media types and link relations to understand what the server is saying (e.g. Atom or RSS)
The client uses embedded links to find other resources; some automatically (like <img src=) some manually (like <a href=).
Very often they are driven by a user, and can correctly be termed "user agents", except for, say GoogleBot.
Restfulie is a Ruby, Java, and C# framework which aims to enable building clients and servers which employ HATEOAS. I haven't used it, but it does look interesting.
Here's some example code from their java project:
Order order = new Order();
// place the order
order = service("http://www.caelum.com.br/order").post(order);
// cancels it
resource(order).getTransition("cancel").execute();
Again, I'm not sure exactly what this does, or how well it works in practice, but it does seem intriguing.
The problem with REST HTTP and HATEOAS is that there is no common approach to specifying links so it is hard to follow links since their structure might change from a service provider to another. Some would use <link href="..." /> others would use proprietary structure for of links ex. <book href="..." />. It is not like in HTML or atom were link are part of a standard defined.
A client can't know what a link is in your representation is it doesn't know your media type unless there is a standard or conventional representation of a link
The HATEOAS design principle (REST is a set of design principles also) means that each resource should have at most a single fixed URL.
Everything else related should be discoverable dynamically from that URL through "hypermedia" links.
I just started a wikipedia stub here
In the meanwhile, there is the Spring HATEOAS project. It has also a client implementation:
https://docs.spring.io/spring-hateoas/docs/current/reference/html/#client
Map<String, Object> parameters = new HashMap<>();
parameters.put("user", 27);
Traverson traverson = new Traverson(URI.create("http://localhost:8080/api/"), MediaTypes.HAL_JSON);
String name = traverson
.follow("movies", "movie", "actor").withTemplateParameters(parameters)
.toObject("$.name");
I want to call some RESTful web services from a J2ME client running on a MIDP enabled mobile device. I read the MIDP api for HTTPConnections and thought this is just crying out for a simple wrapper to hide all those unpleasant byte arrays and such like. Before I write my own I wondered whether there was a good open source library already available.
-FE-
You might want to check out this little gem, Mobile Ajax for Java ME:
https://meapplicationdevelopers.java.net/mobileajax.html
One part is (from the site):
Asynchronous I/O for Java ME
This library provides the equivalent
of XmlHttpRequest for Java ME with
some additional functionality useful
for invoking RESTful web services.
It is layered on top of the
com.sun.me.web.path library. Features
include -
* Asynchronous versions of HTTP Get and Post
* HTTP Basic Authentication
* Multipart MIME (sender only)
* Progress listeners
LWUIT 1.5 now includes classes for accessing REST, using OAuth2, JSON, etc.
I don't know of any such library, but found some succinct examples of accessing various RESTful web services
We ended up writing our own simple wrapper api for a variety of reasons not the least of which was the fact that the Sony Ericsson K750 that we were developing for had a weird bug (that SE refused to fix) where if you tried to get/use a connection when the device was off network, more than about 20 times, the internal connection pool would get hosed and never recover unless you restarted the app.