WSRequest using HTTP Basic authentication with WSDL

pavkriz's picture

Hi, I'd like to invoke remote service using WSRequest in WSDL mode, but the service requires HTTP Basic authentication.

Unfortunately, following code

var request = new WSRequest();
var options = new Array();
options["username"] = "myname";
options["password"] = "mypass";
request.openWSDL("http://url.to/the/service/wsdl",false, options);
request.send("operation",null);
return request.responseXML;

results in

Fault: Transport error: 401 Error: Authorization Required

Documentation of  "openWSDL" mentions, that username and password options are related to WS-Security (that is not used in this scenario). Probably, "open" function is able to use HTTP Basic authentication, but it lacks the benefits of using WSDL!

Is there any solution to invoke such service in WSDL mode? (I think, HTTP Basic auth is still widely used in many environments)

tyrell's picture

Can you try

Can you try using  options.username = "username";  options.password = "password"; Instead? Just a suggestion, since I always use this format. Tyrell  
keith's picture

If I remember correct for

If I remember correct for WSDL mode we expect all details to be in the WSDL. But I have already created a JIRA for allowing users to override these details via the options object. As of now in WSDL mode we use the options object to get username/password and keystore details for WS-Security scenarios. This username/password is not used for basic auth. can you file a JIRA requesting this feature. I can look into it when time permits. Thanks, Keith.
pavkriz's picture

Is there a way to correct the WSDL?

Probably, I can ask for correcting the service's WSDL, but as far as I know, there no way to inform about HTTP Basic security in WSDL (redesign of the service to engage WS-Security is improbable). So currently there's no way, how to tell the underlying axis2 client to use HTTP Basic without explicit support in WSRequest (which is done only for "open" function using HttpTransportProperties.Authenticator). Am I right?
stefan.dressler.sygnomi.de's picture

This issiu seems to be very

This issiu seems to be very old. Is there any solution. I am trying to handle auth by using BasicAuth. But if I use wsdl it is not working. PHP Code $client = new WSClient(array("wsdl" => "link/authService.php?wsdl2", "classmap" => $class_map, "httpAuthUsername" => "test", "httpAuthPassword" => "test", "httpAuthType" => "Basic" )); Result: Could not Load WSDL from ***/authService.php?wsdl Soap Fault Code: Receiver