WCF代理中的系统命名空间冲突

时间:2013-12-15 03:05:36

标签: c# .net wcf proxy

我正在尝试为我创建的WCf服务生成代理。服务中的一个操作具有返回类型WebHeaderCollection,它恰好是System.Net Assembly的一部分。我正在使用以下命令生成代理。

>svcutil.exe /language:cs /out:Proxies/AuthManagerProxy.cs /ct:System.Collections.Generic.List`1 /config:Proxies/out.config https://localhost/OpenAPISecurityManager/AuthManager.svc /serializer:DataContractSerializer

我面临的问题是Proxy包含根命名空间的定义,这会导致客户端发生冲突。我可以手动删除定义,一切正常,但我不知道这种奇怪行为的原因是什么。如果我使用visual studio添加服务引用,那么我不会遇到问题。

向下滚动下面的代码片段(第112行,我想看看为命名空间生成的代码)

    //------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.1008
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace OpenAPISecurityManager.DataContracts
{
    using System.Runtime.Serialization;


    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="EndpointAccessConfig", Namespace="http://schemas.datacontract.org/2004/07/OpenAPISecurityManager.DataContracts")]
    public partial class EndpointAccessConfig : object, System.Runtime.Serialization.IExtensibleDataObject
    {

        private System.Runtime.Serialization.ExtensionDataObject extensionDataField;

        private string ApplicationIDField;

        private bool disableSignatureField;

        private string kevalueField;

        private string svcmethodField;

        private string svcurlField;

        public System.Runtime.Serialization.ExtensionDataObject ExtensionData
        {
            get
            {
                return this.extensionDataField;
            }
            set
            {
                this.extensionDataField = value;
            }
        }

        [System.Runtime.Serialization.DataMemberAttribute()]
        public string ApplicationID
        {
            get
            {
                return this.ApplicationIDField;
            }
            set
            {
                this.ApplicationIDField = value;
            }
        }

        [System.Runtime.Serialization.DataMemberAttribute()]

        public bool disableSignature
        {
            get
            {
                return this.disableSignatureField;
            }
            set
            {
                this.disableSignatureField = value;
            }
        }

        [System.Runtime.Serialization.DataMemberAttribute()]
        public string kevalue
        {
            get
            {
                return this.kevalueField;
            }
            set
            {
                this.kevalueField = value;
            }
        }

        [System.Runtime.Serialization.DataMemberAttribute()]
        public string svcmethod
        {
            get
            {
                return this.svcmethodField;
            }
            set
            {
                this.svcmethodField = value;
            }
        }

        [System.Runtime.Serialization.DataMemberAttribute()]
        public string svcurl
        {
            get
            {
                return this.svcurlField;
            }
            set
            {
                this.svcurlField = value;
            }
        }
    }
}
   namespace System.Net
{
    using System;


    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.SerializableAttribute()]
    public partial class WebHeaderCollection : System.Collections.Specialized.NameValueCollection
    {

        public WebHeaderCollection(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : 
                base(info, context)
        {
        }
    }
}
namespace System.Collections.Specialized
{
    using System;
    using System.Runtime.Serialization;***


    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.SerializableAttribute()]
    [System.Runtime.Serialization.KnownTypeAttribute(typeof(System.Net.WebHeaderCollection))]
    public partial class NameValueCollection : System.Collections.Specialized.NameObjectCollectionBase
    {

        public NameValueCollection(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : 
                base(info, context)
        {
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.SerializableAttribute()]
    [System.Runtime.Serialization.KnownTypeAttribute(typeof(System.Collections.Specialized.NameValueCollection))]
    [System.Runtime.Serialization.KnownTypeAttribute(typeof(System.Net.WebHeaderCollection))]
    public partial class NameObjectCollectionBase : object, System.Runtime.Serialization.ISerializable
    {

        private System.Runtime.Serialization.SerializationInfo info;

        public NameObjectCollectionBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            this.info = info;
        }

        public System.Runtime.Serialization.SerializationInfo SerializationInfo
        {
            get
            {
                return this.info;
            }
            set
            {
                this.info = value;
            }
        }

        public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            if ((this.SerializationInfo == null))
            {
                return;
            }
            System.Runtime.Serialization.SerializationInfoEnumerator enumerator = this.SerializationInfo.GetEnumerator();
            for (
            ; enumerator.MoveNext(); 
            )
            {
                System.Runtime.Serialization.SerializationEntry entry = enumerator.Current;
                info.AddValue(entry.Name, entry.Value);
            }
        }
    }
}


[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://masked/servicecontracts", ConfigurationName="IAuthManager")]
public interface IAuthManager
{

    [System.ServiceModel.OperationContractAttribute(Action="http://masked/servicecontracts/IAuthManager/CreateSignedHeader", ReplyAction="http://masked/servicecontracts/IAuthManager/CreateSignedHeaderResponse")]
    System.Net.WebHeaderCollection CreateSignedHeader(OpenAPISecurityManager.DataContracts.EndpointAccessConfig endPoint);

    [System.ServiceModel.OperationContractAttribute(Action="http://masked/servicecontracts/IAuthManager/CreateSignedBody", ReplyAction="http://masked/servicecontracts/IAuthManager/CreateSignedBodyResponse")]
    string CreateSignedBody(string body, OpenAPISecurityManager.DataContracts.EndpointAccessConfig endPoint);
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface IAuthManagerChannel : IAuthManager, System.ServiceModel.IClientChannel
{
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class AuthManagerClient : System.ServiceModel.ClientBase<IAuthManager>, IAuthManager
{

    public AuthManagerClient()
    {
    }

    public AuthManagerClient(string endpointConfigurationName) : 
            base(endpointConfigurationName)
    {
    }

    public AuthManagerClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public AuthManagerClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public AuthManagerClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress)
    {
    }

    public System.Net.WebHeaderCollection CreateSignedHeader(OpenAPISecurityManager.DataContracts.EndpointAccessConfig endPoint)
    {
        return base.Channel.CreateSignedHeader(endPoint);
    }

    public string CreateSignedBody(string body, OpenAPISecurityManager.DataContracts.EndpointAccessConfig endPoint)
    {
        return base.Channel.CreateSignedBody(body, endPoint);
    }
}

0 个答案:

没有答案