File wsdlFile = new File("resources/webservice/jbws309/META-INF/wsdl/OrganizationService.wsdl");
assertTrue("wsdl file exists", wsdlFile.exists());
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(wsdlFile.toURL(), new QName(nsURI, "OrganizationService"));
Call call = service.createCall(new QName(nsURI, "BasicSecuredPort"), "getContactInfo");
call.setTargetEndpointAddress(targetAddress);
try
{
call.invoke(new Object[] { "mafia" });
fail("Security exception expected");
}
catch (RemoteException ignore)
{
// ignore expected exception
}
call.setProperty(Stub.USERNAME_PROPERTY, USERNAME);
call.setProperty(Stub.PASSWORD_PROPERTY, PASSWORD);
Object retObj = call.invoke(new Object[] { "mafia" });
assertEquals("The 'mafia' boss is currently out of office, please call again.", retObj);
}