Java Reference
In-Depth Information
{
public static void main(String[] args) throws Exception
{
URL url = new URL("http://localhost:9901/TempVert-
er?wsdl");
QName qname = new QName("http://tv.tutortutor.ca/",
"TempVerterImplService");
Service service = Service.create(url, qname);
qname = new QName("http://tv.tutortutor.ca/", "Tem-
pVerterImplPort");
TempVerter tv = service.getPort(qname, TempVert-
er.class);
//
TempVerter tv = service.getPort(TempVerter.class);
BindingProvider bp = (BindingProvider) tv;
Binding binding = bp.getBinding();
List<Handler> hc = binding.getHandlerChain();
hc.add(new SOAPLoggingHandler());
binding.setHandlerChain(hc);
System.out.println(tv.c2f(37.0)+"\n");
System.out.println(tv.f2c(212.0)+"\n");
}
}
Listing11-20 ' s main() methodaccessestheclient'shandlerchainandinsertsanin-
stance of SOAPLoggingHandler into this chain by completing the following steps:
1. Cast the proxy instance returned from getPort() to
javax.xml.ws.BindingProvider because the proxy instance's class
implements this interface. BindingProvider provides access to the pro-
tocolbindingandassociatedcontextobjectsforrequestandresponsemessage
processing.
2. Call BindingProvider 's Binding getBinding() method to return
the protocol binding instance, which is an instance of a class that ultimately
implementsthe javax.xml.ws.Binding interface—theclassactuallyim-
plements Binding 's javax.xml.ws.soap.SOAPBinding subinterface.
3. Invoke Binding 's List<Handler> getHandlerChain() method on
this instance to return a copy of the handler chain.
Search WWH ::




Custom Search