2012-12-21 23 views
1

在我的项目中,我包含了Webservice文件,当我试图运行时,我在Chrome浏览器中出现此错误。当我的项目中包含webservice文件时出错

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.


Compiler Error Message: CS0029: Cannot implicitly convert type 'Unified.WebService.GetOrder [c:\Users\Venkatesh\AppData\Local\Temp\Temporary ASP.NET Files\root\417f2571\29df25a\assembly\dl3\1f05470e\0779ccf4_47dfcd01_0\WasteManagement.DLL]' to 'Unified.WebService.GetOrder [c:\Users\Venkatesh\Desktop\Venkateshwar\Company Related\Waste Management - Copy\WasteManagement\WasteManagement\App_Code\GetOrder.cs(8)]'

源错误:

Line 43:   public GetOrder retrieveOrder(string orderNumber) 
Line 44:   { 
         //Calling Web service method in my class 
Line 45:/*ERROR*/  return connection.getOrder(orderNumber); 
Line 46:   } 
Line 47: 

当我点击Compiler Warning Messages,它显示在所有这一切都是通过Web服务连接错误。

如果有必要,我也会分享代码。 (因为我是asp.net的新手,我无法理解要共享哪部分代码,所以请根据需要提及代码的哪个部分。)

回答

2

您的Web服务应该是您的解决方案中的独立项目。之后,您应该为其添加Web引用,之后您可以安全地调用它。

Web服务不是您不能添加和使用的基本类 - 它是不同的东西,所以您不能简单地将它添加到您的App_Code文件夹中以使其工作。

从MSDN:

Web service discovery is the process by which a client locates a Web service and obtains its service description. The process of Web service discovery in Visual Studio involves interrogating a Web site following a predetermined algorithm. The goal of the process is to locate the service description, which is an XML document that uses the Web Services Description Language (WSDL).

The service description describes what services are available and how to interact with those services. Without a service description, it is impossible to programmatically interact with a Web service.

编辑:

是的,你可以删除[WebMethod]属性等,从Web服务声明,临时使用它像类,但在那之后,你仍然有为其添加Web引用以便像使用Web Service一样使用它。

+0

我还没有完全创建Webservice文件..因此,直到那时我决定将它保存在我的项目中(正如我的其他同事选择的那样)。 –

+0

@Mr_Green在使用Web服务之前,您仍然需要添加参考。这是唯一的方法。 – VMAtm

+0

嗯好吧我会采纳你的建议..我以前就像你现在解释的一样......但是当我的朋友们建议我这样做:)。好吧然后我会让你知道.. –

相关问题