Java Reference
In-Depth Information
boolean suppliedPassword = password != null &&
!password.value.isEmpty();
if (suppliedUsername && suppliedPassword) {
//log
System.out.println("Username: " + username.value);
System.out.println("Password: " + password.value);
//check registered user credentials in LDAP
//or database or something
boolean validUser = username.value.equals("eben") &&
password.value.equals("secret");
if (validUser) {
return true;
}
}
return false;
}
}
The highlighted code indicates the part of the service devoted to handling the SOAP headers
and their values.
In order to use this web service, you first need to use the wsimport tool to import the WSDL
and generate client classes that match it, as you've done before. See Example 7-20 .
Example7-20.Email verifier web service client that passes SOAP headers
package headerclient;
import com.soacookbook.headerClient.EmailCheckService;
import com.soacookbook.headerClient.EmailCheck;
import com.soacookbook.headerClient.Verify;
import com.soacookbook.headerClient.VerifyResponse;
import javax.xml.ws.Holder;
/**
* Invokes a web service that checks the validity of an
* email address. The web service requires a registered
* user's credentials as SOAP headers, so we use a
* {@code javax.xml.ws.Holder<T>} to pass the username
* and password.
*/
public class EmailHeaderClient {
Search WWH ::




Custom Search