1

I've written a simple self-hosted (in a ConsoleApplication) rest service with service stack 3.9.70.

using System;
using System.Runtime.Serialization;

// service stack support
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints;

namespace HelloWorldConsole
{
    namespace DTO
    {
        [DataContract(Namespace = "http://localhost:8080/types")]
        [Route("/hello/{Name}")]
        class Hello : IReturn<HelloResponse>
        {
            [DataMember]
            public string Name { get; set; }
        }

        [DataContract(Namespace = "http://localhost:8080/types")]
        class HelloResponse
        {
            [DataMember]
            public string Response { get; set; }
        }
    }

    class HelloService : IService
    {
        public Object Any(DTO.Hello request)
        {
            return new DTO.HelloResponse { Response = "Hello " + request.Name };
        }
    }

    public class HelloHost : AppHostHttpListenerBase
    {
        public HelloHost()
            : base("Hello Service Self-Host",
                typeof(HelloService).Assembly)
        { }

        public override void Configure(Funq.Container container)
        {
            SetConfig(new EndpointHostConfig
            {
                DebugMode = true,
                WsdlServiceNamespace = "http://localhost:8080/",
                WsdlSoapActionNamespace = "http://localhost:8080/",
                SoapServiceName = "HelloService"
            });
        }
    }

    class MainClass
    {
        public static void Main (string[] args)
        {
            string listenOn = "http://localhost:8080/";
            HelloHost host = new HelloHost ();
            host.Init ();
            host.Start (listenOn);
            Console.WriteLine ("AppHost created at {0} on {1}",
                DateTime.Now, listenOn);
            Console.ReadKey ();
        }
    }
}

Under Windows the generated WSDL is good, and if I try to create a client application and add a web reference to the soap service on localhost, I'm able to call Hello. If I run the same code under Linux using Mono, the generated WSDL does not contain the types defined inside the DTO namespace. If I try to add a web service reference on a client, I'm not able to exploit hello method.

At this link I've read that by default the same ServiceStack Console app binary runs on both Windows/.NET and Mono/Linux as-is. I've tried to launch the binary under windows; the service runs but the generated WSDL is incorrect (without types defined in DTO namespace). I use mono 2.10.8.1.

Does anyone have any suggestion?

I also have another question. If I use new version Servicestack last release (4.0.33) I'm not able to exploit soap endpoint.

At this link I've read that SOAP endpoints are not available when hosted on a HttpListener Host. Is it a feature introduced with new version 4.0? Isn't there the posbility to exploit soap endpoints with servicestack releases higher than 3.9?

Any help is appreciated.

Community
  • 1
  • 1

1 Answers1

1

Mono has a weak and partial WCF/SOAP support which will fail to generate WSDLs for many non-trivial Service definitions. This situation may improve in the near future now that Microsoft has Open Sourced .NET server libraries, but in the interim I recommend avoiding Mono if you want to use SOAP.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • Thank you very much for your response, mythz. My problem is that I have to develop a .net rest web service under Linux, and it have to be invoked via SOAP- Do you know if there is a valid alternative to Mono to do that? Thank you very much – Michele Ferrari Nov 24 '14 at 07:56