1 year ago
#379718
miketromba
Consuming SOAP service with NET 6 Blazor WASM - Error in ServiceModel.BasicHttpBinding
I'm working with Blazor WebAssembly in Net 6, trying to consume a web service SOAP. The Blazor app is configure to HTTPs, but the SOAP service no.
In the Reference.cs, there is a line where crash with an error:
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
And the error is:
The type initializer for 'System.ServiceModel.Channels.ChannelBindingUtility' threw an exception.
One part of the Reference.cs of the service is:
private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IMyService))
{
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
result.MaxBufferSize = int.MaxValue;
result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
result.MaxReceivedMessageSize = int.MaxValue;
result.AllowCookies = true;
return result;
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IMyService))
{
return new System.ServiceModel.EndpointAddress("http://MyService.svc");
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
private static System.ServiceModel.Channels.Binding GetDefaultBinding()
{
return MyServiceClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_IMyService);
}
private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
{
return MyServiceClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_IMyService);
}
public enum EndpointConfiguration
{
BasicHttpBinding_IMyService,
}
There is a chance to consume a SOAP service properly? Should I register the service in Program.cs?
Help!
Thanks in advance.
c#
soap
service
blazor
endpoint
0 Answers
Your Answer