Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a Basic Auth Header to my SOAP?

I'm trying to send a Authentication header through to a WSDL service that does not have the authentication requirement specified on the WSDL.

How can I add the Auth header to the call for the web service ?

Code I have been working with:

using System;
using System.Web.Services.Protocols;

namespace TesteSoap
{           
    class MainClass
    {
        public static void Main (string[] args)
        {

            WSDLService Service = new WSDLService();
            /* How can I add authentication to the call of this webservice ? */
            Service.get();
            Console.WriteLine ("Hello World!");
        }
    }
}
like image 733
Fernando André Avatar asked Feb 09 '11 13:02

Fernando André


People also ask

How do I add a header in SOAP request?

Select the service task or web service integration component and click the Variables tab above the diagram area. Create the private variable that you will later map to the SOAP header of the request message. To add a single header entry to the request message, use the variable type SOAPHeader.

How do I add basic authentication to WSDL?

The MustSupportBasicAuthentication element within a policy is required to enable basic authentication in the endpoint. The user name and password fields can be specified either as plain text in the WSDL, or as tokens in the WSDL and configured at runtime.

How do I add a basic Authorization header to my postman?

Basic authentication involves sending a verified username and password with your request. In the request Authorization tab, select Basic Auth from the Type dropdown list. Enter your API username and password in the Username and Password fields. For additional security, store these in variables.


1 Answers

This problem is questioned in other link but in a different way related to the WSDL including the question for user/password.

link

They aren't the same question but the problem is related.

Michaelis.MockService is the Webservice library extracted you may see an example on how to do this in: link Mono project website.

Michaelis.MockService service = new Michaelis.MockService();

// Create the network credentials and assign
// them to the service credentials
NetworkCredential netCredential = new NetworkCredential("Inigo.Montoya", "Ykmfptd");
Uri uri = new Uri(service.Url);
ICredentials credentials = netCredential.GetCredential(uri, "Basic");
service.Credentials = credentials;

// Be sure to set PreAuthenticate to true or else
// authentication will not be sent.
service.PreAuthenticate = true;

// Make the web service call.
service.Method();
like image 97
Fernando André Avatar answered Sep 18 '22 14:09

Fernando André