4
votes

I'm creating my client/server application intercommunication with ServiceStack, and is working great, but I need also to access an external SOAP web service.

I tried to use the Soap12ServiceClient to access it, but I couldn't find any example, and then I went the add service reference WCF way that actually worked, but creating a ton of code.

Is it possible to use Soap12ServiceClient in the same easy way I use JsonServiceClient to send a message/request and receive the message/response? If so, can you help or point me to a sample?

1
Old question but I was interested in doing the same thing -- use ServiceStack's SOAP client to call an external SOAP endpoint instead of having to use Visual Studio's bloated, generated proxies. After a little trial and error, I noticed that ServiceStack's Soap11ServiceClient and Soap12ServiceClient have hard-coded endpoints of "/Soap11" and "/Soap12". So, unfortunately, this is not possible.PatrickSteele

1 Answers

1
votes

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.