New Web Api methods not recognized only when web api is online - c#

I have a Web Api, I don't know why when I add new methods to it and I put my Web Api online the new methods are not recognized, if I run the application locally the methods are recognized, I'm using somee.com to upload and run my application online, for example if I just add this simple method:
[HttpGet]
[System.Web.Mvc.ValidateInput(false)]
public IHttpActionResult TestJustGet()
{
var x = "new method tested";
return Ok(x);
}
and I run the application locally it is recognized(http://localhost:62852/api/people/testjustget)
But when I try to call that method with the online application is not recognized(http://testwebhook.somee.com/api/people/testjustget) and I get this error:
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://testwebhook.somee.com/api/people/testjustget'.
</Message>
</Error>
I think that the problem is that the online application it's not recognizing the new changes, maybe I'm not updating it the best way. What I am doing to update my application is delete the old one that I have online, and instead upload the new application with the new methods added, but those methods are not being recognized, what can I do?

It seems that I need to run locally my application first and then upload it to somee.com, after I began to do that, it has recognized all the new methods, I run it locally and try all the new methods locally first and then I upload it and works

Related

My web service operation call only opens test page in IIS - I am not sure how to call the operation to return my xml

I am new to web services.
I have built a web service in C# that consumes a third party service and then returns the XML response from that call in a web method.
When I test this in IIS on the local web server it works perfectly.
However when I try to call or invoke the service via the URL I use on the test page I can't return a response.
If I use a GET I simply get the test page loading and the message I can't use this test page outside of the local server.
In short, I simply want to know how to call the web method externally and mimic the INVOKE button being pressed so I get the response passed back.
This is probably really simple but I can't get my head around it.
In addition if I use Postman to try and call the URL:
WebService.asmx?op=GetSalesOrders
I get the error message detailed below which is a step forward but I am still unsure about how to package up a call to this service
You call the service by making a POST request with a properly formated SOAP message to this URL:
<path>/WebService.asmx
You get the WSDL of the web service by making a GET request to this URL:
<path>/WebService.asmx?wsdl
You can use that WSDL to build a client or test the service with something like SoapUI. See this and this for more details.
That invocation page or URLs with parameters like this:
<path>/WebService.asmx?op=GetSalesOrders
are just provided for convenience to allow you to poke at the service and make sure the service is running. They should not be used in "real" calls.

Why do downloads from firebasestorage URL fail when called from IIS context?

I am getting a strange behavior when trying to download files from my web service.
My web service is a .net service based in IIS. One task it has is to retrieve images from URLs that are given as a part of its workflow. This generally works. We have a new requirement to support downloads from firebasestorage URLs. This seems pretty straightforward, but for some reason, it doesn't work when the IIS-based web service tries to download.
If I use the same code in a standalone application, the download works fine. The error is a response from the googleapis, so there must be some difference in the way the call is made, but I don't see what it is.
The basic code looks like this (client specific information is scrubbed):
using (WebClient wc = new WebClient())
{
Uri uri = new Uri("https://firebasestorage.googleapis.com/v0/b/hidden.appspot.com/o/images%2F20182248141Image.jpg?alt=media&token=******-474d-4693-a36c-dfee***cb9c4");
wc.DownloadFileAsync(uri, #"c:\temp\Image.jpg");
}
If I run the above snippet in C# interactive window or in a standalone app, the file will download.
If I run the snippet with the context of IIS, then the WebClient reports: The remote server returned an error: (400) Bad Request.

HTTP Request in Xamarin.Forms

I'm building a Xamarin.Forms App for Android and iOS which is supposed to consume an API. The API is kind of built in a REST spirit, I'm hosting the API on a local IIS Express server and my Android emulator has no problem finding it (tested on various endpoints and I can also display the api-doc).
I'm trying to get in touch with a http://IPOfMyComputer/api/Stuffs endpoint which gives me a JSON list of Stuff. Using Postman I successfully get all the stuff I needed, a valid auth token in that case, to build a proper HTTP GET request. I'm using the Microsoft.Net.Http NuGet package to build this request as it seemed to be the proper tool to do the job. I'm doing this request building process in Xamarin.Forms "Main" project (not the iOS or Android one, the other one which I don't know how to name which is automatically by Visual Studio).
My code looks like this:
var rootUri = "http://IPOfMyComputer"
var requestedUri = "/api/Stuffs"
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",
"blablabla");
var response = await client.GetAsync(rootUri + requestedUri);
And this gives me an error "NotSupportedException" on the last instruction.
I'm clueless here so some help would be really appreciated.
Edit
The proper error message is
"System.InvalidCastException: Specified cast is not valid."
I found the source of that error:
Turns out it wasn't directly linked with the GetAsync method but with some mess in the code related with async/await use.
There was a bunch of crappy code everywhere. I dropped it all to go back to a regular MVVM logic and I put the async/await logic into methods invoked by eventhandlers (instead of trying to "create" an async builder for a class...).

Not sure how to construct a URL to call a web service method

I have just written my first SOAP web service. It's fairly simple. It just runs Powershell scripts or functions in a couple different manners. My problem is that I'm not sure how to construct a URL to call my methods. I'm sure it's just due to my inexperience with web services.
The method definition is RunPowershellScriptWithArgsExportJson(string scriptPath, string[] scriptArgs). The scriptPath is a local path like C:\Scripts\Testing.ps1. scriptArgs could potentially be anything.
I've verified that I can see the xml response in a browser by entering the path to the asmx. It was similar to http://PCName.com/PsWebService/ServiceName.asmx. (We're only using this service on our internal network so I'm using the computer name instead of a domain name in the URL)
I can also invoke the methods from remote computers with Powershell and its New-WebServiceProxy cmdlet, but that doesn't require a URL that includes method calls. So the web service appears to work. I'm just not sure how to call it in a URL which is ultimately what I need.
Could someone provide me with an example of a URL that would work to call my RunPowershellScriptWithArgsExportJson method correctly? I've tried several things and also read a few blogs and tech articles, but so far I'm just getting random URL exceptions on everything I try.

I am trying to consume a PHP SOAP service from C# and create a class wrapper in VS 2010

I've been tasked with creating a class wrapper for a SOAP service, the idea is that you'll be able to treat it as a regular class. The main reason for this is that the WDSL for the SOAP service contains only one method and it's got 5 parameters and it's only kind of OO so you'd have to know all the method calls really well and it's a bit hard to remember them all.
OK, so I've tried adding a web reference, now web references can now be added as service references in VS 2010. You click add service reference advanced etc and it puts in a service reference. Great. Unfortunately if I try and access this from a class I can't.
I can build a console app and put code in the main procedure and access the method of the SOAP service fine but when I add a reference to a class library the intellisense won't allow me to select anything. I'd instantiate an instance like so:
SOAPService.webServiceService ws = new SOAPService.webserviceService();
ws.
and then the intellisense refuses to kick in. If I do the same in a web project or a console app then I can access it fine. I've added the namespace I've done all kinds of things. Also, I can add a web reference and get a DISCO file whenever I create a web project.
OK, also while I'm on the subject I also need to pass credentials to the web service in PHP.
The problem is that in the past I'd create some .net system credentials and add these and it would usually pass through if I was connecting to another .net service.
How should I be sending them to a PHP web service? I always get either invalid username/password combo errors or envelope malformatted error types
Thanks
Mr. B
So the intellisense is not working, but if you add the method in and try to use it does it work, or produce an error?
With regard to diagnosing authentication issues try using fiddler to view the SOAP messages that are being sent, and to view the reply. Do you have some other software that connects and authenticates to that service? Use fiddler to look at the SOAP messages and compare them to see if the header is different etc.
I'd normally do it like this,
using (Service service = new Service())
{
service.ClientCredentials.Windows.ClientCredential.Domain = "domain";
service.ClientCredentials.Windows.ClientCredential.Password = "password";
service.ClientCredentials.Windows.ClientCredential.UserName = "username";
}
Also with regard to the service working or not in general use fiddler if you have any problems, you can see the SOAP messages and it often gives you a clearer message.
I know in IIS you can turn on failed request handling that also gives you an insight from what is going on at the server end, perhaps you have some form of logging too for your php service?

Categories

Resources