2012-01-26 54 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訪問飼料。