简体   繁体   English

如何在我的VB.net应用程序中使用c#web服务处理区分大小写的类和方法

[英]How do I handle case sensitive classes and methods from a c# web service in my VB.net app

I am working on a VB.Net application that needs to access a web service that I am nearly certain has a C# backend. 我正在开发一个VB.Net应用程序,需要访问我几乎肯定有C#后端的Web服务。 At bare minimum, the backend is providing classes to me that are differentiated only by case, and within a number of those classes, there are properties and methods that are only differentiated by case. 至少,后端为我提供了仅按大小写区分的类,并且在许多类中,有些属性和方法仅按大小写区分。

VB.Net is case insensitive, and it sees a number of these items as being ambiguous. VB.Net不区分大小写,并且它看到许多这些项目含糊不清。

I've thought of a few ways of dealing with this, but I would like suggestions before I go down a road that is likely difficult. 我想到了一些处理这个问题的方法,但在我走上可能很难的道路之前,我想提出一些建议。

Here are some ways I have considered going about it. 以下是我考虑过的一些方法。

  1. Modifying the generated code for the wsdl. 修改生成的wsdl代码。 This has presented problems in responding as the xml output would no longer conform to the webservice requirements. 由于xml输出不再符合Web服务要求,因此在响应时出现问题。 I think there might be some attributes I could use to override this, but I'm not sure what they are yet. 我认为可能有一些属性可以用来覆盖它,但我不确定它们是什么。 Even so, this web service gets frequent updates and I would hate to have to keep refixing the service every time I refreshed it. 即便如此,这个Web服务也会经常更新,我不想每次刷新时都要重新修改服务。

  2. Creating a csharp wrapper project where I expose the underlying classes with different names. 创建一个csharp包装器项目,我用不同的名称公开底层类。 Primarily through inheritance. 主要通过继承。 Although the big problem here has been the issue with properties and methods that are only differentiated by case as well. 虽然这里的一个大问题是属性和方法的问题,这些问题和方法也只是按案例区分。

I'm sure at some point I could get one or the other of these solutions working, but if anyone has any better suggestions that I'm not thinking of, I'd appreciate the help. 我确信在某些时候我可以让这些解决方案中的一个或另一个起作用,但如果有人有任何我没想到的更好的建议,我会很感激帮助。

Thank you 谢谢

If the web service was developed in-house, you'll want to review your company's development practices; 如果Web服务是内部开发的,那么您需要查看公司的开发实践; in particular, ensuring that all your public .NET APIs are CLS compliant . 特别是,确保所有公共.NET API都符合CLS

If the web service was not developed in-house, or you can't make changes to it (customers are already using it, etc.), then I would take the approach of either writing a C# wrapper library, or at least centralizing the calling code into a new (or existing) business-tier C# project. 如果Web服务不是内部开发的,或者您无法对其进行更改(客户已经在使用它等),那么我会采用编写C#包装器库的方法,或者至少集中管理将代码调用到新的(或现有的)业务层C#项目中。 There's a good chance you'll want to do this kind of abstraction anyway , instead of calling web methods directly from the application tier. 无论如何 ,你很可能想要做这种抽象,而不是直接从应用程序层调用web方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在vb.net中使用此查询-我无法理解从c#转换为vb.net - How do I use this query in vb.net - I cannot get my head around converting from c# to vb.net 对于在C#/ VB.NET中具有静态方法的类,如何进行垃圾收集? - How does Garbage collection happen for Classes having static methods in C#/VB.NET? 如何在C#中使用FileOpen(VB.NET)? - How do I use FileOpen (VB.NET) in C#? 如何将 VB.NET 中的扩展移植到 C#? - How do I port an extension in VB.NET to C#? 如何从vbScript调用.NET代码(C#/ vb.net)? - How do I call .NET code (C#/vb.net) from vbScript? 如何从遥远的类中调用未引用的方法? (允许使用C#和VB.NET) - How do I call an unreferenced method from a distant class? (C# and VB.NET allowed) 在VB.NET/C#中,如何将SQL表架构从数据库复制到另一个数据库? - In VB.NET/C#, how do I copy a SQL table schema from on DB to another? 如何将这个动态集合表达式从 VB.NET 转换为 C#? - How do I translate this dynamic collection expression from VB.NET into C#? 如何将高权限代码从C#转换为VB.Net以用于SharePoint? - How do I convert Elevated Privilege code from C# to VB.Net for use with SharePoint? 如何将此 LINQ 查询表达式从 C# 转换为 VB.NET? - How do I convert this LINQ query expression from C# to VB.NET?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM