Closed wolfen351 closed 9 years ago
@wolfen351 can you please elaborate exactly what breaks when you try and compile?
There is an interface called something like IActionResult that is referenced in many places in the generated code, it requires this using statement..
The responses need to be concrete, so you cannot implicitly return
interfaces. To get around this problem, decorate each applicable method
(endpoint) with the ResponseType
attribute and explicitly pass in the
returned type without changing the actual signature of the method.
When you do this, WebApiProxy will then use the specified concrete type instead of the abstraction, meaning no dependency on System.Web
Hope this helps?
Hi there
You misunderstand.. I have a c# class library project that I'm using as a webservicecommunicator.dll. This class library has the WebApiProxy nuget package installed, and it happily communicates with the server and generates the code. However the code that is generated, does not compile. All I need to change to make it compile is to switch the auto generate on build in the config xml off, and then add 1 more using statement to the header of that file.
Inside the generated code, all the references to HttpResponseMessage are unknown.
For example in line 347 of the template: WebApiProxy.Tasks/Templates/CSharpProxyTemplate.cs:
this.Write("\t\t///
That HttpResponseMessage is only available if the line using System.Web.Http; is at the top of the same file.
Do I make more sense now?
That is odd indeed and should not happen. Is it possible to recreate this scenario in a sample project and share it so we can find the real cause of the problem?
On Sat 29 Aug 2015 at 07:17 wolfen351 notifications@github.com wrote:
Hi there
You misunderstand.. I have a c# class library project that I'm using as a webservicecommunicator.dll. This class library has the WebApiProxy nuget package installed, and it happily communicates with the server and generates the code. However the code that is generated, does not compile. All I need to change to make it compile is to switch the auto generate on build in the config xml off, and then add 1 more using statement to the header of that file.
Inside the generated code, all the references to HttpResponseMessage are unknown.
For example in line 347 of the template: WebApiProxy.Tasks/Templates/CSharpProxyTemplate.cs: this.Write("\t\t/// \r\n\t\tTask ");
That HttpResponseMessage is only available if the line using System.Web.Http; is at the top of the same file.
Do I make more sense now?
— Reply to this email directly or view it on GitHub https://github.com/faniereynders/WebApiProxy/issues/56#issuecomment-135942667 .
What version of WebApiProxy.CSharp are you using? I have just tried to reproduce the issue by creating a sample WebApi project with an action returning a HttpResonseMessage
. On the client side I have a console app and it seems to generate just fine. However, the HttpResponseMessage
that needs to be used is not sourced from System.Web.Http
, but from System.Net.Http
instead. See here https://msdn.microsoft.com/en-us/library/system.net.http.httpresponsemessage(v=vs.118).aspx. Hope this helps?
Ok, time for me to eat humble pie. In the process of making the example projects you asked for we discovered that we were including the standard MVC accountcontroller in the webapi server solution and this was causing all the weird references to be required. Removing this controller (which we dont use anyway) made the code compile and work 100% . :)
Hi there
I have a bit of an odd situation, when I include all this in a standalone class library, I need to manually add the using each time I update the code (to get it to compile). It would be really nice if it was part of the template.
Thanks!