首页 新闻 会员 周边

引用WCF 生成怪异代码问题

0
[已解决问题] 解决于 2013-05-20 21:47

Hello everyone,

我在服务端定义了如下方法:

View Code
1 /// <summary>
2         /// 修改一条DriverInvoice记录状态为开票
3         /// </summary>
4         /// <param name="pk"></param>
5         /// <param name="usergid"></param>
6         /// <returns></returns>
7         [OperationContract]
8         [FaultContract(typeof(UserFriendlyError))]
9         bool MakeOutInvoice(Dictionary<string, string> pk, string usergid);

客户端生成了如下代码

View Code
 1 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")]
 2     [System.SerializableAttribute()]
 3     [System.Diagnostics.DebuggerStepThroughAttribute()]
 4     [System.ComponentModel.DesignerCategoryAttribute("code")]
 5     [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays")]
 6     public partial class ArrayOfKeyValueOfstringstringKeyValueOfstringstring : object, System.ComponentModel.INotifyPropertyChanged {
 7         
 8         private string keyField;
 9         
10         private string valueField;
11         
12         /// <remarks/>
13         [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=0)]
14         public string Key {
15             get {
16                 return this.keyField;
17             }
18             set {
19                 this.keyField = value;
20                 this.RaisePropertyChanged("Key");
21             }
22         }
23         
24         /// <remarks/>
25         [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=1)]
26         public string Value {
27             get {
28                 return this.valueField;
29             }
30             set {
31                 this.valueField = value;
32                 this.RaisePropertyChanged("Value");
33             }
34         }
35         
36         public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
37         
38         protected void RaisePropertyChanged(string propertyName) {
39             System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
40             if ((propertyChanged != null)) {
41                 propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
42             }
43         }
44     }
View Code
1 public bool MakeOutInvoice(LPM.Web.LPTMSFinancialServiceRef.ArrayOfKeyValueOfstringstringKeyValueOfstringstring[] pk, string usergid) {
2             LPM.Web.LPTMSFinancialServiceRef.MakeOutInvoiceRequest inValue = new LPM.Web.LPTMSFinancialServiceRef.MakeOutInvoiceRequest();
3             inValue.pk = pk;
4             inValue.usergid = usergid;
5             LPM.Web.LPTMSFinancialServiceRef.MakeOutInvoiceResponse retVal = ((LPM.Web.LPTMSFinancialServiceRef.ILPTMSFinancialService)(this)).MakeOutInvoice(inValue);
6             return retVal.MakeOutInvoiceResult;
7         }

按道理生成一个Dictionary<string,string>的参数就行了 为什么会搞得这么复杂呢?

谁遇到过,请问该怎么解决?

不好意思没有园豆了

wcf
weblogical的主页 weblogical | 初学一级 | 园豆:6
提问于:2013-04-15 10:07
< >
分享
最佳答案
0

WCF,客户端在添加引用的时候,对于泛型默认是生成数组的,你这个就是,可以通过在引用的时候,在“高级”设置里改成生成泛型应该就OK了,你可以试试

奖励园豆:5
Stone zhang | 菜鸟二级 |园豆:222 | 2013-04-28 16:20

不行,

Dictionary<string, string> pk 怎么设置都是数组
weblogical | 园豆:6 (初学一级) | 2013-05-10 11:23
其他回答(1)
0

这个是在Vs 2012下出现的问题,目前似乎还有好的解决办法。

我采用了迂回路线:在web 端代理类中(非系统生成的) 把Dictonary<string,string> 序列化成Json

服务端再反序列化,这样改动最小

weblogical | 园豆:6 (初学一级) | 2013-04-18 17:27

这个问题难道就我一个人遇到过?

支持(0) 反对(0) weblogical | 园豆:6 (初学一级) | 2013-04-18 17:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册