如何从一个项目访问WebService到另一个项目 [英] how to access webservice from one project to another project

查看:250
本文介绍了如何从一个项目访问WebService到另一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有名字叫做(dbservice层)的项目,该项目是在路径:D:\\ web服务\\ DBService。在这里我有一个连接到数据库,并返回一个类的对象的Web服务。

i have an project with name called(dbservice layer) which is in path: d:\webservice\DBService. here i have an webservice which connects to DB and returns an object of an class.

有一次,我在这里增加了一个参考我得到一个网址:HTTP://本地主机:2371 / Jobs.svc

once i added an reference here i get an url:http://localhost:2371/Jobs.svc

现在我还有一个项目名称(UILayer)whic是路径:E:\\学校\\ UILayer
我与这里的网址添加了服务引用作为的http://本地主机:2371 / Jobs.svc
但是我得到一个messgae说服力服务不能这是为什么发生的

now i have another project name (UILayer) whic is in path: E:\School\UILayer i added an service reference here with url as http://localhost:2371/Jobs.svc but i get an messgae telling service is unable why is that happening.

如果我的两个webserivce层和UI层都在同一个项目中。然后我能够使用webserive在UI层。并得到所需的输出

所以我想知道有没有什么办法,我们可以acesss从一个项目的webserive到另一个项目

so i wanted to know is there any way we can acesss the webserive from one project to another project

在此先感谢

王子

推荐答案

发布Web服务的实际位置,然后添加使用实际的URL不是一个由Visual Studio提供了一个参考。我认为正在发生的事情是每一个Visual Studio的实例使用不同的端口,所以你不能说本地主机:2371这两个项目,因为这是本地端口与原始项目正在运行的实例

Publish your web service to an actual location and then add a reference using the actual URL not the one served up by visual studio. What I think is happening is each Visual Studio instance is using a different port so you can't say localhost:2371 for both projects because that is the local port for the instance your running with your original project.

发布,然后访问它通过 HTTP://localhost/jobs.svc 。您应该能够通过IE浏览器的情况下直接运行Visual Studio如果你已经正确地发布它来访问它。

Publish it and then access it via http://localhost/jobs.svc. You should be able to access it via IE directly without running Visual Studio if you have published it correctly.

主要的一点是,你有错误的URL。

The main point is, you have the wrong URL.

这篇关于如何从一个项目访问WebService到另一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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