Hi,
I am creating a windows service..
in that i am connecitng to a webservice and retrieving the data by
calling a web method. This calling will be done every 5 min once and
the data will be stored in the database.

I added a web reference.. successfully.
proxy class generated..
installed as windows service
I am getting error when It connecting webservice and calling web
method.

But when I work with same in Normal windows application.. I am
successfully connecting to the webservice and able to call web method.

Working in Web application also successfully.

GIVING PROBLEM ONLY IN WINDOWS SERVICE .

The following is the class having Single method. "CallWebservice()"
which I am calling
==================================================================
    public class TestClass
    {
        ILogManager log = LogManager.Instance;

        public void CallWebservice()
        {
            log.Log(LogTypeEnum.INFO, "Starting windows service
calling..............!");
            MgmtServicesSoap mgmtServiceProxy = new MgmtServicesSoap
();
            try
            {
                log.Log(LogTypeEnum.INFO, "Connecting to webserice for
tesing..");
                mgmtServiceProxy.PreAuthenticate = true;
                mgmtServiceProxy.AllowAutoRedirect = true;
                mgmtServiceProxy.Proxy = WebRequest.DefaultWebProxy;

                NetworkCredential networkCredential = new
NetworkCredential("xxxxx", "xxxxxx");
                CredentialCache credentialCache = new CredentialCache
();
                credentialCache.Add(new Uri(mgmtServiceProxy.Url),
"Basic", networkCredential);
                mgmtServiceProxy.Credentials = credentialCache;

                log.Log(LogTypeEnum.INFO, "Proxy class initialized.");
                string responseXmlString =
mgmtServiceProxy.getTransactionStatus("143566");
                log.Log(LogTypeEnum.INFO, "Proxy class initialized
succesfully and connected to webservice.");
                log.Log(LogTypeEnum.INFO, responseXmlString);

            }
            catch (Exception ex)
            {
                log.Log(LogTypeEnum.ERROR, "Error occured while
connecting to the webservice.");
                log.Log(ex);
            }
        }

    }

=====================
Windows service startup code
======================
 protected override void OnStart(string[] args)
        {
            log.Log(LogTypeEnum.INFO, "Starting windows
service..............!");
            MgmtServicesSoap mgmtServiceProxy = new MgmtServicesSoap
();
            try
            {
                TestClass ss = new TestClass();
                ss.CallWebservice();
            }
            catch (Exception ex)
            {
                log.Log(LogTypeEnum.ERROR, "Error occured while
connecting to the webservice.");
                log.Log(ex);
            }
        }

==================================
Error
==================================
ExceptonType WebException : Unable to connect to the remote server
   StackTrace :
         at System.Net.HttpWebRequest.GetRequestStream()
         at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke
(String methodName, Object[] parameters)
         at
TestindABSService.gov.energystar.estar8.MgmtServicesSoap.getTransactionStatus
(String TXNS_ID) in D:\Share\Testingservice\Web References
\gov.energystar.estar8\Reference.cs:line 379
         at TestindABSService.TestClass.CallWebservice() in D:\Share
\Testingservice\TestindABSService\TestClass.cs:line 31
2008-12-08T18:38:34.6601 :: Error: ExceptonType SocketException : A
connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed
because connected host has failed to respond xxx.xxx.xx.xxx:443
   StackTrace :
         at System.Net.Sockets.Socket.DoConnect(EndPoint
endPointSnapshot, SocketAddress socketAddress)
         at System.Net.Sockets.Socket.InternalConnect(EndPoint
remoteEP)
         at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)

Reply via email to