Reputation: 57
I have added asmx web service in my project using Connected Services in Visual Studio 2017. Proxy is generated properly. This is the URL http://secure.smartbearsoftware.com/samples/testcomplete10/webservices/Service.asmx?WSDL
. I am using ASP.NET Core 2.0.
How can I use the service in my controller. I want to call HelloWorld. I try to create instance but no success. Anyone?
I tried like var service = new SampleWebServiceSoapClient();
. That's the Question. How?
Upvotes: 1
Views: 2252
Reputation: 11514
It appears to simply require an enumeration that states the SOAP version you want to use:
var client = new ServiceReference1.SampleWebServiceSoapClient(EndpointConfiguration.SampleWebServiceSoap12);
var res = await client.HelloWorldAsync().ConfigureAwait(false);
However, I'm not sure about the support for System.ServiceModel in Core 2.0. Don't they have a modern API?
Update
It works with this NuGet package: System.ServiceModel.Http
Upvotes: 1
Reputation: 29
I think this is what you might be looking for.
class Program
{
static void Main(string[] args)
{
var client = new ServiceReference1.SampleWebServiceSoapClient();
string result = client.HelloWorld();
Console.WriteLine(result);
Console.ReadKey();
}
}
Upvotes: 1