forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientFactory.cs
More file actions
33 lines (26 loc) · 1.14 KB
/
ClientFactory.cs
File metadata and controls
33 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using ServiceStack.Common;
using ServiceStack.Service;
using ServiceStack.ServiceClient.Web;
namespace ServiceStack.Messaging
{
public static class ClientFactory
{
public static IOneWayClient Create(string endpointUrl)
{
if (endpointUrl.IsNullOrEmpty() || !endpointUrl.StartsWith("http"))
return null;
if (endpointUrl.IndexOf("format=") == -1 || endpointUrl.IndexOf("format=json") >= 0)
return new JsonServiceClient(endpointUrl);
if (endpointUrl.IndexOf("format=xml") >= 0)
return new XmlServiceClient(endpointUrl);
if (endpointUrl.IndexOf("format=jsv") >= 0)
return new JsvServiceClient(endpointUrl);
if (endpointUrl.IndexOf("format=soap11") >= 0)
return new Soap11ServiceClient(endpointUrl);
if (endpointUrl.IndexOf("format=soap12") >= 0)
return new Soap12ServiceClient(endpointUrl);
throw new NotImplementedException("could not find service client for " + endpointUrl);
}
}
}