To create web services that use JSON, the specific use cases have to be encapsulated within a Web Service Definition object (FSCOWS@1.1001:WebServiceDefinition).
In the following example, a web service contactaddress is used to fetch address data from a contact person who is identified via first name and surname.
Example |
---|
app.ducx Object Model Language instance WebServiceDefinition JSONWebSvc { app.ducx Use Case Language usecase GetContactAddress(string firstname, string surname, out Address address) { |
JSON web services can be accessed via a HTTP GET or HTTP POST method call via the “wsjson” Friendly URL.
http://localhost/fsc/wsjson/JSONSAMPLE_1_1065_JSONWebSvc/contactaddress?firstname=Leo&surname=Mayr
The „wsjson“ Friendly URL takes two parameters:
In case of HTTP GET the parameters are transmitted as URL parameters.
http://localhost/fsc/wsjson/JSONSAMPLE_1_1065_JSONWebSvc/contactaddress
In case of HTTP POST, the parameters are transmitted in the http request body as JSON string.
{
"firstname": "Cadence",
"surname": "Jones"
}
In both cases the result is sent in the HTTP response body.
Note: The key “address” within the JSON string corresponds to the outgoing parameter address of the GetContactAddress use case.
{
"address": {
"_": "Address",
"addrstreet": "Pfarrgasse 5",
"addrzipcode": "5409",
"addrcity": "Hallein",
"addrcountry": "Österreich",
"addrtopic": {
"_": "TermComponentObject",
"objaddress": "COO.1.1001.1.182477",
"objname": "Business"
},
"addrsource": {
"_": "ContactPerson",
"objaddress": "COO.1.1065.3.402",
"objname": "Jones Cadence"
}
}
}