动态Web引用真的很动态吗?

时间:2022-03-26 05:55:12

Currently I'm looking at a problem with web references in vs2005 .net

目前我正在查看vs2005 .net中的Web引用问题

I have multiple web applications with multiple dynamic web references, now in the web.config I see the following code:

我有多个带有多个动态Web引用的Web应用程序,现在在web.config中我看到以下代码:

<applicationSettings>
    <MainWeb.Properties.Settings>
        <setting name="MainWeb_localhost_WebService" serializeAs="String">
            <value>http://localhost/test/WebService.asmx</value>
        </setting>
    </MainWeb.Properties.Settings>
</applicationSettings>

But because I'm using the same web services in different applications I want the place the web reference in the machine.config, but As you can see, the name of the web reference is diverted from the web application name, so the name is not dynamic at all.

但是因为我在不同的应用程序中使用相同的Web服务,我希望将web引用放在machine.config中,但正如您所看到的,Web引用的名称从Web应用程序名称转移,因此名称是根本没有动态。

And I don't want to put 10 different web references in the machine.config for the same web service.

我不想在machine.config中为同一个Web服务添加10个不同的Web引用。

So now is my question if someone know a good solution/workaround for this isseu.

所以现在是我的问题,如果有人知道这个isseu的好解决方案/解决方法。

1 个解决方案

#1


If you use wsdl.exe at the command line, you can pick the key with the /appsettingurlkey:<key> switch. The MainWeb_localhost_WebService is just what the IDE chooses as a default; that way, you can use the same key from multiple apps.

如果在命令行中使用wsdl.exe,则可以使用/ appsettingurlkey: 开关选择密钥。 MainWeb_localhost_WebService正是IDE选择的默认值;这样,您就可以使用来自多个应用的​​相同密钥。

In this scenario, it sounds like you might also want to create an assembly that purely represents the web-service (that all your web-applications reference); this will properly represent the fact that they represent the same essential service.

在这种情况下,听起来您可能还想创建一个纯粹代表Web服务的程序集(所有Web应用程序都引用);这将恰当地代表它们代表相同的基本服务的事实。

#1


If you use wsdl.exe at the command line, you can pick the key with the /appsettingurlkey:<key> switch. The MainWeb_localhost_WebService is just what the IDE chooses as a default; that way, you can use the same key from multiple apps.

如果在命令行中使用wsdl.exe,则可以使用/ appsettingurlkey: 开关选择密钥。 MainWeb_localhost_WebService正是IDE选择的默认值;这样,您就可以使用来自多个应用的​​相同密钥。

In this scenario, it sounds like you might also want to create an assembly that purely represents the web-service (that all your web-applications reference); this will properly represent the fact that they represent the same essential service.

在这种情况下,听起来您可能还想创建一个纯粹代表Web服务的程序集(所有Web应用程序都引用);这将恰当地代表它们代表相同的基本服务的事实。