Java Reference
In-Depth Information
The
S:
and
ns2:
namespace prefixes are generated by JAX-WS.
Note
To learn more about SOAP message handlers (especially on using
@Hand-
lerChain
), check out Oracle's “Creating and Using SOAP Message Handlers” tu-
Authentication and a Customized Lightweight HTTP Server
YoucancreateacustomizedlightweightHTTPserverthatoffersadditionalfeaturesfor
testing a web service, and replace the default lightweight HTTP server that is started
in response to an
Endpoint.publish()
invocation with your server. What makes
this possible is that
Endpoint
's
void publish(Object serverContext)
method can accept as its argument an instance of a class that subclasses the abstract
com.sun.net.httpserver.HTTPContext
class.
Note
You can find JDK 7 documentation on
HTTPContext
and the rest of
Forexample,supposeyouwanttotestbasicauthenticationwithyourwebservice—I
thatsuppliesausernameandpasswordtothewebservice.
Listing11-21
revealsthisau-
thenticator in the context of
TempVerterClient
.
Listing 11-21.
Supporting basic authentication with the
TempVerterClient
application
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import ca.tutortutor.tv.TempVerter;
class TempVerterClient