c# - ServiceStack 命名空间更改不起作用

标签 c# web-services mono namespaces servicestack

小问题,当我在我的 Windows 机器上运行我的 ServiceStack API 应用程序时, namespace 正确显示,正如我所说的那样。但是当我在关闭 mod_mono 的 Linux 机器上运行该服务时。然后这些 namespace 被其他东西覆盖。请在下面查看我的代码:

数据传输

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

Windows 生成的 SOAP11 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 模式单声道

<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.example:service:entity:20130308 和 urn:com.example:service:20130308,而不是 http://schemas.datacontract.org/2004/07/API_ESERVICES_NOTIFICATION.Model .任何帮助将不胜感激。

最佳答案

这看起来像是 Mono 中的一个错误,它没有选择 DataContract 的命名空间,或者没有考虑将 urn: 作为有效的 xml 命名空间前缀。我推荐filing a bug in Mono .

您可以尝试的替代方法是将命名空间留空并在项目的 Assembly.cs 中指定一个程序集属性,例如:

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

关于c# - ServiceStack 命名空间更改不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17542802/

相关文章:

c# - WPF MVVM-在 View 模型中访问 View 控件的属性

c# - 计划在nunit中自动执行测试

java - 表示 REST 中的断裂时间范围

java - Glassfish 2.11 未在管理控制台中显示 Web 服务

c# - 将字节数组从 Unity C# 传递到 C++ 库方法

c# - 在wpf C#中禁用自定义父级时启用子控件

c# - 在C#中记录登录、注销、系统锁定/解锁事件

mysql - 来自数据库的 RESTful Web 服务错误 500

php - MySql数据库版本控制系统

ubuntu - 在 Ubuntu 14.04 LTS 上安装 Mono 3.4.0 和 MonoDevelop 4.2.2