Can a Webservice be made publicly inaccessible? - c#

I am working on a project where a webservice is referenced. I can resolve and add the webservice reference to the project, update it and etc. without issue. I can also paste the URL of the webservice in my browser and have it resolved to see the public methods.
However when I publish the webservice to Azure it consistently fails saying that there is no endpoint and/or the address cannot be resolved.
After trying numerous methods of troubleshooting the issue and modifying different sections of my configuration file as it pertains to the webservice; I figured I'd try accessing the service from outside of my work domain.
When I pasted the URL into a browser from my home I received a "Page cannot be found" error.
I then attempted to resolve the URL from within VS from my home system and I received the same error that Azure has been throwing regarding no endpoint and that the URL could not be resolved.
In the past when I've worked with Webservices, I've always been able to resolve the services from my work or home environment so this is a first for me.
I know that methods within a service can be publicly exposed or hidden but can the actual WebService be made inaccessible to the public as well? And if so, would the "No endpoint" message be the typical result?
I am working with the classic WebService model (asmx) not WCF. If that really makes any difference.

Related

Is it possible to send data to a specific login-required web service with C# using its defined method without HttpWebRequest?

I have access to WSDL file of a specific web service that contains a SendData method - basically I specify the TimeStamp and Value to be send. I uploaded the WSDL file to my project in Visual Studio 2019 as a connected service (Add->Connected Service->Microsoft WCF Web Service Reference Provider->Browse->I added location of the WSDL file and specified the service that included SendData method). After that I created a new client:
ServiceSoapClient client = new ServiceSoapClient(ServiceSoapClient.EndpointConfiguration.ServiceSoap);
added credentials (the web service requires login):
client.ClientCredentials.UserName.UserName = "test"; client.ClientCredentials.UserName.Password = "test";
created a new variable Data that contains TimeStamp and Value (in a specific format required by the method).
After that I invoked the method:
client.SendData(Data);
but it doesn't work. There are no errors or exceptions thrown, but the Data is not visible on the web service (the web service also has a GUI). I started to wonder if it is possible to send data to a web service in such a way or is it maybe necessary to create an xml file with a request and use HttpWebRequest?
Perhaps someone could help me figure out what is wrong, is there a way to check, what is going on during compilation? Unfortunately, I cannot include the URI or WSDL file, but hopefully my description of the issue will be sufficient. Thanks in advance for any guidance!
Okay, with the suggestion from Robert Harvey (thank you once again) and some trial and error I managed to solve my problem. Hopefully my answer will be useful to someone with the similar issue.
I found out that in some cases WCF web service's calls are not visible in Fiddler. In my case it was due to some packages not being up-to-date. These out-of-date packages were added automatically after connecting the web service via Microsoft WCF Web Service Reference Provider.
System.ServiceModel.Duplex/Http/NetTcp/Security all were installed in version 4.4 instead of 4.7. I updated them using Project->Manage NuGet Packages and now my requests are visible in Fiddler and I managed to verify that the way I used my method was correct, but the access to the web service (with the ability to save data) is currently limited, that is why the result was not visible directly on the web service (in the GUI).

IIS Express- C# Angular 2 Web Api functionality changes after publish

I have recently published my C# .net core Angular 2 web application to an IIS Server. However, the Web Api that I am calling is not working correctly. When I call the Api, a file is supposed to download however, the file does not render correctly.
I am sure that the api is being called as I am not getting a 404 error. When I run the project on my localhost, it works fine, but on the live site it is not working.
One more thing, when I enter information that should normally cause an error in the web api, it is not throwing me an error like it does in the localhost. It is as if the api is failing but when it is published to IIS it doesn't recognize the error in the angular observable. If anyone has any ideas on why this is happening or how I can debug this it would be appreciated. Thanks
Please run the WebApi from IIS individually and check the error.
Please check the file size while downloading because you need to
configure in webconfig file, if exceed default configuration.
Please check in Angular you have subscribe to that observable.
If you can give more details on this. It can help us to provide
more information like specific error and so on.....

Webservice URL appends port when adding a reference in my application

I have developed a simple .asmx webservice and hosted it on my server. The local machine url of the service is http://192.168.1.34:1115/webservices/verify.asmx.
I have given this a public IP so we can access it from anywhere like http://104.32.43.21/webservices/verify.asmx
when I hit the public url from my browser it works fine and the service page shown.
But when I try to add a reference of this service in my asp.net application, the port number 1115 gets appended to the service url and it shows an error in downloading the wsdl file from the server saying unable to resolve the host.
can someone tell me what is happening here and how can I access the webservice.
Thanks
There was problem in the way I was trying to add the service reference to my application. When ever adding an ASMX service reference add it with appending ?wsdl at the last of the service URL.
For my case it should have been like: http://104.32.43.21/webservices/verify.asmx?wsdl.

Accessing a WSDL web service that requires a Header from a .Net solution client

This is going to be a bit long so please bear with me.
I have been beating my head against this issue for quite some time. I am not very experienced in web services from a client and am having real issues setting this up. What I have is a web service from a third part hosted on a site. The service is a WSDL service written in JAVA. I am trying to connect to it from y .NET solution and consume the web services provided. One of the requirements from the vendor is to "set the Headers parameter to 'XXXX' and the value to 'YYYY'"
I am having some serious issues doing this. My first attempt was to simply add the web service as a web reference in Visual Studio (2012). There were no methods exposed by the service to set the header so I simply called a function to see what happened. I received an exception "No SOAP Headers specified".
Next I attempted to create a manual proxy using SVCUTIL.exe. I think there may be something wrong with the web services because I receive errors "Cannot import wsdl:binding": "Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled."
However, the class and config files are still created. Anyways, I imported the class into my web app and updated my web.config with the necessary settings from the proxy config. I declare an instance of the needed class and this is where things go south for this attempt. When declaring an instance of the class I receive the error "could not find default end point element that references contract "ContractName" in the ServiceModel client configuration. This might be because no endpoint element matching this contract could be found in the client element". I am wondering if perhaps there is a problem with the services or they simply weren't designed for .NET. The other obvious option is I am doing something wrong. I would be happy to post the config file and such if you would like to see it (I just felt I had loaded this post enough as it is).
What I am really looking for is instructions (a tutorial would be awesome) on how to add a web service as a reference within Visual Studio c# application but being able to set the headers from within the code.
I am sorry for the length of this post.
Thank you for your help.

deploying precompiled WCF REST service error "service not defined"

I created an ASP.NET REST service (using WCF) and access it through one of my .aspx page.
the problem is that when I publish (precomile) my code to the web server, I get an error :
"ThunServ not defined" in the Javascript console of my browser.
don't know what's causing it and how to solve it.
It means that the WCF service isn't initializing correctly, and so the client-side object that represents it isn't being created in Javascript.
Make sure your web.config contains the proper bindings and endpoints for the service. Then try testing its ASMX file on the server to see if you can get the client-side script to generate, e.g. http://myserver/myapp/myservice.asmx/js. If it doesn't generate, you should get an error (you'll need to turn on debugging in the web.config to read it) telling you what went wrong.

Categories