我试图使用一个简单的控制台应用程序从一个web服务中获取一些数据,但是我得到了这个错误:
SoapException未被处理 错误-缺少标题信息。
我已经试过以下几条:
但是我不被允许在WebServer方面工作,所以我无能为力。
代码:
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
myWS.WServer WebService = new myWS.WServer();
string[] myMethods = WebService.GetMethods();
}
}
}遵循完整的错误消息:
System.Web.Services.Protocols.SoapException未被处理 HResult=-2146233087 Message=Error -缺少报头信息。 Source=System.Web.Services Actor=Unknown Error Lang=“ “”System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage消息: em System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String消息,WebResponse响应,流responseStream,Boolean ) em System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,(参数) em c:\VS\ConsoleApplication3\ConsoleApplication3\Web () na c:\VS\ConsoleApplication3\ConsoleApplication3\Program.cs:linha References\myWS\Reference.cs:linha 532 em ConsoleApplication3.Program.Main(String[] args) na c:\VS\ConsoleApplication3\ConsoleApplication3\Program.cs:linha 14 em System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String[] args) em System.AppDomain.ExecuteAssembly(String assemblyFile,parameters,em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() em System.Threading.ThreadHelper.ThreadStart_Context(Object state ) em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback回调,Object状态,Boolean ) em System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,Object状态,布尔preserveSyncCtx) em System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态) em System.Threading.ThreadHelper.ThreadStart() InnerException:
尽管存在上述问题,使用SoapUI和XML,它仍然工作得很好。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ver="http://www.multispeak.org/Version_3.0">
<soapenv:Header>
<ver:MultiSpeakMsgHeader Version="3.0" UserID="myId" Pwd="myPwd" AppName="?" AppVersion="?" Company="?" CSUnits="feet" CoordinateSystem="?" Datum="?" SessionID="?" PreviousSessionID="?" ObjectsRemaining="?" LastSent="?" RegistrationID="?"/>
</soapenv:Header>
<soapenv:Body>
<ver:GetMethods/>
</soapenv:Body>
我认为这个问题与身份验证有关,因为我没有在控制台应用程序中设置任何凭据。
发布于 2014-09-25 17:48:07
我想出了解决办法。
它与身份验证有关,例如:
WebService .MultiSpeakMsgHeaderValue = new MultiSpeakMsgHeader {
Pwd = "***",
UserID = "***"
};在打电话给方法之前。
https://stackoverflow.com/questions/26027498
复制相似问题