如何在 ASP.Net 中处理沙箱和生产站点的 SalesForce WSDL 文件?

发布于 2024-08-04 19:47:10 字数 578 浏览 2 评论 0原文

我需要对用户进行身份验证并从 ASP.Net 应用程序获取有关他们的信息。 由于我有 2 个站点(沙箱、生产)和 2 个组织 ID - 我需要生成 2 个 SalesForce WSDL 文件。

我比较了这两个文件(每个文件大小约为 600kb),虽然它们 95% 相同,但到处都有足够的差异 - 足以让我需要同时使用它们。我将两者作为网络引用添加到我的解决方案中,这就是我的问题开始的地方。

显然,我不能在同一个文件中使用这两个引用,因为它们包含相同的类/函数。我必须在周末编写一个快速而肮脏的解决方案,所以我只创建了 2 个类 - 每个类使用不同的 Web 引用 - 但在其他方面是确切的功能,并且我根据用户即将到来的 URL 使用适当的类从。这很有效,但在我看来是一个糟糕的(读:快速而肮脏的)解决方案。

我的问题:有没有办法执行以下一项或多项操作:

  1. 即时更改网络引用?
  2. 在同一文件中使用两个 Web 引用,但将其放在不同的命名空间中?
  3. 为整个情况找到更好的解决方案?我发现了一个巨大的 XmlSerializer.dll(3mb!) - 可能是由于使用了两个巨大的 WSDL 文件。

感谢您抽出时间。

I need to authenticate users and get info about them from an ASP.Net application.
Since I have 2 sites (sandbox, production) and 2 org IDs - I needed to generate 2 SalesForce WSDL files.

I diffed the 2 files (each about 600kb in size) and while they are 95% the same, there are enough differences strewn all over the place - enough for me to need to use them both. I added both as web references to my solution, and here's where my problem starts.

Obviously, I cannot use both references in the same file, as they contain the same classes/functions. I had to write a quick-and-dirty solution over the weekend, so I just created 2 classes - each using a different web reference - but otherwise the exact functionality, and I use the appropriate one, based on the URL the user is coming from. This works well, but strikes me as a bad (read: quick-and-dirty) solution.

My question: is there any way to do one or more of the following:

  1. change the web reference on the fly?
  2. use both web references in the same file, but put one in a different namespace?
  3. find a better solution to the whole situation? I nd up with a huge XmlSerializer.dll (3mb!) - probably due to using both huge WSDL files.

Thanks for your time.

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

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

发布评论

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

评论(3

惜醉颜 2024-08-11 19:47:10

事实上,解决方案要简单得多,而且就藏在我眼皮子底下。
我只需要使用命名空间别名。这样,我可以在编译时包含这两个服务,并决定在运行时使用哪个:

using System.Web;
.
using ProductionAPI = MyCompany.SForce;
using SandboxAPI = MyCompany.SForce.Sandbox;
.
.
.
if(isSandbox)
  binding = new SandboxAPI.SForceService();
else
  binding = new ProductionAPI.SForceService();
.
.
.

Actually, the solution was much easier and was hiding under my nose.
I just needed to use Namespace aliases. That way, I can include both services in compile time, and decide which to use at runtime:

using System.Web;
.
using ProductionAPI = MyCompany.SForce;
using SandboxAPI = MyCompany.SForce.Sandbox;
.
.
.
if(isSandbox)
  binding = new SandboxAPI.SForceService();
else
  binding = new ProductionAPI.SForceService();
.
.
.
终止放荡 2024-08-11 19:47:10

我可能遗漏了一些东西,但我会尝试回答:

1 我假设你的意思是网址?是的,您可以在创建客户端对象时

var service = new Acmeco.AcmecoService();
service.Url = "oneUrlOrTheOther;   

2 什么意思?添加引用时,您必须为其指定一个名称,将其放入唯一的命名空间中。就像前面示例中的 Acmeco 一样。

3 这取决于你提到的 5% 差异是什么?我不太明白为什么两个不同主机上的同一个 Web 服务的 WSDL 会有所不同。我认为只有地址会不同,但方法和参数将保持不变。也许你可以详细说明一下?

It might be I am missing something but I will try to answer:

1 I assume you mean the URL? Yes you can when creating the client object

var service = new Acmeco.AcmecoService();
service.Url = "oneUrlOrTheOther;   

2 What do you mean? When you add the reference you have to give it a name which puts it in a unique namespace. Like Acmeco in the previous example.

3 That kind of depends on what in that 5% difference you mention? I don't quite understand how you end up with a difference in the WSDL for the same webservice on two different hosts. I would think only the addresses would be different but the methods and parameters would stay the same. Perhaps you can ellaborate?

窝囊感情。 2024-08-11 19:47:10

它们之间有什么区别?我怀疑这只是 SalesForce.com 的可定制性很强,因此您的沙箱和生产站点并不相同。如果您要利用沙盒站点进行测试的能力,则这两个需要相同。

What are the differences between them? I suspect it's just aht SalesForce.com is very customizable, so that your sandbox and production sites are not identical. The two need to be identical if you're going to take advantage of the ability to use the sandbox site for testing.

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