Index: WSServiceDelegate.java =================================================================== RCS file: /cvs/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/client/WSServiceDelegate.java,v retrieving revision 1.8 diff -u -r1.8 WSServiceDelegate.java --- WSServiceDelegate.java 14 Sep 2005 20:15:50 -0000 1.8 +++ WSServiceDelegate.java 22 Sep 2005 09:29:38 -0000 @@ -37,6 +37,7 @@ import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Proxy; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.rmi.Remote; import java.util.*; @@ -306,7 +307,7 @@ private Dispatch createDispatchClazz(QName port, Class clazz, Service.Mode mode) throws WebServiceException { - PortInfoBase dispatchPort = dispatchPorts.get(port); + PortInfoBase dispatchPort = getDispatchPort(port); if (dispatchPort != null) { DispatchBase dBase = new DispatchBase((PortInfoBase) dispatchPort, clazz, (Service.Mode) mode, this); setBindingOnProvider(dBase, port, dBase._getBindingId()); @@ -317,7 +318,7 @@ } private Dispatch createDispatchJAXB(QName port, JAXBContext jaxbContext, Service.Mode mode) throws WebServiceException { - PortInfoBase dispatchPort = dispatchPorts.get(port); + PortInfoBase dispatchPort = getDispatchPort(port); if (dispatchPort != null) { DispatchBase dBase = new DispatchBase((PortInfoBase) dispatchPort, jaxbContext, mode, this); setBindingOnProvider(dBase, port, dBase._getBindingId()); @@ -327,6 +328,31 @@ } } + /** + * Looks up the dispatch port. If the port has not been added, then try look in the WSDL to find it. + */ + protected PortInfoBase getDispatchPort(QName port) { + PortInfoBase answer = dispatchPorts.get(port); + if (answer == null) { + // lets try find it in the WSDL + WSDLContext wsdlContext = serviceContext.getWsdlContext(); + QName serviceName = serviceContext.getServiceName(); + Binding binding = wsdlContext.getWsdlBinding(serviceName, port); + if (binding != null) { + try { + URI bindingId = new URI(binding.getBindingId()); + String endpointAddress = wsdlContext.getEndpoint(serviceName); + addPort(port, bindingId, endpointAddress ); + answer = dispatchPorts.get(port); + } + catch (URISyntaxException e) { + throw new WebServiceException(e); + } + } + } + return answer; + } + private URL getWsdlLocation() { return serviceContext.getWsdlContext().getWsdlLocation(); }