Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request model is coming as null #1104

Open
ankush-source opened this issue Dec 16, 2024 · 3 comments
Open

Request model is coming as null #1104

ankush-source opened this issue Dec 16, 2024 · 3 comments
Labels

Comments

@ankush-source
Copy link

ankush-source commented Dec 16, 2024

I am adding SoapCore as below in Program.cs using .Net 8 API project

`var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSoapCore();
builder.Services.TryAddScoped<IAddressValidationSOAP, AddressValidationSOAPService>();

var app = builder.Build();

var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

// Configure the HTTP request pipeline.

app.UseHttpsRedirection();

app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
// SOAP endpoint
_ = endpoints.UseSoapEndpoint("/AddressValidation.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
});

app.MapControllers();

app.Run();
`

But in my service AddressValidationSOAPService.cs, request model SOAPValidationRequest is coming as null, please suggest.

public async Task<SOAPAddressResponseDto> IsValidAddressV2Async(SOAPValidationRequest request)

I am using DataMember attributes and (xmlns:soap) property also matches with the model namespaces.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://www.myapps.com/HISERV/AddressValidation/SOAP">

`[DataContract(Namespace = "https://www.myapps.com/HISERV/AddressValidation/SOAP", Name = "VldnRqs1")]
public class SOAPValidationRequest
{
[DataMember(IsRequired = true, Name = "AppId")]
[XmlElement(ElementName = "AppId")]
public required string ApplicationId { get; set; }

[DataMember(IsRequired = true, Name = "AppKey")]
[XmlElement(ElementName = "AppKey")]

public required string ApplicationKey { get; set; }

[DataMember(Name = "Ctx")]
[XmlElement(ElementName = "Ctx")]

public string? Context { get; set; }

[DataMember(IsRequired = true, Name = "MxMtchCnt")]
[XmlElement(ElementName = "MxMtchCnt")]

public required int MaxMatchingAddressCount { get; set; }

[DataMember(IsRequired = true, Name = "Addr")]
[XmlElement(ElementName = "Addr")]
[JsonPropertyName("Addr")]

public required SOAPAddressRequestDto Address { get; set; }

}`

@SpodoY
Copy link

SpodoY commented Jan 15, 2025

Sorry to be of no help but I ran into the same Issue - My request consist of one object which I try to parse but it always results to null - I already tried SoapSerializer.XmlSerializer and SoapSerializer.DataContractSerializer but both didn't work.

What I noticed in my WSDL was that SoapCore seems to expect only a single parameter of my object instead of the previously required multiple parameters. I thus tried to add [MessageContract(IsWrapped = false)] to my Data-Class but without success.

It would be nice if this issue got some attention

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Feb 15, 2025
@ShelestSergey
Copy link

ShelestSergey commented Feb 27, 2025

In my case problem was in DataMember description.
I've added "Order" in DataMember description.

[DataMember(Name = "name", IsRequired = true, Order = 2)]

and sent soap with attributes in direct order.
and one more thing. In interface method definition name of input parameter have to be the same as name of contract.

        [ServiceContract(Name = "dc", Namespace = "http://schemas.datacontract.org/2024/07/method")]
        public interface IUnitService
        {
            [OperationContract(Action = "postUnit", Name = "postUnit")]
            Task<Bonning> PostUnit(Bonning dc);
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants