I want to add a web service to my ASP.NET MVC 5
project.
我想在我的ASP.NET MVC 5项目中添加一个Web服务。
I do that by right click on the project in solution explorer > add
> service reference
.
我通过右键单击解决方案资源管理器中的项目>添加>服务引用来实现这一点。
Then I add a web service url like this and it creates a new file in Service References
folder called ServiceReference1
然后我添加一个这样的Web服务URL,它在Service References文件夹中创建一个名为ServiceReference1的新文件
Then I'm able to call web service methods in C# by using ServiceReference1
namespace and VS intellisense works.
然后我可以通过使用ServiceReference1命名空间和VS intellisense来调用C#中的Web服务方法。
The problem is that when I add this web service url, it adds a new namespace (ServiceReference2
) to that folder, but I can't call the new namespace and it says ServiceReference2 namespace could not be found
.
问题是,当我添加此Web服务URL时,它会向该文件夹添加一个新的命名空间(ServiceReference2),但我无法调用新的命名空间,并且无法找到ServiceReference2命名空间。
Is it me doing something wrong or the web service has a problem?
是我做错了什么还是网络服务有问题?
1 个解决方案
#1
12
After you open your service window, click on the advanced button like below.
打开服务窗口后,单击高级按钮,如下所示。
In general, I agree it's best not to use the older versions of web-services like I'm showing here, but in real life people have deadlines and such.
总的来说,我同意最好不要像我在这里展示的那样使用旧版本的网络服务,但在现实生活中,人们有截止日期等等。
Saying that though, there is no huge drawback to using this tech, as long as performance isn't an issue.
尽管如此,只要性能不是问题,使用这种技术并没有什么大的缺点。
Then, click 'add Web Reference' like the picture below.
然后,单击“添加Web引用”,如下图所示。
Then enter URL and click on the little arrow button. Name your reference and click 'Add Reference'. see pic below
然后输入URL并单击小箭头按钮。命名您的参考,然后单击“添加参考”。见下图
#1
12
After you open your service window, click on the advanced button like below.
打开服务窗口后,单击高级按钮,如下所示。
In general, I agree it's best not to use the older versions of web-services like I'm showing here, but in real life people have deadlines and such.
总的来说,我同意最好不要像我在这里展示的那样使用旧版本的网络服务,但在现实生活中,人们有截止日期等等。
Saying that though, there is no huge drawback to using this tech, as long as performance isn't an issue.
尽管如此,只要性能不是问题,使用这种技术并没有什么大的缺点。
Then, click 'add Web Reference' like the picture below.
然后,单击“添加Web引用”,如下图所示。
Then enter URL and click on the little arrow button. Name your reference and click 'Add Reference'. see pic below
然后输入URL并单击小箭头按钮。命名您的参考,然后单击“添加参考”。见下图