Rest Inference
This short tutorial will guide you through the architecture inference function.
We will create a new project and add a rest service, and the initial WADL file is started.
Once the request is sent, we can use the response to build our schema.
Demo Request
to demonstrate the principles, we will take a demo from a An example of Flickr's rest .
https://www.flickr.com/services/rest/?method=flickr.test.echo&format=rest&foo=bar&api_key= D6c7b624b138bcb07a2e2c736aefeb65
The request (when successful) returns the following response in this format:
<RSP stat= "OK" > <method>flickr.test.echo</method> <format>rest</format> <foo>bar</foo> <API_KEY>9E5F204388E9D6070B6B1423876BE728</API_KEY></RSP >
NOTE: The main changes to the API, so you may need to visit Flickr's Rest demo site and get an up-to-date API key.
Create Projects and services
Get very easy to request to a rest project:
- Open file menu
- Select a new rest project
In the Create Rest Project window, open:
- Copy and previous URLs into the area
The project is created and added to the workspace:
The URL from the requested parameter is automatically extracted and can be viewed in the editor.
Requests and responses
Now we initiate the request:
The request contains all the parameters that are defined in it. Parameters are pre-populated with default values.
We have not yet sent the request, so the response is blank:
Schema tab
The rest of the reaction looks at the label with the so-called "architecture" at the bottom. This is the inference schema checker.
No information has been logged yet.
In general, we want to automate the process of conflict resolution. But for demonstration purposes, this time we will take the manual:
- Make sure that automatic parsing is disabled.
Get response
The request is sent, and we get a response:
NOTE: The main changes to the API, so you may need to visit Flickr's Rest demo site and get an up-to-date API key.
The Schema tab has changed to indicate that the schema conflicts have occurred:
This means that the analysis of the reaction shows that there is a conflict between the current response and the previously inferred pattern.
Now we can resolve the conflict manually.
For each conflict detected, we get a notification and can act as needed.
In this case, we can assume that all conflicts should be resolved (again, without the previous pattern).
All conflicts are then automatically resolved and logged in the log mode:
Inference schema
When all conflicts have been resolved, the schema is added on the Schema tab:
So far, we can see a namespace and have an XSD schema associated with it. As a schema based on only one response, we can optimize it with a few more requests. We should try to change the response so that they are as different as possible. For example, we can issue an invalid request so that we can infer a schema failure, or make a query request that returns an empty result set, and so on.
Add definition
More responses can be automatically added to the schema by simply sending different requests. Since we can assume that the reaction will be effective, we can use the "auto-resolve" function.
- Make sure that automatic resolution is enabled.
Different requests
In order to get a different response, we need to change the requirements:
This will ensure that we get an error response.
The request is sent, and we get a response:
This time, because a conflict has been resolved and automatically recorded:
Update mode
When all conflicts are resolved, the new response is included in the Schema tab:
The new response has been included in the schema:
Now you can continue to modify the requirements and build your own patterns.
SOAPUI Chinese operation Manual (vii)----WEB Service Sample Project