Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Make sure you read about <a href="https://github.com/ServiceStack/ServiceStack/wiki/SOAP-support">SOAP Limitations</a> when creating Services that you want to consume by SOAP. i.e. You need to keep a single XSD/WSDL namespace. E.g. You can change the default WSDL Namespace in your AppConfig with:</p> <pre><code>SetConfig(new EndpointHostConfig { WsdlServiceNamespace = "http://my.new.namespace.com/types", }); </code></pre> <p>This sets what WSDL/XSD namespace gets used on the generated WSDL page. You also need to match this custom XSD namespace with your <code>[DataContract]</code> DTOs by specifying a namespace for each DataContract which you can do by either specifying manually on each </p> <pre><code>[DataContract(Namespace="http://my.new.namespace.com/types")] </code></pre> <p>or you can use specify the </p> <pre><code> [assembly: ContractNamespace("http://my/custom/namespace", ClrNamespace = "TheGuest.Test")] </code></pre> <p>to set it on a number of DTO's under a shared C# namespace.</p> <p>Also a few things have changed recently, we've added the <a href="https://github.com/ServiceStack/ServiceStack/wiki/New-Api">New API</a> and added different attributes to allow you annotate your services (that will appear on the /metadata and Api Docs/Swagger pages). Taking account of these changes the new way to create your service is:</p> <pre><code>[DataContract] [Api("A sample web service.")] public class Greet { [DataMember] [ApiMember("The name of the person you wish to greet")] public string Name { get; set; } } [DataContract] public class GreetResponse { [DataMember] public string Result { get; set; } } public class GreetService : Service { public GreetResponse Any(Greet request) { return new GreetResponse { Result = "Hello " + request.Name }; } } </code></pre> <h2>Telling ServiceStack what the Services Response Type is</h2> <p>In order for ServiceStack to determine what the Response Type of your service is, you need to provide any of the below hints:</p> <h3>Using a strong type return type</h3> <p>Your services can either return an <code>object</code> or now a <code>ResponseDto</code> type, e.g:</p> <pre><code>public class GreetService : Service { //1. Using Object public object Any(Greet request) { return new GreetResponse { Result = "Hello " + request.Name }; } //2. Above service with a strong response type public GreetResponse Any(Greet request) { return new GreetResponse { Result = "Hello " + request.Name }; } } </code></pre> <p>If you use option 2) ServiceStack will assume a <code>GreetResponse</code> type.</p> <h3>Use the IReturn marker interface</h3> <pre><code>[DataContract] public class Greet : IReturn&lt;GreetResponse&gt; { ... } </code></pre> <p>Another advantage of using a Marker interface is that it provides a more succinct client API, e.g:</p> <pre><code>GreetResponse response = client.Send(new Greet { Name = "World!" }); </code></pre> <p>If you didn't have the Marker interface the client API would've been:</p> <pre><code>GreetResponse response = client.Send&lt;GreetResponse&gt;(new Greet { Name = "World!" }); </code></pre> <h3>Use a typeof(RequestDto).Name + 'Response' naming convention</h3> <p>If your services have an <code>object</code> response type and no marker interface than you can use the name <code>{RequestDto}Response</code> naming convention to tell ServiceStack what the Response type is.</p> <p>Note: For ServiceStack to be able to find the Response type it <strong>needs to be in the same namespace</strong> as the Request DTO. Also every Request and Response DTO should be uniquely named, this is what lets you call a ServiceStack service with just the <strong>Name of the Request DTO</strong> and not the full namespace.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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