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

Compatible with .NET Core 3.1? #373

Closed
GarryGibson opened this issue Dec 10, 2019 · 20 comments
Closed

Compatible with .NET Core 3.1? #373

GarryGibson opened this issue Dec 10, 2019 · 20 comments

Comments

@GarryGibson
Copy link

We've just updated our project from 2.2 to 3.1 as it's the LTS version, and all our responses are now coming back empty:

<s:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body />
</s:Envelope>

No errors or exceptions, just empty. I can see the custom response being correctly built up, but by the time the IMessageInspector2.BeforeSendReply() gets it, the reply is empty, as above.

@kotovaleksandr
Copy link
Member

Hi! Its very strange, i didn't have time to use 3.1 in real application, but SoapCore tests passed without any error:
image

Attach sample of project, i see them.

@rasmk
Copy link

rasmk commented Dec 10, 2019

I have just tried to set up a fresh project. For me it does not compile at endpoints.UseSoapEndpoint. Supposedly because #if ASPNET_30 in SoapEndpointExtensions.cs does not match ASP.NET 3.1.
If I use app.UseSoapEndpoint, it does compile. But then in runtime I get

System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Http.Internal.BufferingHelper' from assembly 'Microsoft.AspNetCore.Http, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
   at SoapCore.SoapEndpointMiddleware.Invoke(HttpContext httpContext, IServiceProvider serviceProvider)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at SoapCore.SoapEndpointMiddleware.Invoke(HttpContext httpContext, IServiceProvider serviceProvider)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass4_1.<UseMiddleware>b__2(HttpContext context)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

@kotovaleksandr
Copy link
Member

Tomorrow i will publish new version with support 3.1 to nuget

@kotovaleksandr
Copy link
Member

https://www.nuget.org/packages/SoapCore/1.0.0-alpha.3

@snapfisher
Copy link

I am using 1.0.0-alpha3, with an out of the box brand new project. Following the instructions in the readme, I get this:

System.InvalidOperationException: 'Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddRouting' inside the call to 'ConfigureServices(...)' in the application startup code.'

All I am doing in ConfigureServices is:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSoapCore();
        services.AddSingleton<IWeatherService, WeatherService>();
    }

Where WeatherService is just a class that returns a string.

@kotovaleksandr
Copy link
Member

@snapfisher Hi, maybe need add to Startup UseRouting and UseEndpoints calls?

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
	app.UseRouting();
	
	app.UseEndpoints(endpoints => {
		endpoints.UseSoapEndpoint<ServiceContractImpl>("/ServicePath.asmx", new BasicHttpBinding());
	});
    
}

@snapfisher
Copy link

I already did that. I went back to the README and followed it exactly. Although, for ServiceContractImpl, I used the interface, not the service. Reading it now, maybe it should have been the other way around. I'll check it later today. Other than that, it matched the instructions.

@BorisVezhyk
Copy link

BorisVezhyk commented Dec 12, 2019

https://www.nuget.org/packages/SoapCore/1.0.0-alpha.3

Hi @kotovaleksandr, I have one problem with DeserializeInputParameter. In the previous version (0.9.9.6) stable worked Deserialize, the current version works wrong. There is a problem with namespaces object. After I analyzed your code, I found the problem:
version 0.9.9.6

string parameterNs = inParameter.Namespace ?? operation.Contract.Namespace;

Type parameterType = inParameter.Parameter.ParameterType;

objArray[inParameter.Index] = !(parameterType == typeof (HttpContext)) ? this.DeserializeInputParameter(xmlReader, parameterType, inParameter.Name, parameterNs, inParameter) : (object) httpContext;

version 1.0.0:

Type parameterType = inParameter.Parameter.ParameterType;

 objArray[inParameter.Index] = !(parameterType == typeof (HttpContext)) ? this._serializerHelper.DeserializeInputParameter(xmlReader, parameterType, inParameter.Name, operation.Contract.Namespace, inParameter) : (object) httpContext;

If we have different namespaces contract and object which we want deserialize, our object will not deserialized. And we get request with null.

@kotovaleksandr
Copy link
Member

Hi @BorisVezhyk. Can you describe your model? Service have one namespace, but method arguments model another namespace? This problem not related to .NET Core 3.x, its application code issue.

@snapfisher
Copy link

I changed the call to use the service directly, and it still fails. It fails here:

    private static void VerifyRoutingServicesAreRegistered(IApplicationBuilder app)
    {
        // Verify if AddRouting was done before calling UseEndpointRouting/UseEndpoint
        // We use the RoutingMarkerService to make sure if all the services were added.
        if (app.ApplicationServices.GetService(typeof(RoutingMarkerService)) == null)
        {
            throw new InvalidOperationException(Resources.FormatUnableToFindServices(
                nameof(IServiceCollection),
                nameof(RoutingServiceCollectionExtensions.AddRouting),
                "ConfigureServices(...)"));
        }
    }

And for completeness, my entire Startup.cs file looks like this:

namespace WeatherSoapApi
{
public class Startup
{

    // Note, I could not get SoapCore to work



    // This method gets called by the runtime. Use this method to add services to the container.
    // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSoapCore();
        services.AddSingleton<IWeatherService, WeatherService>();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseRouting();

        app.UseEndpoints(endpoints => {
            endpoints.UseSoapEndpoint<WeatherService>("/ServicePath.asmx", new BasicHttpBinding());
        });
    }
}

}

@kotovaleksandr
Copy link
Member

@snapfisher enable MVC in ConfigureServices:

services.AddMvc();

@snapfisher
Copy link

That does not fix the problem. I tried in all three positions in the method. I get this failure from SoapCore. It seems to start fine, the failure is when I try and hit http://localhost:port/ServicePath.asmx. I tried with Kestral and IIS Express.

Image of the stack trace on failure....

image

@kotovaleksandr
Copy link
Member

@snapfisher Your service interface have ServiceContract attribute?

@BorisVezhyk
Copy link

BorisVezhyk commented Dec 14, 2019

Hi @BorisVezhyk. Can you describe your model? Service have one namespace, but method arguments model another namespace? This problem not related to .NET Core 3.x, its application code issue.

@kotovaleksandr I need to create a new service, but it must work with old working clients. And clients send the next xml request. For example,

<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Status xmlns="http://www.somesite.com/fax/">
<Parameters xmlns="http://xxx.company.yyy.Applications.Fax.Core.Schemas.StatusRequest"><TokenName xmlns="">1</TokenName>
<TokenID xmlns="">1</TokenID>
<RequestID xmlns="">1</RequestID>
</Parameters></Status></s:Body></s:Envelope>

I use the next contract.

[ServiceContract(Name = "EntryPoint", Namespace = "http://www.somesite.com/fax/")]
	public interface IFaxService
	{	
		
		[OperationContract]
		void Status([XmlElement(Namespace = "http://xxx.company.yyy.Applications.Fax.Core.Schemas.StatusRequest", ElementName = "Parameters")]StatusRequestParameters part);
	}

And it works in 0.9.9.6 and mapping correct, but does not work in 1.0.0....

So, I found one more problem with deserializing base64 string in 1.0.0.0((

@kotovaleksandr
Copy link
Member

@BorisVezhyk Boris, please, create two issues: about problem with namespaces (i'm already reproduce this problem, work in progress) and about base64 string.

@BorisVezhyk
Copy link

BorisVezhyk commented Dec 16, 2019

@BorisVezhyk Boris, please, create two issues: about problem with namespaces (i'm already reproduce this problem, work in progress) and about base64 string.

I created the second issue here #380. and described where a problem.

@rasmk
Copy link

rasmk commented Dec 17, 2019

For me alpha3 works fine in the new clean project. Thanks a lot Alexander.
I used service from the SampleService.cs.
I just needed to mark the class with ServiceContract and methods with OperationContract. Perhaps it is worth to update the sample and put the attributes there?

@kotovaleksandr
Copy link
Member

For me alpha3 works fine in the new clean project. Thanks a lot Alexander.
I used service from the SampleService.cs.
I just needed to mark the class with ServiceContract and methods with OperationContract. Perhaps it is worth to update the sample and put the attributes there?

SampleService already have attributes:
https://github.com/DigDes/SoapCore/blob/develop/samples/Models/ISampleService.cs

@rasmk
Copy link

rasmk commented Dec 17, 2019

Missed the interface. All is perfect. Thanks.

@KamranShahid
Copy link

@snapfisher enable MVC in ConfigureServices:

services.AddMvc();

does it required in .net core 3.1?

CameronS29 pushed a commit to CameronS29/Soap-.NET-Core that referenced this issue May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants