3 Replies Latest reply on Dec 17, 2010 2:45 AM by Jim Ma

    createDispatch with WS-Address

    Gary Brown Master



      I'm trying to create a Dispatch instance using WS-Addressing endpoint reference.


      When I try this from code deployed within the server, both using cxf and native, it results in an exception like:


      12:14:48,551 ERROR [STDERR] javax.xml.ws.WebServiceException: Port HelloWorldPort not found.
      12:14:48,552 ERROR [STDERR]     at org.apache.cxf.jaxws.ServiceImpl.getJaxwsEndpoint(ServiceImpl.java:258)
      12:14:48,552 ERROR [STDERR]     at org.apache.cxf.jaxws.ServiceImpl.createDispatch(ServiceImpl.java:616)
      12:14:48,552 ERROR [STDERR]     at org.apache.cxf.jaxws.ServiceImpl.createDispatch(ServiceImpl.java:641)
      12:14:48,552 ERROR [STDERR]     at javax.xml.ws.Service.createDispatch(Service.java:444)


      However when I run the same code in a client app, it works fine - the Dispatch instance is returned.


      The code fragment I use is:



           try {
                  URL wsdlUrl=WSClient.class.getClassLoader().getResource("HelloWorldWS.wsdl");
                  QName serviceName=QName.valueOf("{http://simple_invoke/helloworld}HelloWorldWSService");
                  Service service = Service.create(wsdlUrl, serviceName);
                  String text="<EndpointReference xmlns=\"http://www.w3.org/2005/08/addressing\">"+
                              "<wsam:ServiceName xmlns:wsam=\"http://www.w3.org/2007/05/addressing/metadata\" "+
                                  " xmlns:srv=\"http://simple_invoke/helloworld\" EndpointName=\"HelloWorldPort\">srv:HelloWorldWSService</wsam:ServiceName>"+
                  javax.xml.ws.EndpointReference epr=
                      javax.xml.ws.wsaddressing.W3CEndpointReference.readFrom(new StreamSource(
                              new java.io.ByteArrayInputStream(text.getBytes())));
                  Dispatch dispatcher = service.createDispatch(epr, SOAPMessage.class,
                              Service.Mode.MESSAGE, new javax.xml.ws.soap.AddressingFeature());
              } catch(Exception e) {


      Not sure if the problem is due to the way that the port (or endpoint name) in EPR is being handled. In WS-Addressing meta spec, endpoint name is an NCName attribute on the ServiceName element. However the ServiceMetaData in jbossws-native I believe is expecting it to be a QName with namespace of the service name. This is possibly why it is not locating the port?


      I am trying to override the web service address (URL) in the WSDL, and it appears the Service/Dispatch approach only allows WS-Addressing to be used for this. If there is another means of overriding the URL, then I would also be interested in trying that.




        • 1. Re: createDispatch with WS-Address
          Jim Ma Apprentice

          Hi Gary,

          I suspect wsdl url is not retrieved when code is deployed in server. wsdlUrl result of this line should be a VFS url when code deployed in server:

          URL wsdlUrl=WSClient.class.getClassLoader().getResource("HelloWorldWS.wsdl"); 

          It needs the JBossWSResourceResolver used to resolve the VFS file resource to add in cxf bus.

          If it is the cause, you can simply change this wsdl location to something like "http://localhost:8080/foo/bar?wsdl".  Or add this resolve in bus with :



          • 2. Re: createDispatch with WS-Address
            Gary Brown Master

            Hi Jim


            Its not a WSDL loading problem, as this part hasn't changed (in riftsaw). I have also seen the ServiceMetaData and client endpoint metadata info when debugging - thats why I believe it has something to do with the fact that the client endpoints (ports) are keyed on a QName with the service's namespace, whereas the WS-Address endpoint reference (although it returns the port as a QName) is only an NCName, and so does not technical have a namespace.




            • 3. Re: createDispatch with WS-Address
              Jim Ma Apprentice

              OK, Gary . Can you send your code to me ? At the mean time I am trying to create a sample to reproduce the error locally .   Thanks.  Jim