WCF service using mod_mono

984 views Asked by At

I am trying to host a WCF service on CentOS using mono 2.10.8 and access it as a REST or SOAP server.

I started an application using mod-mono-server-4 in the folder containing my web.config:

<configuration>
    <system.serviceModel>
        <services>
            <service behaviorConfiguration="WebBehavior" name="Services.Hello">
                <clear/>
                <endpoint address="http://DOMAIN/service" behaviorConfiguration="HelloBehavior" binding="webHttpBinding" contract="Services.IHello" />
                <endpoint address="http://DOMAIN/web" binding="basicHttpBinding" bindingConfiguration="" contract="Services.IHello" />
            </service>
        </services>
        <behaviors>
            <endpointBehaviors>
                <behavior name="HelloBehavior">
                    <webHttp/>
                </behavior>
            </endpointBehaviors>
            <serviceBehaviors>
                <behavior name="WebBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

If I now call DOMAIN/web?wsdl or DOMAIN/service/hello (/hello is the UriTemplate of a WebGetAttribute of a method in IHello) I only get a 404:

Server Error in '/' Application
The resource cannot be found.

I also have a Service.svc file containting:

If I call DOMAIN/Service.svc/hello I get a SOAP-Error:

The request message has the target 'http://DOMAIN/Service.svc/hello' with action '' which is not reachable in this service contract

If I start a console application on the server executing the following:

WebServiceHost sh = new WebServiceHost(typeof(Hello), new Uri("http://localhost:681/service"));
sh.Open();

I can access the service on port 680 so mono should be able to run the service, but I need it to run with mod_mono (on port 80).

What do I need to configure differently?

In the end I'm trying to host a SyndicationFeed to deliver RSS/Atom-Feeds.

1

There are 1 answers

0
Christoph Fink On BEST ANSWER

I found a workaround to get it running ATM:
Create a normal *.asmx-WebService and create a method like:

[WebMethod]
[SoapDocumentMethod(ParameterStyle=SoapParameterStyle.Bare)]
public XmlDocument Feed()
{
    SyndicationFeed feed = new SyndicationFeed();
    //Fill the feed...
    Atom10FeedFormatter atom = new Atom10FeedFormatter(feed);

    StringBuilder result = new StringBuilder();
    XmlWriter writer = XmlWriter.Create(result);
    atom.WriteTo(writer);
    writer.Flush();

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(result.ToString());

    return doc;
}

Then you can access the feed at DOMAIN/Service.asmx/Feed.