Facing issue with custom response in dot net core 8.0 service.

Bhuvaneswari Vinayagamoorthi 0 Reputation points
2025-05-09T12:25:30.0733333+00:00

Hi Team,

This question is continuation of (https://learn.microsoft.com/en-us/answers/questions/2236081/http-response-body-content-needs-to-be-set-from-so?page=1&orderby=helpful&comment=answer-2013060&translated=false&source=docs#newest-answer-comment) but since issue is related to local environment vs testing environment i am posting as a new one.

Background: My application was developed as soap service(asmx) in dotnet framework. In that response was set in its body with 'CurrentContext.Current.Response.WriteAsync("required content")' implementation.

Recently we migrated our soap service from dotnet framework to Dotnet core(8.0). Here we used 'SoapCore' nuget package to expose our service as soap from dot net core solution.

Issue: as suggested by above question link, i am currently returning as custom response as below. which is working fine in my local except additional namespace. but the same code i deployed in my testing environment, but i am not getting the response which i returned from my web method when i hit my testing environment endpoint as shown below.

Kindly help to resolve this issue.

Implementation:

 public object GetDestinationNumber(string sXMLData)
{
object resp = null;
resp = new DestinationResponseNA { destnum = sRoutingNumber.HtmlEncode(), ucid = sUcid.HtmlEncode() };
return resp ;
}

Local response:

<?xml version="1.0" encoding="utf-8"?>
<ctiresponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
    <icmind>0</icmind>
    <routenum>0079701</routenum>
    <string />
</ctiresponse>

User's image

Testing Environment response: empty as shown below.

User's image

Regards,

Bhuvana.

ASP.NET Core Training
ASP.NET Core Training
ASP.NET Core: A set of technologies in the .NET Framework for building web applications and XML web services.Training: Instruction to develop new skills.
69 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pradeep M 8,660 Reputation points Microsoft External Staff Moderator
    2025-05-09T13:00:33.4733333+00:00

    Hi Bhuvaneswari Vinayagamoorthi,

    Thank you for the detailed information. Since the code works as expected in your local environment but not in the testing environment, the issue is likely due to configuration or environmental differences. Here are some steps to investigate: 

    1.Configuration Consistency: Ensure that the SoapCore configuration is identical across both environments, particularly settings related to serialization and any middleware that may affect the response format. 

    2.Deployment Verification: Confirm that the same version of the code has been deployed to the testing environment. Occasionally, deployment discrepancies can result in behavior that differs from the local setup. 

    3.Namespace Management: To eliminate unwanted namespaces (e.g., xmlns:xsi, xmlns:xsd), consider setting the Namespace property to an empty string in your DataContract: 

    [DataContract(Namespace = "")]
    public class DestinationResponseNA
    {
        [DataMember] public string destnum { get; set; }
        [DataMember] public string ucid { get; set; }
    }
    
    

    4.Encoding Considerations: Verify whether HtmlEncode() is influencing the response in the testing environment. If necessary, adjust or remove the encoding method as needed. 

    5.Logging and Debugging: Enable logging in the testing environment to capture and compare the actual response being returned with your local setup. This may provide further insight into any discrepancies. 

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.