Code Comments
Programming Forum and web based access to our favorite programming groups.My question is:
VisualWorks SOAP client -- How to obtain a session ID?
I am using the VisualWorks SOAP client to converse with a web service
that requires the session ID as one of the arguments for the web
service call. I have been able to successfully execute a conversation
by swiping a non-terminated session ID from a Perl SOAP::Lite client,
but can't figure out where/how to obtain the session ID for the
VisualWorks SOAP client.
Here is the code:
-------- Smalltalk code starts here -----------
| wsdlClient soapRequest sessionID |
wsdlClient := WsdlClient new loadFrom:
'http://imac.local:8080/exist/services/Query?WSDL' asURI.
wsdlClient transportClient loginToHost: 'myHost' port: 8080 asUser:
'myUserID' withPassword: 'myPassword' .
soapRequest := SoapRequest new.
soapRequest port: wsdlClient config anyPort.
"This is a session ID swiped from a Perl SOAP::Lite client session:"
sessionID := '9103440'.
"The sessionID is a required argument for the web service call:"
soapRequest smalltalkEntity:
(Message selector: #getResourceData arguments: #(sessionID
'/db/shakespeare/plays/hamlet.xml' true false false) ).
soapRequest value
-------- Smalltalk code ends here -----------
And here is the equivalent Perl SOAP client code:
-------- Perl code starts here -----------
#!/usr/bin/perl -w
use SOAP::Lite;
die "Usage: $0 collection document\n" unless @ARGV == 2;
my $collection = $ARGV[0];
my $doc = $ARGV[1];
my $service =
SOAP::Lite->service("http://myHost:8080/exist/services/Query?WSDL");
$service->on_fault(sub { my($soap, $res) = @_;
die ref $res ? $res->faultdetail : $soap->transport->status, "\n";
});
print "Connecting ...\n";
# The Perl connect method returns a session ID string:
my $session = $service->connect("guest", "guest");
print "$session\n"; # <--- got my session ID from here
print "Collection contents for $collection:\n";
my $resp = $service->listCollection($session, $collection);
my @resources = @{$resp->{'resources'}};
foreach $r (@resources) {
print "\t$r\n";
}
$doc = "$collection/$doc";
print "\nRetrieving document $doc ...\n\n";
$resp = $service->getResourceData($session, $doc, TRUE, FALSE, FALSE);
print "$resp\n\n";
#$service->disconnect($session);
-------- Perl code ends here -----------
Suggestions on how to obtain a session ID for a VisualWorks SOAP client
would be appreciated!
Thanks,
Pat Podenski
Post Follow-up to this messageAs usual after thinking it over, I figured it out. Here is how to get the sessionID for the eXist SOAP query: | wsdlClient soapRequest session args | wsdlClient := WsdlClient new loadFrom: 'http://localhost:8080/exist/services/Query?WSDL' asURI. soapRequest := SoapRequest new. soapRequest port: wsdlClient config anyPort. soapRequest smalltalkEntity: (Message selector: #connect arguments: #( 'userID' 'password' ) ). session := soapRequest value. args := OrderedCollection new. args add: session. args addAll: #( '/db/shakespeare/plays/hamlet.xml' true false false ) asOrderedCollection. soapRequest smalltalkEntity: (Message selector: #getResourceData arguments: args asArray ). soapRequest value. soapRequest smalltalkEntity: (Message selector: #disconnect).
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.