I am not able access a web service that uses token based security using the code below. Does anyone see something that is wrong or does a change need to be made on the web service end? If I leave out the calls to the AddHttpHeader, I get a different error message. I've included working PERL code as a reference. A chronos is an event that happened at a specific time. The WSDL is not available to the public.
With AddHTTPHeader calls, error is "Unauthorized to access the resource"
Without AddHTTPHeader calls, error is "Security token is required to access the service"
============================================================
*** Load the Proxy and Support Class Libraries
DO SecurityTokenServiceProxy.prg
*** Create an instance of the Proxy
LOCAL loSecurityService as SecurityTokenServiceProxy
*loService = CREATEOBJECT("ChronoServiceProxy","V4") && Optionally specify .NET Version
loSecurityService = CREATEOBJECT("SecurityTokenServiceProxy")
loMyToken = loSecurityService.issuetoken("account", "password")
*** Load the Proxy and Support Class Libraries
DO ChronosServiceProxy.prg
loProxy = CREATE("ChronosServiceProxy")
loProxy.oService.AddHttpHeader("authenticationToken",loMyToken)
loProxy.oService.AddHttpHeader("districtID","0970")
myChronos = loProxy.oService.getChronos("0970",1838,.T.)
============================================================
WORKING CODE FROM PERL
sub getChrono
{
my $self = shift;
my $args = shift;
if ($args) {
my ($chronoId, $districtId, $username, $password, $token);
$chronoId = getParameter($args, 'chronoId');
$districtId = getParameter($args, 'districtId');
$token = getParameter($args, 'token');
$self->{_cs}->proxy('http://xxxxx.dcn:8080/xxx-soap/chronosservice?wsdl');
$self->{_cs}->ns('http://xxxxxxx/chronosstubs', 'chr');
$self->{_cs}->endpoint('http://xxxx:8080/xxx-soap/chronosservice');
$self->{_cs}->transport->http_request->header('authenticationToken' => $token);
$self->{_cs}->transport->http_request->header('districtID' => $districtID);
#my $method = SOAP::Data->name('tns:getChrono');
my $method = SOAP::Data->name('chr:getChronos');
my @params = ( SOAP::Data->name('chr:district' => $districtId),
SOAP::Data->name('chr:chronoId' => $chronoId) );
my $response = $self->{_cs}->call($method => @params);
return $response;
} else {
die "no arguments provided to getChrono";
}
}