当前位置: 代码迷 >> Web Service >> 请问:WCF里怎么修改默认命名空间的前缀等
  详细解决方案

请问:WCF里怎么修改默认命名空间的前缀等

热度:948   发布时间:2013-11-12 12:10:37.0
请教:WCF里如何修改默认命名空间的前缀等
用WCF做出来的效果是:
目标效果是:
问题如下:
1. 怎样将第一行的s:Envelope修改为SOAP-ENV:Envelope;
2. 怎样添加命名空间,现在只有2个,我想增加至目标的5个;
3. 怎样在Inform前增加"cwmp:";
4. 怎样去掉Inform后面的xmlns="urn:dslforum-org:cwmp-1-0"
问题很多,只是看了网上几个例子自己写的,希望各位大大不吝赐教,小女子感激不尽。。。

附件:
一个解决方案里包含两个项目:server和client,code如下:
server端:

using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Xml.Serialization;
using System.Runtime.Serialization;

namespace ACS
{
    [DataContract]
    public class DeviceIdStruct
    {
        [DataMember]
        public string Manufacturer;
        [DataMember]
        public string OUI;
        [DataMember]
        public string ProductClass;
        [DataMember]
        public string SerialNumber;
    }
    public class EventList
    {
        public string EventCode;
        public string CommandKey;
    }
    public class ParameterValueList
    {
        public string Name;
        public string Value;
    }

    [ServiceContract]
    public interface ICwmpBinding
    {
        [OperationContract(IsOneWay = false)]
        uint Inform(DeviceIdStruct DeviceId, EventList Event, uint MaxEnvelopesI, System.DateTime CurrentTime, uint RetryCount, ParameterValueList ParameterList);
    }

    public class cwmpServiceType : ICwmpBinding
    {
        public uint Inform(DeviceIdStruct DeviceId, EventList Event, uint MaxEnvelopesI, System.DateTime CurrentTime, uint RetryCount, ParameterValueList ParameterList)
        {
            Console.WriteLine("Time Now is:{0}!", CurrentTime);
            return 1;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            // 服务器基址  
            Uri baseAddress = new Uri("http://192.168.20.110:8080/openacs");
            // 声明服务器主机  
            using (ServiceHost host = new ServiceHost(typeof(cwmpServiceType), baseAddress))
            {
                // 添加绑定和终结点  
                WSHttpBinding binding = new WSHttpBinding();
                binding.Security.Mode = SecurityMode.None;
                host.AddServiceEndpoint(typeof(ICwmpBinding), binding, "/acs");
                // 添加服务描述  
                host.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true });
                try
                {
                    // 打开服务  
                    host.Open();
                    Console.WriteLine("服务已启动。");
                }
  相关解决方案