| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
When you create a service, there are by default three endpoints:
The preferred way to call the webservice is mostly using the REST endpoint. As you have seen, user-defined REST endpoints can be configured with the Route attribute for each request DTO.
But you can also call your service by using the default endpoint, without configuring a REST url with the default endpoint. Of course there's always the option to use the SOAP endpoint.
The possible requests for the following request DTO are:
[Route("/hello")]
public class Hello
{
public string Name { get; set; }
}POST example.org/soap11
<?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>
<Hello xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
<Name>String</Name>
</Hello>
</soap:Body>
</soap:Envelope>POST example.org/hello
{"Name":"World"}POST example.org/json/reply/Hello
{"Name":"World"}But you don't need to pass the Name of the request DTO in the request body. There's also the possibility to set the value of Name with URL parameters (works only with REST and default endpoint of course).
POST example.org/hello?Name=World
POST example.org/json/reply/Hello?Name=World
You can also combine the two approaches.
Last but not least there exists another way to set the value of Name! But this works only with the REST endpoint: If you add the following mapping to the request DTO above:
[Route("/hello/{Name}")]...you will be able to set the name in the URL itself, without any URL parameters:
GET example.org/hello/World
As you can see {Name} (in the mapping) is the placeholder for the value of the property Name.
Tip: The last two approaches are mostly used for GET and DELETE requests, because often clients don't support to attach a request body for these HTTP methods.
Tip: As you may have noticed, ServiceStack is also capable to support different formats (JSON, XML, etc). There exists another separate tutorial about formats.
Getting Started
Designing APIs
Reference
Clients
Formats
View Engines 4. Razor & Markdown Razor
Hosts
Security
Advanced
Caching
HTTP Caching 1. CacheResponse Attribute 2. Cache Aware Clients
Auto Query
AutoQuery Data 1. AutoQuery Memory 2. AutoQuery Service 3. AutoQuery DynamoDB
Server Events
Service Gateway
Encrypted Messaging
Plugins
Tests
ServiceStackVS
Other Languages
Amazon Web Services
Deployment
Install 3rd Party Products
Use Cases
Performance
Other Products
Future
| Back | FazBrowse Home | New Git URL |