2012-01-26 59 views
0

我试图在CentOS上使用单声道2.10.8托管WCF服务,并将其作为REST或SOAP服务器进行访问。使用mod_mono的WCF服务

<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> 

如果我现在请DOMAIN/web?wsdlDOMAIN/service/hello/hello是一种方法的一个WebGetAttribute的UriTemplate:

我使用含有我的web.config MOD-单服务器4中的文件夹中启动的应用程序在IHello)我只得到了404:

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

我也有一个Service.svc文件containting:

如果我打电话DOMAIN/Service.svc/hello我得到一个SOAP错误:

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

如果我在服务器上启动控制台应用程序执行以下操作:

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

我可以在端口680来访问服务所以mono应该可以运行该服务,但我需要它使用mod_mono(在端口80上)运行。

我需要什么配置不同?

最后,我试图托管一个SyndicationFeed来提供RSS/Atom-Feeds。

回答

0

我发现了一个变通方法来让它运行ATM:
创建一个正常的*的.asmx Web网页,并创建一个类似方法:

[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; 
} 

然后你就可以在DOMAIN/Service.asmx/Feed访问饲料。