ServiceStack命名空间更改不起作用

本文关键字:不起作用 命名空间 ServiceStack | 更新日期: 2023-09-27 18:21:41

小问题,当我在windows机器上运行ServiceStack API应用程序时,名称空间会正确显示为我所说的名称空间。但当我在mod_mono下的Linux机器上运行服务时。然后这些名称空间被其他东西覆盖。请参阅下面的代码:

DTO-

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

Windows生成的SOAP1 xml

<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命名空间设置为urn.com.例如:service:entity:20130308和urn.com.示例:service:20130308,而不是http://schemas.datacontract.org/2004/07/API_ESERVICES_NOTIFICATION.Model.任何帮助都将不胜感激。

ServiceStack命名空间更改不起作用

这看起来像Mono中的一个错误,它没有选择DataContract的命名空间,或者没有将urn:前缀视为有效的xml命名空间。我建议在Mono中提交一个bug。

您可以尝试的另一种选择是将名称空间留空,并在项目的Assembly.cs中指定一个assembly属性,例如:

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