簡體   English   中英

SoapException-缺少標題信息

[英]SoapException - Missing Header Information

我正在嘗試使用一個簡單的控制台應用程序從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 =“”
Node = Unknown Error Role =“” StackTrace:em System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage消息,WebResponse響應,流responseStream,布爾asyncCall)em System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(字符串methodName ,Object []參數)em ConsoleApplication3.myWS.WServer.GetMethods()不適用c:\\ VS \\ ConsoleApplication3 \\ ConsoleApplication3 \\ Web References \\ myWS \\ Reference.cs:linha 532 em ConsoleApplication3.Program.Main(String [] args)不適用c:\\ VS \\ ConsoleApplication3 \\ ConsoleApplication3 \\ Program.cs:linha 14 em System.AppDomain._nExecuteAssembly(RuntimeAssembly Assembly,String [] args)em System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)em Microsoft .VisualStudio.HostingProcess.HostProc.RunUsersAssembly()em System.Threading.ThreadHelper.ThreadStart_Context(Object state)em System.Threading.ExecutionContext.RunInternal(ExecutionContext executeContext,ContextCallback回調,對象狀態, System.Threading.ExecutionContext.Run(ExecutionContext executeContext,ContextCallback回調,對象狀態,布爾類型的saveSyncCtx)em System.Threading.ExecutionContext.Run(ExecutionContext執行上下文,ContextCallback回調,對象狀態)的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>

我認為問題與身份驗證有關,因為我沒有在控制台應用程序中設置任何憑據。

我想出了解決方法。
它與身份驗證有關,如下例所示:

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

在調用方法之前。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM