Java Reference
In-Depth Information
/**
* Command-line client invokes the web service,
* passing header data along with the operation parameter.
*/
public static void main(String... args) {
String emailToCheck = "me@example.com";
try {
EmailCheckService service = new EmailCheckService();
EmailCheck port = service.getEmailCheckPort();
//This is the email address we want to check
Verify params = new Verify();
params.setEmail(emailToCheck);
//Used for header data, because username is a String
Holder<String> username = new Holder<String>();
//Holder's value is of type T
username.value = "eben";
//Same deal for password header
Holder<String> password = new Holder<String>();
password.value = "secret1";
//Note that we pass the SOAP header into the op
VerifyResponse result =
port.verify(params, username, password);
System.out.println("Email check result: " +
result.getReturn());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Here is the result if you pass an invalid username and password combination:
C:\oreilly\soacookbook\code\chapters\HeaderClient>java -jar dist/
HeaderClient.jar
Email check result: You must be registered and supply a valid username
and password
to use this service.
Search WWH ::




Custom Search