views:

71

answers:

2

I have a webservice that's not exposed thru the web. How can I access the webservice thru .net? Do I need to put the path to the server? I have three options in my solution? Which is the way that I have to go to access the service?

  1. Add Reference
  2. Add web reference
  3. Add Service Reference
+1  A: 

You need to use Add Web Reference

I hope you know how to do it furthur. When selecting "Add Web Reference", it would ask for the Webservice URI.

Here is the difference between Web Reference and Service Reference


If the web service is running on .NET developement server, it would be something like http://localhost:3013/WebService.asxm

If it is hosted on IIS, it would be something like http://localhost/WebService

Manish Sinha
-1: Why suggest "Add Web Reference" when you have no reason to believe he's restricted to old technology?
John Saunders
You should also know that not everyone works on latest bleeding edge software or technology. You need to give solutions which can even run on older technologies esp when it is being used exhaustively. Even I have to use Web Reference instead of Service Reference.
Manish Sinha
WCF is three years old, Manish! It's not "bleeding edge". If your application is important, you should probably use technology that the vendor plans to fix when it breaks. Better to use technology with a future than technology with no future. And it's not like WCF is hard to use when using it as a replacement for ASMX! There's little excuse beyond ignorance for not using WCF for new development.
John Saunders
Thanks John. I fully agree with your statements. The reason I told him to use Web Reference was that most of his colleagues might be using it and he can get help easily (the common situation in most of the places). OTOH Let me tell you from my experience - People **do** run away from WCF initially since at first it does look pretty complicated. It needs patience to learn.
Manish Sinha
Manish, no, it does not require patience to learn. Go create a "Hello, world" service from the VS template - pretty simple, huh? Change the binding to basicHttpBinding. Now you have a WCF service that ASMX can call. Very simple. What's complicated is deciding which WCF features you can ignore (hint: you can ignore almost all of them).
John Saunders
Thanks John. I had done WCF and do find it good. Telling from my personal experiences - Most people are utterly confused with it. People are mostly confused with things like "Half duplex" "Full duplex" communication and how to implement it. I too need to look into it again. Forget nearly everything in advanced WCF
Manish Sinha
A: 

Actually, you should use "Add Service Reference" if possible. "Add Web Reference" uses the ASMX technology which Microsoft now considers to be "legacy technology".

When you use that command, pass it the path to the WSDL file for the service. Ordinarily, the path would be the path to a URL, like http://services.company.com/service.svc?wsdl. However, since you say the service is not on the net, they'll have to give you the WSDL. You can then simply supply the path to where the wsdl file is located on your disk.

John Saunders
Do you have an example? Actually the file that I need to access is an .asmx but I don't have access thru the web. I can see the server tough.
Tony
John, even though Microsoft considers it legacy, it is still widely popular in the industry. Even I have to use it and have to live by it.
Manish Sinha
@Tony: You don't need to access the .asmx. You need to access the WSDL. If it was accessible through the web, you'd use service.asmx?wsdl. Since it's not, they need to do that for you and then give you the WSDL. _That's_ what you need to access.
John Saunders
@Manish: VB6 is also widely popular within the industry. I recommend that nobody use it for new development. Same with ASMX. If your application matters, you should probably use technology that will get bug fixes and stay up to date. Don't treat the two like they're equivalent: they're not. WCF has a future, ASMX does not.
John Saunders
@John I can understand, but it not the developer's fault. The biggest problem is with legacy. I would also suggest everyone to use WCF instead of ASMX, but for client end, I am using Web Reference to be compatible with everything. If the web service on which am working on is on WCF, i won't mind using whatever you say.
Manish Sinha
There is no reason to not use a service reference, even if the service is an ASMX service. And, if the developer knows better than Management, and doesn't even speak up once, then that is the fault of the developer.
John Saunders