Recommended testing frameworks for testing SOAP as well as REST services? - wcf

We have several WCF services - some with SOAP endpoints and others that with REST endpoints. There are also some services that have both SOAP and REST endpoint (diff. customer specs/demands). So far when it comes to testing, we've written custom test clients from ground up purely for testing the actual service+endpoints. However, I'm not sure if that's the best approach because we also have to maintain the test applications as a separate 'product'.
Is there any recommended approach to formally test these endpoints and services? Hopefully one framework/pattern that can cover both SOAP as well as REST sides.

SoapUI can test both SOAP and REST web services. Check out its other features.

This answer is specific to testing RESTful web services. We use the following tools:
RestClient is a Java application to test RESTful webservices.
curl - Comes in the Cygwin distribution for windows. You can find linux installables for your flavor of linux here. Sample uses of curl to make REST calls:
curl -v http://flickr.com/rogermenezes/photos/61 -H 'Content-Type:application/json' -H 'X-FlickrAPI-Version:1.0' -X DELETE
curl -v http://flickr.com/rogermenezes/albums -H 'Content-Type:application/json' -H 'X- FlickrAPI -Version:1.0' -X POST -d '{"name": "hawaii 2011", "tags": "vacation, hawaii, ", "creation_date": "2012-02-22T13:42Z"}'
Chrome Plugin - Advance REST Client
You can install this plugin through the Chrome Web Store. You can save past requests and the plugin also maintains a history of previous calls you had made.
Fiddler2
Fiddler2 snoops your network traffic. It also provides a way to "reissue and edit" past requests. Here, you can edit your past REST requests and execute them repeatedly.

You can use the headers section to provide security token. Our services are secured and I use SOAPUI to organize tests

Related

Postman Automated Collection Generation

has anyone done an enterprise integration of their public API with Postman? Checking Postman pages it seems like everything is straightforward, however, I have some concerns:
I don't see the way to automatically install pre-request scripts. Pre-request scripts allow an easy and straightforward way to call the endpoints without going through authentication step manually.
If you use sync with Github you'll need to give Postman full access. Not sure how people work around that.
You need to convert swagger to postman definition. Default Postman has limited nested levels of API schema, which means your API documentation will need additional processing step
So I don't know if it's worth integrating API release to the Postman with the internal API management system, or rather have a simple script on a virtual machine.

Alternatives to JMS Queue Browser for STOMP over ActiveMQ?

My ActiveMQ messaging instance (ActiveMQ 5.16.2 on Amazon MQ) uses STOMP. I cannot use the JMS QueueBrowser, and there is no way to "unack" a message. As soon as there is a consumer that pulled that message from the queue i.e. marked as "unconsumed" as stated in the docs here.
Assuming the broker cannot be changed, I was looking at the REST API mapping of JMS here, but I do not see any endpoint that mimic the ActiveMQ admin pages (JSP), that is capable to browse the queue, consumers and message content without actively "pulling" those messages from the queue.
So, how to implement that JMS logic we can see in the ActiveMQ admin pages programmatically (e.g. via REST apis)?
Looking at the docs of REST API, assumed having the logon, this approach works
curl -XGET https://user:pass#server:8162/admin/browse.jsp?JMSDestination=ActiveMQ.DLQ
and it grab the JSP page output as on the web console, so I assume that it could be done via some "official" rest API.
NOTE. The ActiveMQ JSP page is not using any AJAX call, so I assume it is using the JMS Java API directly.
The REST/JMS mapping doesn't offer any message browsing functionality.
However, it's worth noting that the REST/JMS mapping is independent of the management functionality exposed by Jolokia. Jolokia is an HTTP-JMX bridge so anything exposed via JMX can be accessed via HTTP (e.g. using curl). The DestinationViewMBean has various "browse" methods you can use, e.g.:
$ curl -XGET -u admin:admin -H "Origin: http://localhost" http://localhost:8161/api/jolokia/exec/org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=TEST/browse\(\)
Where TEST is the name of your queue.
You can get a list of JMX objects using the search command, e.g.:
$ curl -XGET -u admin:admin -H "Origin: http://localhost" http://localhost:8161/api/jolokia/search/org.apache.activemq:*
You can read more about the Jolokia Protocol on their website.

How can we use WCF services from iPhone?

I am implementing an application that displays data which is coming from a back end server. The back end server is using WCF for writing web services. I am not familiar with that WCF.
What can I try to resolve this?
If your WCF application is configured to be a SOAP service, then any SOAP libraries for iOS can be used.
You can make HTTP or SOAP requests to WCF. Given an HTTP request, for example, you could test it using cUrl. In it's simplest form, a cUrl get request is as follows:
curl http://stackoverflow.com
You very well may need to make POST or PUT request. If so you can review the docs here: http://curl.haxx.se/docs/httpscripting.html. I've included an example POST request using cUrl:
curl -X POST -H 'Content-type: text/xml' -d <YOUR PAYLOAD HERE> http://stackoverflow/fakepost
There a loads of ways to make HTTP requests, cUrl is just a client for doing so.
The following describes an iOS implementation of a POST request: iOS: how to perform a HTTP POST request? .

How can I automate / schedule a WCF service call hosted in IIS?

I've got an extraordinarily simple service contract for a service that manages its own data import, similar to this:
using System.ServiceModel;
namespace Company.Services.Domain.Contract
{
[ServiceContract(Name = "ImportService", Namespace = "http://services.company.org/")]
public interface IImportService
{
[OperationContract]
ImportResponse ImportData();
}
}
I'd like to set up a scheduled task or something similar to execute this call on a daily basis. I know that I could write a console application and create a proxy via svcutil. But is there a way to configure this in IIS natively (maybe an IIS extension)? Or could I achieve something simple and elegant with PowerShell?
Just wondering what my options are.
You can have an IIS-hosted application that uses IIS auto-start, assuming you are running at least version 7.5 of IIS. The auto-start does not run on a timer, but will help guarantee that your application is always running. After IIS starts the application, your code can start a timer to call the WCF service each day.
The timer would, of course, be implemented in code. Examples of simple timer implementations include this, this, and this.
If you are using ASP.NET then put the timer start code in the Application_Start method in the global.asax file of the auto-started application.
You could use cURL (Windows and 'nix versions available): http://curl.haxx.se/
Set your scheduled task to invoke curl.exe with parameters appropriate to make a request to your web service's URL:
curl -o importResponse.txt http://services.company.org/ImportService.svc/ImportData
The -o will drop the response into a text file of the given name. Other configuration options can be found in the manual: http://curl.haxx.se/docs/manual.html
EDIT: This assumes that you're exposing a web service and GET (rather than POST or SOAP). If you're exposing a SOAP service it should still be fairly trivial because you're not passing any parameters.
curl --request POST --header 'Content-type: text/xml' --output importResponse.txt --data <SOAP/> http://services.company.org/ImportService.svc/ImportData
Alternatively, as you're using WCF you can expose your service as both a SOAP service and a RESTful web service simultaneously, by adding some configuration to your app's web.config: a webHttpBinding, a service endpoint, and an endpointBehavior, as per: http://weblogs.asp.net/kiyoshi/archive/2008/10/08/wcf-using-webhttpbinding-for-rest-services.aspx
Check ou New-WebServiceProxy. It's very useful, you point it at the url and it loads the web ervice. You can pipe it to Get-Member to see whats available as well.
Matt
EDIT: example now I'm not on my phone :-)
# url for the service
$url = "http://services.company.org/ImportService"
# Create the service - using default credentials
$service = New-WebServiceProxy $Url -UseDefaultCredentials
# explore the service
$service | gm
for more information check out the PowerShell help
help New-WebServiceProxy

Integration testing of a CAS secured web service

I have a web service that accepts CAS proxy tickets over HTTP Basic authentication headers via Spring Security. How do I perform integration testing with my client since there seems to be no programmatic way to fetch CAS tickets?
Since the CAS setup is one of the more tricky aspects of the project configuration I really need that to be part of our automated integration tests but I have hit a roadblock.
You be interested in the CAS RESTful API: https://wiki.jasig.org/display/CASUM/RESTful+API
The RESTful API follows the same basic protocol as the original CAS2 protocol, augmented with some additional well-defined resource urls. This is particularly helpful for applications that need to programmatically access CAS.
Hope this helps.