找不到命名空间名称soapcontext

时间:2014-02-27 00:30:31

标签: c# web-services soap visual-c#-express-2010

我正在构建一个表单应用程序,该应用程序调用第三方Web服务,但不断收到"namespace name soapcontext could not be found"错误。

我已经添加了一个指向Web服务的wsdl的Web引用。这就是我所拥有的:

private void btnGetInfo_Click(object sender, EventArgs e)
{
     QTWebSvcsService svc = new qtref.QTWebSvcsService();
     // The getVehicleInformation method accepts an AssetIdentifier and returns a
     // VehicleInfo object.  Instantiate them both.
     qtref.AssetIdentifier ai = new qtref.AssetIdentifier();
     qtref.VehicleInfo vi = new qtref.VehicleInfo();

     // Replace these strings with valid company name, user name and password
     string sUsername = "[usernasme]";
     string sCompanyname = "[company]";
     string sIdentity = sUsername + "@" + sCompanyname;
     string sPassword = "[password]";

     //This is where it fails
     SoapContext requestContext = RequestSoapContext.Current;
}

这是确切的错误:

Error   1   The type or namespace name 'SoapContext' could not be found (are you missing a using directive or an assembly reference?)   C:\Users\Sophia Carter\Documents\Visual Studio 2010\Projects\DemoGetVehInf\DemoGetVehInf\Form1.cs   45  13  DemoGetVehInf

1 个答案:

答案 0 :(得分:0)

根据错误,您似乎需要一个using语句来包含包含SoapContext的命名空间。 我不知道这会是什么名称空间,但在代码的顶部你会发出类似的内容:

using SoapContextNamespace;

我个人使用Visual Studio和ReSharper。这种工具组合检测到此错误,并提供一种方法来纠正它,右键单击时从上下文菜单中选择一些内容。根据您的工具集,您可能会发现此选项或类似选项。

相关问题