开发者

Generating Proxy with svcutil.exe for different (non-default) collection type

I am trying to generate proxy for a wcf service through command line. As required, I am using *svcutil.exe.

There are bunch of services which I need to create proxies for. A sample command is shown below. Everything goes humming about generation of proxies.

For one of the proxy I need to have Collection type as List instead of Array which is default. However, with explicitly mentioned like below, I am not able to get the collectiontype correct. The resulting proxy still has Array type for collections. There are no errors while execution of these commands. Not sure what's going around.

svcutil.exe  http://localhost/DealService.svc /noLogo               开发者_如何学C
/out:D:/Proxies/DealServiceReference.cs /n:*,MyApp.WinUI.DealServiceReference 
/ct:System.Collections.Generic.List`1

Does anyone know, why would I be getting default collectiontype despite of explicit mention? Does anyone know how to get it right?

(Subquestion - All the examples I have seen for defining collectiontype as list, the mysterious `1 appears at the end of System.Collections.Generic.List but I could not understand the need of it, neither I could get a valid explanation somewhere. So if someone could throw light on that, it would be great.)


You should be getting the List of T type in the DataMember classes with that switch. For troubleshooting, try creating the proxy by adding a Service Reference for that service and configuring the collection settings as shown here. If the service reference is created with the expected List of T then the WSDL is good. If not, it may be that SvcUtil can't allow serializing/deserializing the collections as List of T.


Caution:-

svcutil.exe will overwrite existing files on a disk if the names supplied as parameters are identical. This can include code files, configuration or metadata files. To avoid this when generating code and configuration files, use the /mergeConfig switch. In addition, the /r and /ct switches for referencing types are for generating data contracts. These switches do not work when using XmlSerializer.

Reference: https://msdn.microsoft.com/en-us/library/aa347733(v=vs.110).aspx

This may be your situation, check the Serializer used...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜