I have a need to authenticate to a web service using a java console app. I have a working sample in perl, but I'd really like to do it with a java app. I've done a lot of searching on google and most of the stuff I've found seems very complicated. Maybe it just is tougher to do in java?.?.
Can anyone point me to some sample code for this? The whole goal is to simply verify authentication to the web service, which means the site is working correctly.
## Define the urls to the wsdl
$wsdlPathCore = "$url/swWebServices/services/WebNetworkCoreService?wsdl";
$wsdlPathPortal = "$url/swWebServices/services/WebNetworkPortalService?wsdl";
$wsdlPathVersion = "$url/swWebServices/services/Version?wsdl";
## Connect and ask the server for its version using the Version service
print "Getting server version \n";
$ServerVersion = SOAP::Lite->proxy( $wsdlPathVersion )
## Connect to the Core service
print "Connecting to Core Service \n";
$CoreService = SOAP::Lite->proxy( $wsdlPathCore )
## Get the sessionID
$sessionID = $CoreService->authenticateUserNoContext( $userName, $password )
## Ask what version of soap we are speaking.
$soapversion = $CoreService->soapversion;
## Connect to the Portal service
print "Connecting to Portal Service \n";
$portalService = SOAP::Lite->proxy( $wsdlPathPortal )
print "Soap Version : $soapversion \n";
print "Server Version : $ServerVersion \n";
print "Your sessionID is $sessionID \n";
Web services can be secured in many different ways. They are not Java specific. In terms of standards, we have WS-Security, WS-SecurityPolicy and they for themselves leads to many different configurations.
While I am not familiar with Perl, I see that you are invoking two methods authenticateUserNoContext() and voidUserSession() of the web service you have identified as the core service. This probably indicates that you are not using any of the standard (WS-*) security approaches. Hence, just use wsimport tool and generate the web service stub code. You might just be able to use the generated code without any further configuration.