PC Review


Reply
Thread Tools Rate Thread

Calling webserivce giving Error in Windows service but WebApplication& Windows Application Successfull.

 
 
nRk
Guest
Posts: n/a
 
      8th Dec 2008
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 With Quote
 
 
 
 
Jeff Johnson
Guest
Posts: n/a
 
      8th Dec 2008
"nRk" <(E-Mail Removed)> wrote in message
news:73bfdce8-325c-4dac-a54e-(E-Mail Removed)...

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


Is it possible that the account the service is running under simply doesn't
have network access?


 
Reply With Quote
 
nRk
Guest
Posts: n/a
 
      8th Dec 2008
On Dec 8, 7:49*pm, "Jeff Johnson" <i....@enough.spam> wrote:
> "nRk" <ramesh....@gmail.com> wrote in message
>
> news:73bfdce8-325c-4dac-a54e-(E-Mail Removed)...
>
> > 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 .

>
> Is it possible that the account the service is running under simply doesn't
> have network access?


Hi
Thanks for the fast reply..

I started windows service with differenct account..
Like LocalSystem , UserAccount.. Networkservice account..
Actually the current user account is type of Administrator for the
system.

thanks
nrk
 
Reply With Quote
 
Ollis
Guest
Posts: n/a
 
      8th Dec 2008


"nRk" wrote:

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


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

------------------------------------------------------------------------------------------

The above kind of seems that you may be having a firewall issuse (blocked
port) as something is happening with TCP port 443, the HTTPS port.

Is all this you're talking about happening on the localhost/machine or a
remote IP/machine?


 
Reply With Quote
 
nRk
Guest
Posts: n/a
 
      9th Dec 2008
Hi
Thanks for the reply..

As you said there might be firewall issue.. Or port 443 issue..
It working fine in the Windows application without any problem. I am
receiving response what I expected (correct one).

In windows forms I added reference of the window service project and
called class.. as like an button click I did like this.

try
{
TestClass ss = new TestClass();
ss.CallWebservice();
}
catch (Exception ex)
{
log.Log(LogTypeEnum.ERROR, "Error occured while
connecting to the webservice.");
log.Log(ex);
}

It works fine without any problem... When it is working fine the same
why it is not working in the windows service....

Help to get out of this issue...

thanks
nrk


On Dec 9, 12:56*am, Ollis <N...@No.com> wrote:
> "nRk" wrote:
> > 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 .

>
> *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
>
> ------------------------------------------------------------------------------------------
>
> The above kind of seems that you may be having a firewall issuse (blocked
> port) as something is happening with TCP port 443, the HTTPS port.
>
> Is all this you're talking about happening on the localhost/machine or a
> remote IP/machine?


 
Reply With Quote
 
Mr. Arnold
Guest
Posts: n/a
 
      9th Dec 2008

"nRk" <(E-Mail Removed)> wrote in message
news:377f5377-3705-4aca-9cbf-(E-Mail Removed)...
Hi
Thanks for the reply..

As you said there might be firewall issue.. Or port 443 issue..
It working fine in the Windows application without any problem. I am
receiving response what I expected (correct one).


What happens when you try to consume the Web service in a Console
Application that is the Web client? And how is port 443 involved? Do you
know that you are using HTTPS for the Web service? Is this Web service being
consumed on localhost/IIS running this Web service or is the Web service
being consumed over HTTP a Internet or Intranet solution on a remote Web
server?


 
Reply With Quote
 
nRk
Guest
Posts: n/a
 
      9th Dec 2008
Hi Arnold

Thanks
As you said.. Console I didn't try..
The webservice I am consuming is developed using JAVA.
This webservice hosted some other remote machine, not in local machine
IIS.
It is consumed over internet.. not Intranet
I will try with console application ... .

thanks
nrk


On Dec 9, 10:10*am, "Mr. Arnold" <MR. Arn...@Arnold.com> wrote:
> "nRk" <ramesh....@gmail.com> wrote in message
>
> news:377f5377-3705-4aca-9cbf-(E-Mail Removed)...
> Hi
> Thanks for the reply..
>
> As you said there might be firewall issue.. Or port 443 issue..
> It working fine in the Windows application without any problem. *I am
> receiving response what I expected (correct one).
>
> What happens when you try to consume the Web service in a Console
> Application that is the Web client? And how is port 443 involved? Do you
> know that you are using HTTPS for the Web service? Is this Web service being
> consumed on localhost/IIS running this Web service or is the Web service
> being consumed over HTTP a Internet or Intranet solution on a remote Web
> server?


 
Reply With Quote
 
Ollis
Guest
Posts: n/a
 
      9th Dec 2008
nRk wrote:
> Hi Arnold
>
> Thanks
> As you said.. Console I didn't try..
> The webservice I am consuming is developed using JAVA.
> This webservice hosted some other remote machine, not in local machine
> IIS.
> It is consumed over internet.. not Intranet
> I will try with console application ... .
>


Well, I can see the HTTPS TCP port 443 coming into play here possibly on
a remote Web server and a Web service that's using HTTPS, because the
error message you have provided is talking about TCP 443 the HTTPS port.

I don't know what trying to do here, as I am not privileged to the
information that you have. But if this is a 3rd party vendor Web
service, then you need to be in contact with the 3rd party vendor about
the consumption of the Web service from your Web service client solution
via a Windows desktop, ASP.Net, Windows service or Console application.

 
Reply With Quote
 
nRk
Guest
Posts: n/a
 
      10th Dec 2008
Hi Ollis

As you said I am tring to connect third party webservice developed in
Java..

One thing I am still in doubt.. why it is not working only in
WindowService, it is working in asp.net web application & C# Windows
application.

The exception/Error comming only When I am trying to connect in
Windows Service...?

Can you help me on this issue?

thanks
nrk


On Dec 9, 5:07*pm, Ollis <Ol...@Ollis.com> wrote:
> nRk wrote:
> > Hi Arnold

>
> > Thanks
> > As you said.. Console I didn't try..
> > The webservice I am consuming is *developed using JAVA.
> > This webservice hosted some other remote machine, not in local machine
> > IIS.
> > It is consumed over internet.. not Intranet
> > I will try with console application ... .

>
> Well, I can see the HTTPS TCP port 443 coming into play here possibly on
> a remote Web server and a Web service that's using HTTPS, because the
> error message you have provided is talking about TCP 443 the HTTPS port.
>
> I don't know what trying to do here, as I am not privileged to the
> information that you have. But if this is a 3rd party vendor Web
> service, then you need to be in contact with the 3rd party vendor about
> the consumption of the Web service from your Web service client solution
> via a Windows desktop, ASP.Net, Windows service or Console application.


 
Reply With Quote
 
nRk
Guest
Posts: n/a
 
      10th Dec 2008
Hi
Thanks for all for your support
I am able to find out the solution

I changed the proxy settings like this..
from
mgmtServiceProxy.Proxy = WebRequest.DefaultWebProxy; (giving
error, But is the wrong )
to
mgmtServiceProxy.Proxy = new WebProxy("10.108.26.212", 80);

Or can be used

<system.net>
<defaultProxy>
<proxy
proxyaddress = "http://10.108.26.212:80"/>
</defaultProxy>
</system.net>


thanks
nrk


On Dec 10, 8:34*am, nRk <ramesh....@gmail.com> wrote:
> Hi Ollis
>
> As you said I am tring to connect third party webservice developed in
> Java..
>
> One thing I am still in doubt.. why it is not working only in
> WindowService, it is working in asp.net web application *& C# Windows
> application.
>
> The exception/Error comming only When I am trying to connect in
> Windows Service...?
>
> Can you help me on this issue?
>
> thanks
> nrk
>
> On Dec 9, 5:07*pm, Ollis <Ol...@Ollis.com> wrote:
>
> > nRk wrote:
> > > Hi Arnold

>
> > > Thanks
> > > As you said.. Console I didn't try..
> > > The webservice I am consuming is *developed using JAVA.
> > > This webservice hosted some other remote machine, not in local machine
> > > IIS.
> > > It is consumed over internet.. not Intranet
> > > I will try with console application ... .

>
> > Well, I can see the HTTPS TCP port 443 coming into play here possibly on
> > a remote Web server and a Web service that's using HTTPS, because the
> > error message you have provided is talking about TCP 443 the HTTPS port..

>
> > I don't know what trying to do here, as I am not privileged to the
> > information that you have. But if this is a 3rd party vendor Web
> > service, then you need to be in contact with the 3rd party vendor about
> > the consumption of the Web service from your Web service client solution
> > via a Windows desktop, ASP.Net, Windows service or Console application.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error when calling a webservice from a windows service GD Microsoft Dot NET Framework Forms 4 18th Apr 2007 11:58 PM
Deploy a Windows Application that Calling Web Service =?Utf-8?B?VGVkbW9uZA==?= Microsoft Dot NET 2 25th Apr 2006 05:08 PM
Windows service giving error. trialproduct2004@yahoo.com Microsoft Dot NET 0 27th Dec 2005 01:08 PM
Strange behaviour when calling webserivce eNoodle Microsoft Dot NET Compact Framework 0 26th May 2004 09:40 AM
windows service calling another application Billy Cormic Microsoft VB .NET 0 20th Feb 2004 11:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:43 PM.