HodStudio / XitSoap

An alternative way to do SOAP Requests without use the WSDL
MIT License
11 stars 3 forks source link

Authentication #5

Closed Cussa closed 6 years ago

Cussa commented 6 years ago

Improve the library creating a way to provide the Authentication on it.

panmona commented 6 years ago

So that we can add Bearer Tokens to the request headers? (That would have been my next question actually.)

Cussa commented 6 years ago

Yes. My idea is to create methods to add any kind of authentication. So, bearer tokens will be fully supported.

Cussa commented 6 years ago

Done in beta version!

https://www.nuget.org/packages/HodStudio.XitSoap/2.1.0.2-beta

//Create your service var webService = new WebService("url", "namespace");

//If you want to use Basic Authentication webService.SetAuthentication(new BasicAuthentication("user", "password"));

//If you want to use Bearer Token Authentication webService.SetAuthentication(new BearerTokenAuthentication("yourtoken"));

//Invoke the method webService.Invoke("IsAlive", "IQuotaDistributionService");

PLUS 1!

If you want to create your own authentication mode, create a class and inherits it from the IAuthentication interface. Implements the property AuthenticationHeader to have what exactly you want!

PLUS 2!

If you need to add another information on the header, you can use now the AddHeader method. And if it's necessary to remove, you can use the RemoveHeader!

Hope that it helps!

@maracuja-juice if you can test it, please, let me know about the feedback! ;)

panmona commented 6 years ago

@Cussa I only tested the Bearer Authentication:

webService.SetAuthentication(new BearerTokenAuthentication("yourtoken"));

And that works perfectly.

Cussa commented 6 years ago

Perfectly! I'll try to find some public webservice with basic authentication to test it. If everything is ok, I'll release the version.

Cussa commented 6 years ago

As everything seems ok, I'm preparing the documentation to it and I'll release the version 2.1.0! 😃

Cussa commented 6 years ago

Merging to production!