calling webservice in c#

i have a console application that is calling a webservice.  I am getting an error:

System.Web.Services.Protocols.SoapException: Server Error
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClie
ntMessage message, WebResponse response, Stream responseStream, Boolean asyncCal
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodN
ame, Object[] parameters)
   at ArgoServiceVersion14.ArgobasicService.basicInvoke(basicInvoke basicInvoke1
) in c:\documents and settings\jlongo\my documents\visual studio 2010\Projects\C
onsoleApplication2\ConsoleApplication2\ArgoBasicService.cs:line 49
   at ConsoleApplication2.Program.basicInvoke(String inScopeCoordinateIds, Strin
g inRequestXml) in c:\documents and settings\jlongo\my documents\visual studio 2
010\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs:line 82
   at ConsoleApplication2.Program.Main(String[] args) in c:\documents and settin
gs\jlongo\my documents\visual studio 2010\Projects\ConsoleApplication2\ConsoleAp
plication2\Program.cs:line 55

the log is showing some kind of SOAP fault.

2011-12-28 13:30:52,996 ERROR  [http-9080-3                        ] [CredentialAuthenticatorHandler:156] (   ) Authentication Error, created Soap Fault.

what do you think the issue is?

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.Net;
using System.IO;
using System.Data;

namespace ConsoleApplication2
   class Program

      public static String _username = "xxxx";
      public static String _password = "xxxx";
      public static String requestXml;
      public static String responseXml;
      public static String scopeCoordinateIds = "xxxx/xxxx/xxx/xxx"; 
        static void Main(string[] args)
            Console.WriteLine("SEAL PROCESSING");
            SqlConnection myConnection = new SqlConnection("Data Source=sqlserver\\globalsql;Initial Catalog=seal;User Id=xxx;Password=xxxx);

                SqlDataReader myReader = null;
                SqlCommand myCommand = new SqlCommand("select checker, pass, type from seal_authorization", myConnection);
                myReader = myCommand.ExecuteReader();
                while (myReader.Read())
                catch (Exception e)
                requestXml = "<unit-seals><unit-identity id=OOLU1234567 /><seals seal-1=123 /></unit-seals>";
                responseXml = basicInvoke(scopeCoordinateIds, requestXml);
            catch (Exception e)

       private static String basicInvoke(String inScopeCoordinateIds, String inRequestXml)
            ArgoServiceVersion14.basicInvoke wsParams = new ArgoServiceVersion14.basicInvoke();
            wsParams.scopeCoordinateIds = scopeCoordinateIds;
            wsParams.xmlDoc = inRequestXml;
            BasicAuthenticationWebservice ws = new BasicAuthenticationWebservice(_username, _password);
            ws.Timeout = -1; // disable the timeout
            ArgoServiceVersion14.basicInvokeResponse wsResponse = ws.basicInvoke(wsParams);
            return wsResponse.basicInvokeResponse1;

       class BasicAuthenticationWebservice : ArgoServiceVersion14.ArgobasicService
           private String _b64Credentials;
           protected override System.Net.WebRequest GetWebRequest(Uri uri)
               System.Net.HttpWebRequest httpRequest = (System.Net.HttpWebRequest)base.GetWebRequest(uri);
               // set the authentication in the http header
               httpRequest.Headers.Add("Authorization", "Basic " + _b64Credentials);
               return (System.Net.WebRequest)httpRequest;
           public BasicAuthenticationWebservice(String inUsername, String inPassword)
               byte[] bCredentials = Encoding.ASCII.GetBytes(inUsername + ":" + inPassword);
               _b64Credentials = Convert.ToBase64String(bCredentials);


Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NJJoeG8GTAuthor Commented:
do you think i need to convert  this:

 requestXml = "<unit-seals><unit-identity id=OOLU1234567 /><seals seal-1=123 /></unit-seals>";

to XML.

i think this needs some soap headers...
Is there any particular reason why you're creating the xml by hand? You should be able to call the webservice much more easily by adding a reference to it in the project (right click on the project and click add service reference). After you've added the reference it will create proxy classes that make it so you can interact with the webservice in an object oriented way instead of manually creating the xml.
NJJoeG8GTAuthor Commented:
I am new to this.  it very hard to find examples on how to call webservice from a console application.
that being manager wants me to use strings and not things like class serialization.  
it is a java webservice and all the examples i find are using .ASMX web services.


            bReturn = True


            strBillStatus = GetBillingStatus(mVesselInfo.SCMAIN.VESSELN4BILLINGCODE)

            If (strBillStatus = "") Or (strBillStatus = "NOT BILLED") Then

                strConnection = gctIntInfo.GetResource(My.Computer.Name, My.User.Name, "N4" & mConnection)

                lResource = lResource.DeSerialize(strConnection, strStatus)

                strConnection = d.DecryptText(lResource.PARAMETER)

                strConnections = strConnection.Split(",")

                ba = Encoding.ASCII.GetBytes(strConnections(1))

                str64 = Convert.ToBase64String(ba)

                n4WebService = New ExtendedGenericWebservice

                Using n4WebService

                    n4WebService.SetRequestHeader("Authorization", "Basic " + str64)

                    n4WebService.Url = strConnections(0)

                    arg.scopeCoordinateIdsWsType = New WebReference.ScopeCoordinateIdsWsType

                    arg.scopeCoordinateIdsWsType.operatorId = strConnections(2)

                    arg.scopeCoordinateIdsWsType.complexId = strConnections(3)

                    arg.scopeCoordinateIdsWsType.facilityId = strConnections(4)

                    arg.scopeCoordinateIdsWsType.yardId = strConnections(5)

                    strXMLline = "<groovy class-location=""database"" class-name=""GCTGvyRecordVesselBillingEvents"">"

                    LocalLog(". " & strXMLline)

                    strXML = strXMLline

                    strXMLline = "<parameters>"

                    LocalLog(". " & strXMLline)

                    strXML = strXML & strXMLline

                    strXMLline = "<parameter id=""vessel-visit-id"" value=""" & mVesselInfo.SCMAIN.VESSELN4BILLINGCODE & """/>"

                    LocalLog(". " & strXMLline)

                    strXML = strXML & strXMLline

                    For Each lSummary In mSummaryCol

                        nRowMax = lSummary.GRDBILL.Rows.Count - 1

                        For nRow = 2 To nRowMax

                            nLine = nLine + 1

                            strXMLline = "<parameter id=""event-type-id-" & nLine.ToString & """ value=""" & lSummary.GRDBILL.Item(nRow, 1) & ";" & _

                                         lSummary.LINE & ";" & _

                                         lSummary.GRDBILL.Item(nRow, 2) & ";" & _

                                         lSummary.GRDBILL.Item(nRow, 3) & ";" & _

                                         lSummary.GRDBILL.Item(nRow, 4).ToString.ToUpper & """/>"

                            LocalLog(". " & strXMLline)

                            strXML = strXML & strXMLline



                    strXMLline = "</parameters>"

                    LocalLog(". " & strXMLline)

                    strXML = strXML & strXMLline

                    strXMLline = "</groovy>"

                    LocalLog(". " & strXMLline)

                    strXML = strXML & strXMLline

                    arg.xmlDoc = strXML

                    LocalLog(". Calling N4WebService")

                    response = n4WebService.genericInvoke(arg)

                    LocalLog(". STATUS:" & response.genericInvokeResponse1.commonResponse.Status & ":" & response.genericInvokeResponse1.commonResponse.StatusDescription)

                    For Each message In response.genericInvokeResponse1.commonResponse.MessageCollector

                        LocalLog(". . MESSAGE:" & message.SeverityLevel & ":" & message.Message)



                End Using


                If (MsgBox("The current state of the N4 BILLING CODES [" & strBillStatus & "] will not allow posting of BILL EVENTS" & vbCrLf & "Do you want to continue with the FORWARD", MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2, My.Application.Info.AssemblyName) = MsgBoxResult.No) Then

                    bReturn = False

                End If

                LocalLog("..PostBillingInformation:Invalid status codes [" & strBillStatus & "], posting not allowed")

            End If

        Catch ex As Exception

            LocalLog("..PostBillingInformation:Exception:" & ex.Message)

            bReturn = False

        End Try

        Return bReturn

    End Function

Open in new window

Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

NJJoeG8GTAuthor Commented:
so i created a new console application.  Added the web reference.. it resolved and has been added to my solution explorer.  my question now is what do i do with this reference?
Navneet.Net Full Stack DeveloperCommented:

Better use "Add WebService"  functionality in Vs2010.

In your console select Add Service Reference --> Advanced --> Add Web Reference

try it world will be far easier

You have to create an instance of the object and then call whatever method you want.

For instance lets say you called the reference WebService1, and the web service method is WebMethod1
//This creates an instance of the webservice object
var WS = new WebService1();

//This actually calls the webservice, you may need to pass in parameters (as defined by the webservice).

Open in new window

Your webservice may be in a namespace so it might not be as simple as the sample above, the best advise is to just use intellisense to explore the different objects and figure out what you want.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NJJoeG8GTAuthor Commented:
its a complicated question.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.