2013-07-09 42 views
4

小問題當我在Windows機器上運行我的ServiceStack API應用程序時,命名空間顯示正確,因爲我聲明它們是。但是當我在Linux機器上運行服務關閉mod_mono。然後這些命名空間被別的東西覆蓋。請參閱我下面的代碼:生成SOAP11 XMLServiceStack命名空間更改無法正常工作

DTO

namespace API_ESERVICES_NOTIFICATION 
{ 
[DataContract(Namespace = "urn:com.example:service:20130308")] 
public class GetAccountNotification 
{ 
    [DataMember] 
    public GetAccountResponseTO getAccountResponse { 
     get; 
     set; 
    } 
} 
} 

的Windows

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <GetAccountNotification xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:com.example:service:20130308"> 
      <getAccountResponse xmlns:d2p1="urn:com.example:service:entity:20130308"> 

的Linux是mod_mono

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <GetAccountNotification xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API_ESERVICES_NOTIFICATION"> 
      <getAccountResponse xmlns:d2p1="http://schemas.datacontract.org/2004/07/API_ESERVICES_NOTIFICATION.Model"> 

現在我該怎樣讓Linux的命名空間是甕: com.example:service:entity:20130308 and urn:com.example:service:20130308,and not http://schemas.datacontract.org/2004/07/API_ESERVICES_NOTIFICATION.Model。任何幫助將不勝感激。

回答

3

這看起來像是Mono中的一個錯誤,它沒有拾取DataContract的名稱空間,或者沒有考慮urn:前綴有效的xml名稱空間。我建議filing a bug in Mono

你可以嘗試另一種離開的命名空間爲空,並指定在項目的Assembly.cs代替,例如組裝屬性:

[assembly: ContractNamespace("urn:com.example:service:20130308", 
    ClrNamespace = "API_ESERVICES_NOTIFICATION")] 
+0

我想這一點,遺憾的是它不工作,我將提交一個錯誤,但不幸的是,我們永遠不會在Linux上獲得新的單聲道版本。僅支持2.10.8,這已經落後於當前版本。 serviceStack是否支持System.xml.serialization?作爲備選? –

+0

http://mono-project.com/DistroPackages/Ubuntu –

+2

不,ServiceStack沒有自己的XML Serializer,它只是使用DataContractSerializer。你可以通過在'IAppHost.ContentTypeFilters'中註冊自己來交換它,但是你必須找到一個在Mono中運行良好的程序。 – mythz