How to ignore ResponseWrapper in ASP.NET Core Web API response - asp.net-core

I have an web api project in .net core and in Startup there is configured to use a response wrapper "
app.UseResponseWrapper();"
But this format is applied for all the api methods in my project...
I want an api method in my solution that sends another format response , for example a simple xml. I want to know how to ignore that Response wrapper that is applied for all methods? Is there any decorator for that method ?

I solved my issue.
I had built a custom decorator for methods that is able to modify header response.
In the Response wrapper I succeded to manage and to modify the response

Related

ASP.NET Core multi attribute routing

In my ASP.NET Core Web API application, I have declared a route with multiple attributes like following
[HttpGet]
[Route("{tenantId?}/user/getsettings/{id?}")]
When I made a request from swagger, the server is returning 404 not found.
http://localhost:5163/api/1/user/getsettings/2
Is this possible with .NET Core?
Because your url actually not contains api. You can call url by using http://localhost:5163/1/user/getsettings/2. If you want to add api to your url you can add attribute to controller class by using [Route("api/v{version:apiVersion}/[controller]")].
Tip: You can achive same config with only one HttpGet("{tenantId?}/user/getsettings/{id?}") attribute.

WebApi Core 2.2 OData resource/path not found

I'm using WebApi Core 2.2. The Microsoft OData Client is adding a new parent record plus a subrecord (Deal+DealFee) from a WPF application. I'm hosting in IIS on Windows 10.
When I call container.SaveChanges(), it successfully calls the service to add the parent Deal record, but then it does a SECOND POST operation to this url (this is generated by the MS odata client lib):
POST http://localhost/mysite/odata/Deals(14)/DealFees
(note this includes the ID 14 which was just generated when adding the Deal)
This is two separate POSTs from the MS odata client lib, not a "deep insert" apparently. However, this results in a 404 (NotFound), which I can observe in Fiddler. The following urls DO work perfectly:
/odata/Deals
/odata/Deals(14)
/odata/DealFees
It seems like either the WebApi Core 2.2 service is not handling the POST to /Deals(14)/DealFees path, OR /Deals(14)/DealFees isn't a valid odata Uri? Is this kind of path generally supported in OData?
I don't know. Can anyone shed some light on what's going on?
Deep insert is not supported in WebAPI OData as of now. To me, it seems like the client is updating the resource set and the resource set for the navigation with two separate post requests and the reason you are getting a 404 is that there is no action mapped to the second request URI in the service.
The service can support this either by introducing a PostToDealFeesFromDeals controller action with default OData routing convention or use attribute routing to map the action for such requests.
If the action already exists then it might be that the first request did not finish creating the new record and the second request was fired, hence 404.

How to change response format of App Services in ASP.NET Boilerplate (ASP.NET Core)?

I want to change app service's response content-type from application/json to application/xml. One solution I come across is this but it didn't explain how to configure ABP and use Xml Formatter. Can anyone please explain how to configure ABP for this package i.e Microsoft.AspNetCore.Mvc.Formatters.Xml. Simply installing this package and configuring startup.cs file with services.AddMvc().AddXmlSerializerFormatters() didn't work. I think ApplicationCoreModule has to be configured. Btw My app service is returning a list of objects.
Here are the images of Results when I execute API in Swagger:
Request Image
Response Image

How to invoke MobileFirst adapters with curl and SOAP?

Good day,
We have the requirement to call a MobileFirst Adapter via curl and SOAP, ommiting authentication.
An example how to do it with curl and application/x-www-form-urlencoded looks like this, but we also require to invoke the adapter using SOAP.
curl -XPOST -d 'adapter=PushAdapter&procedure=sendNotifications&parameters=["[\"UserA\",\"UserB\"]", "Pushed.you"]' http://localhost:10080/application/invoke
The reason is, we want to trigger sending PushNotifications through a network zone that only allows SOAP.
We are open to different suggestions, like implementing a new JavaAdapter (not JS), implementing an extra WebService, or anything that pops up which could fulfil the requirement in an acceptable way.
I hope someone can come up with an idea how to call Adapters via SOAP, ommiting authentication.
Thank you,
gizmore
---- Edit ---
I added a new Java Adapter, like the video from Hasan suggests.
Thank you very much for that hint :)
There i added a WebService like this:
#WebService
#Path("/soap")
#OAuthSecurity(enabled=false) // Disable the imfAuthentication :)
public class ExternalPushService {
#POST
#Path("/push")
#WebMethod(action="push")
public String push(#WebParam(name="name") String name) {
return name + "ABC";
}
}
I can now do HTTP POST Requests to the http://localhost:10080/app/adapters/PushBridge/soap/push Endpoint, but the SOAP is not parsed.
Instead i get the complete Envelope in the "name" parameter.
If i do a SOAP call to PushBridge/soap, i get 405 Method not allowed.
Does someone have an idea, how i can get SOAP working out of the box there?
Answer is: NO
when you adding #WebService in your java adapter this the warring facing:
Problem description:This annotation requires a web service project. Convert the Java project to a web project targeting the specified runtime environment
SOAP base service are based on the JAX-WS specification.
but
Java adapters are based on the JAX-RS specification.
https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/server-side-development/java-adapter/

ServiceStack not URL decoding route parameter in RESTful route

I'm using self hosted ServiceStack to provide an API to integrate with a ticketing system, and have defined the following routes:
Routes
.Add<TicketsWithStatus>("tickets/{Status}")
.Add<TicketStatusCounts>("tickets");
I'm having URL encoding problems with the first route when the status contains a space. If I browse to http://myservicebase/json/syncreply/TicketsWithStatus?Status=On%20Hold I get the response I'm expecting. However, if I use the RESTful route http://mysevicebase/tickets/On%20Hold I don't get any results.
Debugging my application, I can see that the On%20Hold is being URL decoded to On Hold in the case of the json/syncreply call, but is not decoded when using the RESTful route.
How can I ensure that the status property is properly decoded when calling my service via the RESTful route?
ServiceStack doesn't UrlDecode the PathInfo, it uses the same HttpRequest.PathInfo that the ASP.NET Request object returns. You might have better success if you change it to On+Hold.