从类库中使用Web服务

iKo*_*ode 3 c# wcf web-services visual-studio-2010

我已经成功创建了一个ASP.net网站来调用Soap Web服务.

现在我需要把它变成一个类库,我可以通过Classic从Classic调用它.

这篇关于从类库中使用asp.net app中的Web服务的帖子说我需要添加Web服务,使用"添加服务引用"而不是"添加Web引用"来添加对Web服务的引用.

当我尝试这样做时,我收到一个错误:

元数据包含无法解析的引用:' http : //theURL.com : 8008/asmx/publicServiceAddress.asmx?wsdl '.
下载" http://theURL.com:8008/asmx/publicServiceAddress.asmx?wsdl "时出错.
无法连接到远程服务器连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应77.95.80.35:8008元数据包含无法解析的引用: ' http://theURL.com/asmx/publicServiceAddress.asmx '.元数据包含无法解析的引用:' http://theURL.com/asmx/publicServiceAddress.asmx '.
如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用.

...但是当我点击高级然后再添加"添加Web引用"时我可以添加它.

问题:

1)是否有必要使用"添加服务引用"而不是"添加Web引用"?
2)为什么,有什么区别?
3)这个错误的潜在原因是什么,我怎么能弄清楚这一点,例如我不知道为什么它要移植8080来寻找WSDL http://theURL.com:8008/asmx/reguspublic. asmx?wsdl什么时候应该去http://theURL.com/asmx/reguspublic.asmx?wsdl

Ase*_*tam 5

服务引用适用于Windows Communication Foundation(WCF)服务和WCF数据服务,其中使用"传统"或asmx Web服务时使用Web引用.

因此,对于'asmx',您应该使用Web引用而不是服务引用.

http://alexduggleby.com/2008/08/24/add-web-reference-instead-of-service-reference-in-visual-studio-2008/

关于错误:
WCF服务公开元数据,使其能够与不同类型的端点和数据进行交互..NET 2.0 asmx webservices只有一个端点@SOAP.因此'asmx'Web服务不会公开由于错误发生而导致的任何元数据.