简体   繁体   中英

Unable to authenticate soap web service when adding via Microsoft WCF Web service Reference Provider to .NET Core 3 console application

I'm writing a .net core (3) console application using visual studio 2019, and am trying to code against a soap web-service. However the soap web service requires authentication. I have been using the Microsoft WCF Web SErvice Reference Provider to [try to] connect to the service. It prompts me for my login credentials, but when I type them in, it just prompts me again [and again, and again]. Can .net core work with soap services? I am able to do this when I write a [very simple] proof of concept .net application on the same computer by adding a Web Reference to the application. However on the same system, I am unable to get it to work with .net core. Any help much appreciated.

thanks heaps,

David

The dialog is constantly prompted because the server enables the Windows/Basic Authentication. it doesn't matter when we generate the client proxy by using the Microsoft WCF Web Service Reference Provider.
One thing must be noted is that some bindings are not supported in the Asp.Net Core project. In order to check this result, first, we call the service in the Asp.Net framework console application (it absolutely supports WCF) and then check the automatically generated configuration file. the binding and authentication mode in the configuration file is exactly what the server used. Finally, go to the official repository below to find out if it is supported in the Asp.net Core project.
https://github.com/dotnet/wcf
Feel free to let me know if there is anything I can help with.


Updated.
Here is a sample configuration on the client-side. System.servicemodel in the app.config is what we utmost cared.

    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://10.157.18.36:13100/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
                name="BasicHttpBinding_IService1" />
        </client>
</system.serviceModel>

It indicates that server use basichttpbinding and use the default authentication mode. these configurations are auto-generated by Adding service reference dialog. For the other classes, we don't need to care too much about their structure, basically a client-side proxy class.

I just had this issue, and it turned out that I wasn't targeting a specific service. Once I targeted the.svc file, the problem went away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM