Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the best practice in defining a soap service (generic vs. specific operation)?
    text
    copied!<p>My situation is as follows:</p> <p>I have a normalized database, in which I hold geographic information about airports. The structure is:</p> <pre><code>airport --is in--&gt; city --is in--&gt; country --is in--&gt; continent </code></pre> <p>Now I want to let users administrate this data, without giving them direct access to the database. We need to offer this administration interface via a web service.</p> <p>Now, when it comes to designing the service, we ran into the discussion about how to define the operations. We came up with different solutions:</p> <p><strong>Solution A: specific operations</strong></p> <p>For each of the four tables (airport, city, country, continent) we define 3 operations:</p> <ul> <li>insert</li> <li>get</li> <li>update</li> </ul> <p>This would lead to 12 operations with 2 request/response objects = 24 objects</p> <p>To create an all new airport with all dependencies, at least 4 requests would be necessary.</p> <p><strong>Solution B: generic</strong></p> <p>There is only one operation, which is controlled via parameters. This operation is capable of creating everything needed to administer the database.</p> <p>The operation would decide what needs to be done and executes it. If an error occures, it will roll back everything.</p> <p>==> 1 Operation = 2 highly complex request/response-objects</p> <p><strong>Solution C: Meet in the middle 1</strong></p> <p>One generic operation per table, which is capable of executing get, insert, update, just like solution B, but focused on one table each.</p> <p>==> 4 operations = 8 complex request/response-objects</p> <p><strong>Solution D: Meet in the middle 2</strong></p> <p>One generic operation per action (get, insert, delete), which can work on each table and resolve dependencies.</p> <p>==> 3 operations = 6 slightly more complex request/response-objects</p> <p><strong>Example</strong></p> <p>Since this was rather abstract, hier a simplified example for request-objects for creating (JFK/New York/USA/North America):</p> <p><strong>Solution A:</strong></p> <p>Request 1/4:</p> <pre><code>&lt;insertContinent&gt;North America&lt;/insertContinent&gt; </code></pre> <p>Request 2/4:</p> <pre><code>&lt;insertCountry continent="North America"&gt;USA&lt;/insertCountry&gt; </code></pre> <p>Request 3/4:</p> <pre><code>&lt;insertCity country="USA"&gt;New York&lt;/insertCity&gt; </code></pre> <p>Request 4/4:</p> <pre><code>&lt;insertAirport city="New York"&gt;JFK&lt;/insertAirport&gt; </code></pre> <p><strong>Solution B:</strong></p> <p>Request 1/1:</p> <pre><code>&lt;action type="insertCountry" parent="North America"&gt;USA&lt;/action&gt; &lt;action type="insertAirport" parent="New York"&gt;JFK&lt;/action&gt; &lt;action type="insertContinent" parent=""&gt;North America&lt;/action&gt; &lt;action type="insertCity" parent="USA"&gt;New York&lt;/action&gt; </code></pre> <p><strong>Solution C:</strong></p> <p>Request 1/4:</p> <pre><code>&lt;countryAction type="insert" parent="North America"&gt;USA&lt;/countryAction&gt; </code></pre> <p>Request 2/4:</p> <pre><code>&lt;airportAction type="insert" parent="New York"&gt;JFK&lt;/airportAction&gt; </code></pre> <p>Request 3/4:</p> <pre><code>&lt;continentAction type="insert" parent=""&gt;North America&lt;/continentAction &gt; </code></pre> <p>Request 4/4:</p> <pre><code>&lt;cityAction type="insert" parent="USA"&gt;New York&lt;/cityAction &gt; </code></pre> <p><strong>Solution D:</strong> Request 1/1:</p> <pre><code>&lt;insert airport="JFK" city="New York" country="USA" continent="North America" /&gt; </code></pre> <p>Solution D seems rather elegant for me, therefore I tried to put this in XSD:</p> <p>Code:</p> <pre><code>&lt;complexType name="NewContinent"&gt; &lt;sequence&gt; &lt;element name="NAME" type="string"&gt;&lt;/element&gt; &lt;/sequence&gt; &lt;/complexType&gt; &lt;complexType name="NewCountry"&gt; &lt;sequence&gt; &lt;element name="ISOCODE" type="string"&gt;&lt;/element&gt; &lt;element name="NAME" type="string"&gt;&lt;/element&gt; &lt;choice&gt; &lt;element name="newCONTINENT" type="tns:NewContinent"&gt;&lt;/element&gt; &lt;element name="CONTINENT" type="string"&gt;&lt;/element&gt; &lt;/choice&gt; &lt;/sequence&gt; &lt;/complexType&gt; &lt;complexType name="NewCity"&gt; &lt;sequence&gt; &lt;element name="IATA" type="string"&gt;&lt;/element&gt; &lt;element name="NAME" type="string"&gt;&lt;/element&gt; &lt;choice&gt; &lt;element name="COUNTRY" type="string"&gt;&lt;/element&gt; &lt;element name="newCOUNTRY" type="tns:NewCountry"&gt;&lt;/element&gt; &lt;/choice&gt; &lt;/sequence&gt; &lt;/complexType&gt; &lt;complexType name="NewAirport"&gt; &lt;sequence&gt; &lt;element name="IATA" type="string"&gt;&lt;/element&gt; &lt;element name="NAME" type="string"&gt;&lt;/element&gt; &lt;choice&gt; &lt;element name="CITY" type="string"&gt;&lt;/element&gt; &lt;element name="newCITY" type="tns:NewCity"&gt;&lt;/element&gt; &lt;/choice&gt; &lt;/sequence&gt; &lt;/complexType&gt; </code></pre> <p>A corresponding request would then look like follows:</p> <pre><code>&lt;complexType name="Request"&gt; &lt;choice&gt; &lt;element name="AIRPORT" type="tns:NewAirport"&gt;&lt;/element&gt; &lt;element name="CITY" type="tns:NewCity"&gt;&lt;/element&gt; &lt;element name="COUNTRY" type="tns:NewCountry"&gt;&lt;/element&gt; &lt;element name="CONTINENT" type="tns:NewContinent"&gt;&lt;/element&gt; &lt;/choice&gt; &lt;/complexType&gt; </code></pre> <p>Now my question: <strong>Is this really the best solution available? Is the XSD enough to understand, what is going on?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload