how to access webservice deployed in remote server - c#

Please help me , how to add web service which is deployed in remote server. externally i unable to access that service..in that remote server only that service will run but we don't have Ms.net Environment to add service to my application in that server.
So please guide me how to add that web service to my application ,not accessig externally that service URl, internally Executing that URl.
How can i add that service to my application on my developer PC ?

To add a web reference you need to have access to the WSDL file.
You need to do this in 2 steps:
First add a web reference to your project based on the WSDL
Then change the URL of the web reference to match the address of the external service

You can move service URL to web config please refer here.
http://forums.asp.net/p/1268077/2388602.aspx
But if your IP address changes too often (Dynamic IP) I think better your remote network configuration should be changed to have some sort of redirection to your Dynamic IP via a Static IP in your outside network so you can give that Static IP as service URL.
So you don't have to change the web config even too often.
Anyway you Should get advice from a network administrator.

Related

Web service call from another ws blocked by firewall

My problem is the following:
I got a Web Service running on localhost. When I call it it should connect to another third party web service. But I get a 'Unable to connect to the remote server error'.
When I call the third party web service from a console application, or from a computer that is not from my organization, I can reach it, but not from a running web service, either IIS or IIS Express. If I use another network I can't reach it too (Smartphone).
I suppose that is a a rule in the firewall for the port or something like that but I tried to open the port in both directions but still can't do nothing.
I use HttpWebRequest class to call the other web service.
Thanks in advance.

c# Webservice on localhost

I'm a bit out of my depth and haven't found the answer I need from Google, so could do with some advice.
I have a website that currently has some functionality build in.
I now find myself needing to create a second website containing the same functionality.
In order to do this the proper way, I want to create a webservice and access it from both sites. I've created a new solution and the webservice so far.
On my development machine, I can browse to the webservice.
The question is when I move this webservice to the live server, will it need it's own IP address, domain, or both? Or can it reside on the local server and be accessed in the same way as I would on my development machine?
The webservice does not need to be accessed from outside the server.
I'm a little unclear and its not easy to test in a live environment.
All help appreciated.
A web service works in exactly the same way as a website, only instead of returning HTML, it returns JSON/XML or similar. You'll need to host it on a web server, but if you only need it to be locally accessible, you can set the web server up to bind to localhost (127.0.0.1 in IP4) either on the default port (80) if nothing is already using it or on a different port (eg.12380 where it would be addressed as http://localhost:12380).
Most web servers can bind to anything that comes in on a specific IP address that isn't otherwise allocated or they can recognise which site to serve based on the host name that has been requested. nb. the host name isn't sent automatically by (TCP/)IP - the browser, or in this case web service client will sent an HTTP request header to let the server know which site to serve.
If you have sufficient control over the server, you can also create an entry in the hosts file to use in place of a domain name (eg. webservice maps to 127.0.0.1) and then set up your web server to bind to that.

Error while consuming wcf service

I created a wcf application library with no modification from the original example and I hosted it in IIS. It's on a remote computer and using chrome i can see that the service is up and running but if i try to create a config file using
svcutil.exe http://IP_HERE/serv/WcfServiceLibrary1.Service1.svc?wsdl
i receive the following error.
I think that it has something to do with the application pool. What do you think?
My default config: http://pastebin.com/a355LcWp
After checking your service config file I found that you are hosting service on port 8733 which is mentioned in base address value. You need to make sure that you include this port number while accessing wsdl.

WCF communication on Http

I have a WCF service which works fine when accessed internally. The WCF link is
.
I requested the network team at our organization to expose this WCF to outside world since public websites will access this WCF. I gave the network team DNS as somewebsite.com and IP address of the server on which WCF is hosted.
After getting the confirmation from Network team (they use Juniper network ) that they have made the required settings to make the WCF available to outside world I tested it as an external user.
If I type in http://somewebsite.com/LookUp.svc on address bar I get http 404 page not found error. However if I replace http with httpS as then I see the WCF information. To further test it , I added a simple html file to the root of the website and opened as
http://somewebsite.com/test.html. The Test.html does not open when http is used. However it I use httpS as then Test.html page is displayed to outside users.
The WCF is hosted to windows 2008 R2 and is communicating over port 80 and I have also added the site binding as somewebsite.com with Type as Http and port as 80.
Any idea why WCF caanot be accseed over http ?. I want it to be accessed over http only ?. The WCF uses basicHttpBinding
Is the setting wrong on server on which WCF is hosted ?
Any suggestion is greatly appreciated..
If the service worked before over http before your network guys opened the firewalls I would suggest that they have only enabled the firewall for https traffic.
Sounds like a firewall/routing problem to me...
HTH

Multiple client endpoints to the same WCF service

I've got a WCF service running on a LAN IIS which is accessible from the internet as well.
The client that consumes the service is an application that runs on the LAN and remotely through the internet. There is no forwarding of anything on the DNS server redirecting http://www.corporate.com/Service to http://serverName/Service so I'm figuring I'll need 2 endpoints on the client.
How do you setup multiple endpoints in the client (is it as simple as copying the existing enpoint generated in the app.config but changing the address?) and how do you configure the client to use a particular endpoint?
You may store endpoint addresses either at app.config, or at resource strings. Then using any condition you pass needed endpoint address to service constructor.
var endpoint = ApplicationSettings.IsRemote ? Resources.RemoteEndPoint: Resources.LocalEndPoint;
var service = new MyWCFService(new BasicHttpBinding(), new Endpoint(endpoint));
The app.config (or web.config) for each copy of the application should have the endpoint for the service set based on the one it needs. For LAN installations, use the LAN-visible endpoint; for all others, use the Internet one.
It may save you a trip to the router, but why not just use the internet endpoint everywhere? If your LAN computers have a gateway to the Net, they can see the externally-visible address.
It is as simple as changing the address and using the endpoint generated in the app config. You may have to change security modes depending on what is supported on either server, or whether they are both running HTTPS or not. We have an application where we build the target endpoint based on relative path to the current URL in a Silverlight application. We also dynamically change the security mode based on HTTPS being present and it works great.

Categories