Web服务参考恶作剧

发布于 2024-10-20 07:15:11 字数 563 浏览 6 评论 0原文

我有一个 .net web 服务(直通 WS),它传递到另一个(底层 WS),并传递特定的自定义对象。 两个 WS 都包含具有特定自定义对象类的程序集,但是当我将对底层 WS 的服务引用添加到直通 WS 时,.net 在直通 WS 命名空间中生成自己的此类类型。 这意味着我必须在不同的命名空间中使用另一个对象,而不是它真正的对象——真正复制“真实”的类/对象。 也许我没有很好地解释这一点。

我可以猜测手动进入 .net 生成的服务类并将生成的对象替换为“正确”的对象,但每次更新底层服务时我都必须这样做。至少可以说有点痛苦。 这显然也会影响返回类型以及调用 webmethods 的参数..dagnamit!

有办法解决这个问题吗?理想情况下,我希望两个 WS 使用相同的对象。 或者我是否必须将构造函数添加到生成的对象中,该对象采用底层对象并分配所有属性? - 我希望不是......

我意识到 WS 必须是独立于平台的,使用的类型不仅可以从 .net 或其他地方访问。 确保您只使用这些基本类型,而不是将它们全部包装在自定义对象中,而是将所有这些“属性”作为单独的参数传递,是不是这样? 非常感谢任何帮助,

谢谢

nat

I have a .net webservice (passthrough WS) that passes through to another one (underlying WS), passing a particular custom object.
both WS's include the assembly with the particular custom object class in, but when i add the service reference to the underlying WS to the passthrough WS , .net generates its own type of this class , in the passthough WS namespace.
this then means that I have to use this other object in a different namespace instead of the one it really is- really duplicating the 'real' class/object.
maybe i am not explaning this very well.

i could i guess go in by hand to the .net generated service class and replace the generated object with the 'correct' one, but i would have to do that each time the underlying service was updated. a bit of a pain to say the least.
this clearly also affects the return types as well as the arguments the webmethods are called with.. dagnamit!

is there a way around this? ideally i would like both WS's to use the same objects.
or am i going to have to add constructors to the generated objects that take the underlying ones and just assign all the properties like that? - i hope not....

i realise that WS's have to be platform independent, using types that should be accessible from not just .net or whatever..
so is the idea to make sure you are using just these base types and instead of wrapping them all up in a custom object, to pass in all these 'properties' as separate arguments?
any help much appreciated

thanks

nat

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2024-10-27 07:15:11

如果您使用旧版(又名老式)ASP.NET Web 服务,则基本上有 2 个选项:

  1. 将它们转换为 WCF 服务并使用服务引用(而不是简单的引用) 来消耗它们。 WCF 服务支持类的重用

  2. 如果您想继续使用旧的 Web 服务技术,您将不得不通过 自定义代理类的生成方式

If you are using legacy (aka old school) ASP.NET webservices, you have basically 2 options:

  1. Convert them to WCF services and use Service References (instead of simple References) to consume them. WCF Services support reuse of classes.

  2. If you want to stay with the legacy web service technology, you will have to go the hard way by customizing the way the proxy class is generated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文