【问题标题】:SoapException - Missing Header InformationSoapException - 缺少标头信息
【发布时间】:2014-09-24 22:19:49
【问题描述】:

我正在尝试使用简单的控制台应用程序从 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 消息=错误 - 缺少标头信息。
Source=System.Web.Services Actor=未知错误 Lang=""
节点=未知错误角色=“”堆栈跟踪: em System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage 消息、WebResponse 响应、流 responseStream、布尔值 异步调用) em System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(字符串 方法名,对象 [] 参数) em ConsoleApplication3.myWS.WServer.GetMethods() na c:\VS\ConsoleApplication3\ConsoleApplication3\Web 参考文献\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(字符串 assemblyFile,证据 assemblySecurity,字符串 [] args) em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() em System.Threading.ThreadHelper.ThreadStart_Context(对象状态) em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext、ContextCallback 回调、对象状态、布尔值 保留SyncCtx) em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean 保留SyncCtx) em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) em System.Threading.ThreadHelper.ThreadStart() InnerException:

尽管存在上述问题,但使用SoapUIXML,效果很好。

<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>

我认为问题与身份验证有关,因为我没有在控制台应用程序中设置任何凭据。

【问题讨论】:

    标签: c# .net xml soap soapui


    【解决方案1】:

    我想出了如何解决它。
    和认证有关,如下例:

    WebService .MultiSpeakMsgHeaderValue = new MultiSpeakMsgHeader {
        Pwd = "***",
        UserID = "***"
    };
    

    在调用方法之前。

    【讨论】:

      猜你喜欢
      • 2017-04-05
      • 1970-01-01
      • 2010-10-11
      • 1970-01-01
      • 2013-08-19
      • 1970-01-01
      • 2018-07-17
      • 1970-01-01
      • 2016-08-25
      相关资源
      最近更新 更多