WebService动态URL [英] WebService Dynamic URL

查看:349
本文介绍了WebService动态URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我从 Web.config 键给出了我的Web服务路径,但问题是我更新 WebService 路径被更改。



那么,我该如何防止这种情况?

这是我迄今为止在参考中给出的。 cs

Hi I have given my web service path from Web.config key, but the problem is when I update the WebService the path gets changed.

So, how can I prevent this scenario?
This is what I have given so far in Reference.cs.

public ABC()
{
    this.Url = System.Configuration.ConfigurationManager.AppSettings["ABC"];
    if ((this.IsLocalFileSystemWebService(this.Url) == true))
    {
        this.UseDefaultCredentials = true;
        this.useDefaultCredentialsSetExplicitly = false;
    }
    else
    {
        this.useDefaultCredentialsSetExplicitly = true;
    }
}





我从这个链接得到了这个如何使您的Web引用代理URL动态化 [ ^ ]



但每当我更新 WebService 时,它都会变为。



I got this from this link How to make your Web Reference proxy URL dynamic[^]

But whenever I update the WebService it gets changed to.

public ABC() 
{
    this.Url = global::Drd.Properties.Settings.Default.CoreBusiness_UbossProvisioning_ABC;
    if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
        this.UseDefaultCredentials = true;
        this.useDefaultCredentialsSetExplicitly = false;
    }
    else {
        this.useDefaultCredentialsSetExplicitly = true;
    }
}

推荐答案

如果您在本地服务器中托管服务,则每次都会更改服务引用。

如果您希望它是静态的,您需要在服务器上部署服务或指定特定的端口号。通过这种方式,您可以限制它动态更改。



希望这会对您有所帮助。让我知道,如果这不起作用。



- SG
Service references changes every time if you are hosting the service in the local server.
If you want that to be static you need to deploy your service on the server or specify specific Port number to that. In that way you can restrict that to change dynamically.

Hope this will help you. Let me know if that doesnt work.

- SG


比我认为你只需添加代理服务。你不必从webconfig中读取它。只需添加服务引用即可自动更新Web配置。



这是我从您提供的参考资料中理解的。



而不是使用webconfig只需使用你的服务对象并使用它。
than wht i think is u just need to add the proxy of the service. You dont have to read that from the webconfig. Just add the service reference and that will automatically update the web config.

This is wht i understand from the reference you have given.

Instead of using from the webconfig just use the object your service and use that.


Refrence.cs 是生成的文件,因此随时更改它是不好的做法(请参阅文件标题)



刷新Web引用将根据其属性重新生成此文件。你得到了你看到的代码,因为你的 URL行为是动态的。



你看到的代码意味着你的代码 web.config 文件中有一部分内容如下:



Refrence.cs is a generated file so changing it at any time is bad practice (see file header)

Refreshing web reference is regenerating this file according its properties. You got the code you see because your URL Behaviour is dynamic.

The code you see means that in your web.config file there is a part reads somesing like this:

<applicationsettings>
   <drd.properties.settings>
        <setting name="CoreBusiness_UbossProvisioning_ABC" serializeas="String">
            <value>your service url goes here</value>
        </setting>
    </drd.properties.settings>
</applicationsettings>





如果你想要要更改你应该在web.config文件中执行此操作的URL ...



问候

Peter



If you want to change the url you should do it in the web.config file...

Regards
Peter

这篇关于WebService动态URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆