Mocking Http-503 for a web service - web-services

I would like to mock a web service response for an HTTP 503 (Error 503--Service Unavailable) when The server is unable to handle the request due to a temporary overloading or maintenance of the server. What is the best strategy?
Thanks,
D

Here's what I use:
https://httpstat.us/503
No external software or dependencies required.

You can use the following Groovy script:
mockRequest.getHttpResponse().sendError(503)

Use xml mimic, you can mock almost everything with http response without the need for real server.
http://sourceforge.net/projects/xmlmimic/
http://sourceforge.net/projects/xmlmimic/

the use : https://designer.mocky.io/ for test 503 http request

Related

Call http web service from siddhi file

I need to call a web service from my siddhi file.
in my case isn't important waiting the response, i would call external http service and stop.
I have tried with http(sink) and http-request(sink) like doc:
https://wso2-extensions.github.io/siddhi-io-http/api/2.0.5/#http-sink
Someone can help me?
You will have to use HTTP sink if you want to do a fire and forget request. This testcase will help you in writing one. Also please refer this SO question. It is for making a SOAP request using HTTP sink.

How to test net.tcp binding WCF web services in Jmeter and soapui?

I am unable to test net.tcp wcf services in jmeter and soap ui.
it is showing Response message: java.net.UnknownHostException: net.tcp://******/WcfServiceLibrary1.Service1.svc/mex..your quick response will be help full.
Thanks in advance!!!
I believe you should use JMeter's TCP Sampler for this instead of HTTP Request sampler which supports only http, https anf file protocols.
I also think you will find How To Send Control Characters Using The JMeter TCP Sampler? article useful when it comes to sending non-alphanumeric data

Web service returns error “The remote server returned an unexpected response: (400) Bad Request”

I am calling Web Service in my windows application(Web service is in same project). It works fine when I use it with test database, but when I change database schema to QA in web Service. It gives me error " “The remote server returned an unexpected response: (400) Bad Request”
The web service is same but still gets error when I change schema.This is Web Service, not WCF service and I am using VS2010. I am not understanding what is happening wrong here. Any help would be greatly appreciated. Thanks.
There is error in paramters you supply to webpage (webservice) of website. Check what you supply in headers of your request object.
Actually, one of the values in the DTO which was passed to webmethod was having some bad data(say, memberid="H00001\0\0\0\0"). I corrected this value and assigned to DTO before passing to webmehtod. And it worked fine. Thanks kostas ch. and Salahuddin for your help!

SoapUI : Mock service that not returning response

Is there possible create SoapUI Mock service that not return response but it is just closing connection?
I'm quite sure what you're asking for is not possible with SoapUI MockServices. There are some extensive possibilities involving scripting, and it is even possible to access the underlying javax.servlet.http.HttpServletRequest and Response objects. Have a look here for details:
http://www.soapui.org/Service-Mocking/creating-dynamic-mockservices.html
Using scripting, it is possible to write a mock service request handler like this in SoapUI that just resets and closes the output stream:
mockRequest.getHttpResponse().reset();
mockRequest.getHttpResponse().getOutputStream().close();
But the client will still see a HTTP response header like this generated by the servlet container:
HTTP/1.1 200 OK
Content-Length: 0
Server: Jetty(6.1.x)
It is generally not possible to abort the connection immediately from inside a servlet (which is what SoapUI mock services are built upon). Have a look here about this topic:
How to close a HTTP connection from the HttpServlet
I'd use something completely different than SoapUI, most likely a scripting technology like PHP or Perl to achieve what you're asking for.

HTTP 500 Internal error - throw explicitly in webservices

I am working on a web services application. I have a requirement to throw HTTP 500 error through my application for some test purposes. I use HTTPConnector class of apache to connect to various web services and I need to throw HTTP 500 to test something.
Sorry, your questions is not precise enough (e.g. programming language missing). In case you use Java I'd implement this as a Servlet filter.
In the filter you can then call response.sendError(int).