all groups > visual studio .net ide > march 2007 >
You're in the

visual studio .net ide

group:

Web solution with Web Service does not start Web Service


Web solution with Web Service does not start Web Service Dale
3/20/2007 2:33:08 PM
visual studio .net ide:
I have a series of .Net 2.0 solutions in VS2005. Each solution consists of a
web site and a web service. The web site in the solution always has a web
reference to the web service in the solution.

Some of the solutions also have a class library or two in them.

The solutions are a mix of Web Application Projects and of Web Site
projects, though each solution only contains one or the other project format
within that solution.

The problem I keep having is that I keep getting an error when running the
solution in debug within the IDE, I keep getting a System.Net.WebException in
System.dll with this message:

"Additional information: Unable to connect to the remote server"

The error occurs on the first call from the web site to a webmethod on the
web service.

The only ways to fix it are to either drop the web reference and re-add it -
which always works, or in the case of the Web Application Project format
solution, I can right-click the web service and select Debug->Start new
instance.

Once the new instance is started, the ASP.Net Development Server for the web
service starts and then I can call the web service successfully.

Is there a way to prevent this error? I have a presentation with these 4
solutions tomorrow and I don't want to waste valuable time or credibility by
having to monkey around with things that are not part of the demonstration -
like re-adding web references or tricking the IDE into starting the ASP.Net
Development Server.

Thanks,

Dale
--
Dale Preston
MCAD C#
RE: Web solution with Web Service does not start Web Service v-wywang NO[at]SPAM online.microsoft.com (
3/21/2007 12:00:00 AM
Hi Dale,

Does this issue only occur in Website project? Please open .wsdl file
generated by VS under your Website project.
Found the xml tag such as below.
<wsdl:service name="Service">
<wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
<soap:address
location="http://localhost:13121/WebSite10/Service.asmx" />
</wsdl:port>
<wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
<soap12:address
location="http://localhost:13121/WebSite10/Service.asmx" />
</wsdl:port>
</wsdl:service>

Coply the location into your Internet Exloper, does it work fine?
If not, I think this issue is because you set the dynamic port for your
webservice. For this reason, web reference in your website project can not
connect to the right location where your webservice running.

To resolve this issue, please click your webserivce project, and set the
property "Use dynamic ports" to "False". Then, in each website project, you
may drop the web reference and re-add it again.

Please try this method and let me know whether this resolve your issue. We
will follow up. I'm glad to assist you.

Have a great day,
Sincerely,
Wen Yuan
RE: Web solution with Web Service does not start Web Service Dale
3/21/2007 9:26:00 PM
These 5 solutions consist of 3 website version and two web application
version projects.

Each solution has a web app and a web service. In each case, if the web app
is a website, the web service is also. If the web app was created as a web
application project, so was the web service.

Because of the features of these projects, each must be of the type that
they are; there's no way to make them all the same.

That said, they have all demonstrated the problem described in the original
post.

Four of these projects are demonstration projects for my series of articles
on returning objects from a web service at
http://www.dalepreston.com/Blog/2005/02/returning-custom-classes-from-web.html.
These 4 porjects can be downloaded at
http://www.dalepreston.com/downloads/objectsfromwsdemos.zip. The fifth
project is a production project at work using the SchemaImporterExtension and
cannot really be packaged for use outside of the company.

As for the other questions - in some cases when the problem occurs, I can
cause the web service to start by opening it in another browser using the
port specified in the web reference, and set the next statement to the one
that just failed. Now the statement will run and the demo completes. In
other cases, when I try that, it won't work and even though the port number
matches what I manually started and what the web reference URL is as
determined in debugging, I still cannot get past the error. Then the only
option is to drop and re-create the web reference.

I have not had this problem with these applications before installing SP1
but I can't say for certain that it is related to SP1.

Thanks for following up.

Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA


[quoted text, click to view]
RE: Web solution with Web Service does not start Web Service v-wywang NO[at]SPAM online.microsoft.com (
3/23/2007 12:00:00 AM
Hi Dale,
Thanks for your reply.

I have download four demo solutions from
http://www.dalepreston.comdownloads/objectsfromwsdemos.zip, and had a try.

Frankly, at first, when I start debug each solution, I got the exception
said "Additional information: Unable to connect to the remote server". Then
I did "debug|strat one instance" for each webserice webite/application.
Each solution works fine on my side now. I haven't reproduced the issue
just now.

In order to narrow down the issue, would you please clarify something for
me? Thanks.
[quoted text, click to view]
cause the web service to start by opening it in another browser using the
port specified in the web reference, and set the next statement to the one
that just failed. Now the statement will run and the demo completes.

This behavior is by design. We should have to start the webservice before
starting the project which reference this webservice. (For website
application project).
For Website project, webservice will be started automatically when it been
called.
However, do you have any further issue on this?

[quoted text, click to view]
number matches what I manually started and what the web reference URL is as
determined in debugging, I still cannot get past the error

Do you mean that the webservive still cannot be connected, even though you
have copied webservice url reference into IE and it works fine?
Would you please tell me which solution has this issue? (demo 1/2/3/4). I
have tried, but, unfortunately, I cannot reproduce the issue.
For such issue, I should have to reproduced the issue on my side and then
do further analyze.

Please feel free to let me know if you have more concern. I'm glad to
assist you.
Have a great day,
Sincerely,
Wen Yuan
RE: Web solution with Web Service does not start Web Service Dale
3/23/2007 8:55:03 PM
WenYuan,

Thanks for looking in to this for me. I do have some questions inline
below.

Dale

[quoted text, click to view]

I have been building solutions for several years that include webforms UI
and web service middle-tier and have never had to start the web service that
was contained in the solution before starting to debug. What changed?

[quoted text, click to view]

My current project is a solution that contains a webforms UI and a web
service middle-tier. When I first started on this project, I did not have to
manually start the web service. I have been working on this solution for
several months now. Only since installing SP1 have I suddenly had problems
where the webservice is not started when the UI tries to call it. And this
is all websites, not web applications.

[quoted text, click to view]

Considering that the Visual Studio web server is not running when I start
debugging, how is it that pasting the web service URL into a browser is
supposed to start the webservice running? When I paste that address into a
browser, I get the Internet Explorer cannot display the webpage error in IE.
That is what I expect to get because there is no handler for the assigned
port (in this case 9016) if the Visual Studio web server for my web service
is not started. The Visual Studio web server for the web service should
start when I click Debug. It always has before.

[quoted text, click to view]
RE: Web solution with Web Service does not start Web Service v-wywang NO[at]SPAM online.microsoft.com (
3/27/2007 12:00:00 AM
Hi Dale,

Thanks for your reply.

[quoted text, click to view]

Web Service should have been started before we call it. The reason why you
never have to start the web service before starting to debug is that the
Visual Studio will automatically start web service when you click "start to
debug". But this behavior only applies to [ASP.net Web Service] Project,
for [ASP.net Web Service Application] Project, Visual Studio will not start
it automatically. For this reason, when we call a web service which is
[ASP.net Web Service Application], we will receive the exception as
"Additional information: Unable to connect to the remote server". We need
to start such web service before we begin to debug.

[quoted text, click to view]

Have you checked whether the project type for your web service is [ASP.net
Web Service] Project?
For [ASP.net Web Service] Project, this behavior is not intentional. This
website should automatically have been started by VS IDE when you start
debugging.
If this project type is [ASP.net Web Service Application], I'm afraid this
by design. We should have to start such web service application manual.

[quoted text, click to view]

[ASP.net Web Service Application] is a new feature in SP1. Before VS 2005
SP1, we have only one project type for WebService which is [ASP.net Web
Service] (Except you have installed Visual Studio 2005 Web Application
Project model).
http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx
I guess you have misunderstood [ASP.net Web Service Application] project as
[ASP.net Web Service] project.

However, if you have single solution with many projects, you can enable the
Multiple startup projects option in VS.
Right Click the Solution -> Properties -> Mark the Multiple startup
projects radio button -> Set all the projects in the solution to Start.
After that all the projects (which marked as Start) will be started after
you click "start to debug".

Hope this helps. Please feel free to reply me if you still have anything
unclear. I'm very glad to assist you.

Sincerely,
Wen Yuan
AddThis Social Bookmark Button