0
votes

I am trying to get some data from a web service, using a simple console application, however I am getting this error:

SoapException was unhandled
Error - Missing Header Information.

I have already tried the below articles:

But I am not allowed to work on the WebServer side, so there is not much I can do.

Code:

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            myWS.WServer WebService = new myWS.WServer();
            string[] myMethods = WebService.GetMethods();
        }
    }
}

Follows the full error message:

System.Web.Services.Protocols.SoapException was unhandled
HResult=-2146233087 Message=Error - Missing Header Information.
Source=System.Web.Services Actor=Unknown Error Lang=""
Node=Unknown Error Role="" StackTrace: em System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) em System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) em ConsoleApplication3.myWS.WServer.GetMethods() na c:\VS\ConsoleApplication3\ConsoleApplication3\Web 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 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 executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) em System.Threading.ThreadHelper.ThreadStart() InnerException:

Despite the problem above, using SoapUI and XML, it does works well.

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

I am thinking that the problem is related to authentication, since I do not set any credentials in the console applications.

1

1 Answers

0
votes

I figured out how to solve it.
It was related to the authentication, as the example below:

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

Before call the methods.