douwen9343 2013-03-31 13:03
浏览 108

为什么c#不会因为在架构中使用xs:选项而在visual studio中使用add by service reference来创建来自wsdl的代码?

We created a soap server using php and few of the functions give a varying outcome in terms of the xml elements depending on the arguments passed through.

To explain further, a function takes in argument a and depending on the data received it can return either of the two different arrays(complextype) with distinct number of child elements.

e.g.

   if a =9 then outcome is array/struct ,,,, 
   a[delta]=20 ,,, 
   a[sigma]=yellow 

   if a =3  ,
   a[aTotallyDifferentBallgame]=Omaha ,,,
   a[t]=1 ,,,
   a[theNumberOfElementsCanVary]=yup

In order to explain this possible variance we utilized choice in the schema, thereby trying to intimate that the outcome can be any single element within choice be it simple or complextype.

Now theoretically it sounds logical and it works fine with php's soap client but WHEN we tried to use the add Service Reference feature of the visual studio in a form application ; the application failed to create code for it citing that the use of xs:choice is not allowed for some unfathomable reasons.

Now what I would really like to know is what changes do I need to make to my wsdl or soap server to make this work. We thought a work around was by fixing the outcome to only one possible scenario and utilizing a completely different function to determine the outcome of the other thereby abstaining from use of choice but frankly this seems too redundant and weird.

Is there anything I have missed? Please let me know any ideas you have. Thanks!

  • 写回答

1条回答 默认 最新

  • dongluo9156 2013-04-01 20:01
    关注

    The create service reference machinery tries to map the schema to C# classes, and there is no structure in a C# class corresponding to a choice in the schema - a class cannot have a value for either one property or another one but not for both.

    My suggestion would be to replace choice with sequences of optional elements, the corresponding C# class will have properties for each of the elements - and only one of them will have a value, the other will be null, because the PHP service returns a value for only one of them at a time.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?