Access SOAP webservice with ServiceStack

大城市里の小女人 提交于 2019-12-01 06:35:05

I'm not sure where you're stuck as all of ServiceStack's C# Service Clients implement the same IServiceClient so they can be used in the same way. Here is an example of all of ServiceStack's built-in C# Service Clients calling the same Hello World service:

[TestFixture]
public class HelloWorldServiceClientTests
{
    public static IEnumerable ServiceClients
    {
        get
        {
            return new IServiceClient[] {
                new JsonServiceClient(Config.ServiceStackBaseUri),
                new JsvServiceClient(Config.ServiceStackBaseUri),
                new XmlServiceClient(Config.ServiceStackBaseUri),
                new Soap11ServiceClient(Config.ServiceStackBaseUri),
                new Soap12ServiceClient(Config.ServiceStackBaseUri)
            };
        }
    }

    [Test, TestCaseSource("ServiceClients")]
    public void HelloWorld_with_Sync_ServiceClients(IServiceClient client)
    {
        var response = client.Send<HelloResponse>(new Hello { Name = "World!" });

        Assert.That(response.Result, Is.EqualTo("Hello, World!"));
    }
}

Although SOAP works similar to any other C# client, it's un-common to use it in this way because if you're able to use a generic C# SOAP service client you're also likely able to use any of the other service clients which are all faster, more resilient and more versionable than SOAP - which has effectively has no redeeming quality over the other formats other than its ability to generate client proxies which you said you don't want to do anyway.

If you're undecided which endpoint or format you should use I recommend reading my Interview on InfoQ which discusses the disadvantages of SOAP and the benefits of using the other formats.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!