SoapUI : Mock service that not returning response - web-services

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.

Related

How can I call a ASP.Net made web service without using MSXML?

I am using a very particular language named “Magik”, I used to use MSXML2 to run web services but in one of my projects I failed to use MSXML, I tried a lot of thing to make it work from changing MSXML.DLL and testing different version of MSXML, using MSXMLHttpServer and all the things you may think of, I somehow ate MSDN website but didn’t find anything helpfull.
Now I am looking for other ways of calling a SOAP webservice, someone said you may post your XML to web method address by parsing and using a query string, But I didn’t succeed to do so.
I can also negotiate via TCP/IP, Can I send my XML to a web service using a TCP/IP connection?
If there is any other way that do the job I really appreciate it.
Currently I am connecting Magik to a Java application and when I need to call a web service I send my request to that Java application (there is a Jar file which creates a data-bus between a Magik session and a Java Application) I have also wrote the Java part using Axis technology. But this is a very hard job and I should change a lot of things to only keep my project up and match with a small change in web service that I consume.
Using MSXML were so easy formerly, sadly it does not work now!
First note that you can not use GET to call SOAP web services only POST will work with SOAP, GET can be used for REST but you mentioned SOAP only.
I can introduce you two method that you may use to call a web service instead of your MSXML which does not work anymore.
Using Test Form (Web Service Test Page)
You may ask your .Net web services provider to create a test form for his own web service and you create a query string which suppose to emulate the data on the form, actually you are using the web services tester page to send your data via query string to it and it will complete the rest for you.
Using TCPIP
use a TCP/IP Connection, in this method you need to create a header above your xml to set the parameters that a web service consumer should fill (remember MSXML and Content-Type, Content-Length, SOAPAction, Host, …….)
then translate your string to a byte vector since all programming language which can create a TCPIP Socket just accept a byte vector while inputing or outputing data to that connection. after translating the string you are ready to send the data to your web services address.
take a look at the following example of how you may create a string to send to a TCPIP socket.
POST /globalweather.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.webserviceX.NET/GetCitiesByCountry"
<?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>
<GetCitiesByCountry xmlns="http://www.webserviceX.NET">
<CountryName>Egypt</CountryName>
</GetCitiesByCountry>
</soap:Body>
</soap:Envelope>
You may send above string to http://www.webservicex.net/globalweather.asmx
You may check to following link if you need detailed information about how to consume a web service using TCPIP
http://www.codeproject.com/Articles/312530/Calling-Webservice-Using-TCP-IP-from-any-Programmi

Mocking Http-503 for a web service

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

Automated testing of a SOAP Service

Before just answering: Use SoapUI. Please read the Question, because I tried SoapUI.
I have a lot big wsdl Files. Every Method works like this:
First do a synchronous Call:
Request: Please do foo and send Request to URI: XY
Response: Ok, your Job has UUID: abc
After the Job is done, my Sevice will respond to URI: XY, by sending only a request Message synchronously:
Request: Ok I finished your Job with the UUID: abc and the result is bar
We needed to use this behavior, because we have a pool where all answers will be stored and are identified by UUID.
Do you know a possibility to test such a SOAP Service?
I tried:
SOAP UI
BPEL Unit (I think it should be possible with BPEL Unit but I can't make it work properly)
Please don't recommend writing my own JAVA tests, because I have more than 100 methods to test.
Also the Tests need to be run and the results need to be analyzed automatically in a Test-suite, I can't do this for 100 Methods by hand everytime I change the code of the Web Service.
I'm one of the SoapUI Guys, so you'll probably HATE my answer...
But the solution is using SoapUI; more specifically using MockResponse TestSteps. SoapUI is NOT very strong when it comes to BPEL testing, but using MockResponse Steps you can fix it.
Look here: http://www.soapui.org/SOAP-and-WSDL/testing-asynchronous-services.html. Even though all calls are done synchronously, this can still be considered asynch testing since we have more than plain request/response.
I also know that Oracle has got a great write up on this.
What you need to do is to create a mock service that will receive the second call which signals that the job processing is done. This is can be done in SOAP UI, you can read about how to create a mock web-service here.
You can test Web Services by using Eclipse.
Just put the WSDL file on your project -> right click on the file -> web services -> test using web service explorer.
You will have an interface showing all your WSDL operations and fields which are needed.

PHP library similar to REST-driver in Java

I found this little library to be perfect solution for my problem. It allows you to stub REST service responses easily.
Now i need to replicate the same set of test cases in PHP version of our library. Do you know any similar library/framework in PHP?
You could use Guzzle. Guzzle is a PHP HTTP client & framework for building RESTful web service clients. The thing is that you can create Response objects. In this library, you have a Response class. You could just create the Guzzle Response that you want (choosing the desired status code, content, etc), and mock your HTTP Client so it returns the Response object that you just created.
If you read the documentation, it seems that there is a plugin to mock responses, although I've never used it.

Tool to intercept RESTful webservices

May be this has been asked before but i coud'nt find a proper tool to do this.
What is the best tool to place in the middle of a RESTful webservice and monitor it without port redirection.
Something like TCPMON which will show the full request from the client and the response from the server. For example if the response contain a JSON i should be able to view that??
Charles Proxy is great for logging the full request/response for HTTP connections.