How to call WCF svc with URL and parameters as a GET - wcf

I have a simple WCF I am working on. I am used to .asmx files, web methods and SOAP but switching it up now. Got it working in .aspx page with a script manager and ServiceReference like below
<asp:ServiceReference Path="~/MyTest.svc" />
A coworker now needs it so he can call it in an iOS app (don't know much about that) but he says he needs to call it with the URL passing the parameters as a GET. Can you please tell me how to alter the .svc file to make that possible?
Many thanks!

Related

Visual Studio Code only offers Weather Forecast proxy

I am not able to run any other controller in the default React app for .NET Core 6.0. Has anyone figured this out? I believe I saw a quick message on the terminal about the weatherforecast route being in the SPA proxy.
Whenever I try to go to any other route for a controller it redirects to the fallback page. I have routing setup with default settings. Just seems an odd behavior.
It's obviously a proxy issue because if I run the controller from the IIS port 7132 instead of the 44402 (spa server), I am able to retrieve the json response. There's quite a long readme file in here I can plod through but maybe someone has a better solution.
Update: I found the solution, well there were several, from setting CORS policies on the server side, etc. The easiest way was to do it "pre-flight". I found a handy file called setupProxy.js (who knew lol), where I was able to set an array of end points to proxy. And this had the /weatherforecast endpoint already specified. So now it all works! I guess I answered my own question.
const context = [
"/weatherforecast","/account"
];

Get glimpse working with web api

I have an MVC4 project with the template Intranet Application. Glimpse is working on the MVC4 Routes but not on web api routes (the footer vanishes).
I'm thinking of creating an action in a MVCController which takes a request as parameters to instanciate the right WebApiController and calls the right action with the parameters.
Is there a better alternative ?
I tried to use this (found here) but it doesn't work :
<inspectors>
<ignoredTypes>
<add type="Glimpse.AspNet.Inspector.RoutesInspector, Glimpse.AspNet"/>
</ignoredTypes>
</inspectors>
</glimpse>
The issue you mention is related to Glimpse making changes to the Routes configuration which broke the WebApi Help Pages, fortunately that issue has been solved in the meanwhile.
Based on your question, I assume that you want to see Glimpse diagnostics for WebApi related calls? Unfortunately Glimpse v1.8.4 does not support WebApi requests.
The good news is that support for WebApi is being added as we speak. You can check the pull request to see how it's going and when it's expected to be released.

WCF Global.asax events not firing

I have built a WCF application which has Global.asax file. I have added AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)
on top of service class and added
into web.config as well.
Global.asax Application_Start event fires when debugging the application but when it deployed in the IIS7 its not firing.
Any help or idea?
Thank you.
If you make a request to your app does the "Application_Start" fire then? I don't believe it will be started until the first request is made.
Application level events only need proper naming to work. Is your codebehind class being designated in your Global.asax file?
<%# Application Inherits="YourNamespace.YourApplicationClass" Language="C#" %>
(Or)
becuase project is compiled first and then you have add or modify or changed location of global.asax.cs.
Solution :- Just remove debug folder. Clean project and then rebuild whole project.
Edit
When using the response object from an aspx page, its codebehind class or a
user control, the response object is directly available because all these
derive from the page object.
When using the response object in your own class, the object is not
available, but you can access it:
HttpContext.Current.Response. -> something
Take a look at here
Global ASAX - get the server name

Web API Routing - Returning 404

I have a Web API project in MVC 4 but cannot find the URL to my web service. Rather than MVC, I am actually just using the C (controller) as I'm not returning a view and my model is located in an external project.
I'm using the default route, which is api/{controller}/{id}. The name of my controller is RESTController (I know, probably wasn't the best name) and is located at ~/Controllers/RESTController.cs
Based on naming convention, it seems that my web service should be located at localhost:port/api/REST but I'm just getting a 404 resource cannot be found error (no XML representation of the object returned or anything). Is this the expected behavior without a view?
The funny thing is that I also have a SOAP API in an external project that is actually just returning the REST API result and it works as it should. Doing unit tests on my methods passes... I just can't access it from a browser. I've tried every url imaginable.
Basically...
Would there a way to debug this? (ie. Turning on ASP.NET directory listing)
Does not having a view effect what is shown in the browser?
Shouldn't the browser return an XML file representing the object?
Am I missing something obvious?
Nevermind, I'm a moron. I found the problem... At some point I accidentally drag and dropped (drug and dropped past tense?) my Global.asax file into my Views folder... therefore my routes were not getting registered.
Working as intended now.

How to serve files and html directly from a WCF-service similar to an ASHX-handler?

Im writing an install and update-server for an intranet-application and I want the user to be able to install the app directly from a url such as: http://domain.local/myapp/install.exe where this request is handled by my service.
I also would like to be able to serve some basic HTML on for instance http://domain.local/myapp/status.html which is generated on the fly by my WCF-service.
Is this possible? Im using a self-hosted WS-binding WCF-service with .NET4/VS2010 on WS2008R2.
Ive found the solution! WebGet in System.ServiceModel.Web. I had to change the project target from .NET 4 Client to .NET 4 for the System.ServiceModel.Web.dll to turn up in "add reference"