I think the line:
Service service = Service.create(wsdlURL, new QName("HelloService"));
needs to change to:

Service service = Service.create(wsdlURL, 
     new QName("http://com.example.ws/service";, "HelloService"));

Basically, you need the proper qname for the service in the wsdl.

Dan




On Thursday 25 September 2008 11:46:14 am John wrote:
> Hi,
>
> I am learning CXF and am working with the basic "HelloService" on the
> site's "Developing a Client HOWTO".  I am trying to use the dispatch API
> with my service but am getting the following error:
>
> Exception in thread "main" javax.xml.ws.WebServiceException:
> org.apache.cxf.service.factory.ServiceConstructionException: Could not
> find definition for service HelloService.
>     at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:135)
>     at
> org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.ja
>va:65) at javax.xml.ws.Service.<init>(Service.java:36)
>     at javax.xml.ws.Service.create(Service.java:116)
>     at com.eliteswa.client.Client.dispatchMethod(Client.java:56)
>
> Here is the dispatch code I am using:
>
> URL wsdlURL = new URL("http://localhost:9000/service/hello?wsdl";);
> Service service = Service.create(wsdlURL, new QName("HelloService"));
> Dispatch<Source> disp = service.createDispatch(new
> QName("HelloServicePort"), Source.class,
>                                             Service.Mode.PAYLOAD);
> Source request = new StreamSource("<hello/>");
> Source response = disp.invoke(request);
>
> Here is my WSDL from the deployed HelloService:
>
> <?xml version='1.0' encoding='UTF-8'?><wsdl:definitions
> name="HelloService" targetNamespace="http://com.example.ws/service";
> xmlns:ns1="http://service.example.com/";
> xmlns:ns2="http://schemas.xmlsoap.org/soap/http";
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
> xmlns:tns="http://com.example.ws/service";
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
> xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
>   <wsdl:import
> location="http://localhost:9000/service/hello?wsdl=HelloService.wsdl";
> namespace="http://service.example.com/";>
>     </wsdl:import>
>   <wsdl:message name="sayHi">
>     <wsdl:part element="ns1:sayHi" name="parameters">
>     </wsdl:part>
>   </wsdl:message>
>   <wsdl:message name="sayHiResponse">
>     <wsdl:part element="ns1:sayHiResponse" name="parameters">
>
>     </wsdl:part>
>   </wsdl:message>
>   <wsdl:binding name="HelloServiceSoapBinding" type="ns1:HelloService">
>     <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"; />
>     <wsdl:operation name="sayHi">
>       <soap:operation soapAction="" style="document" />
>       <wsdl:input name="sayHi">
>         <soap:body use="literal" />
>       </wsdl:input>
>
>       <wsdl:output name="sayHiResponse">
>         <soap:body use="literal" />
>       </wsdl:output>
>     </wsdl:operation>
>   </wsdl:binding>
>   <wsdl:service name="HelloService">
>     <wsdl:port binding="tns:HelloServiceSoapBinding"
> name="HelloServicePort">
>       <soap:address location="http://localhost:9000/service/hello"; />
>     </wsdl:port>
>   </wsdl:service>
> </wsdl:definitions>
>
> I know its something simple and obvious, the problem is, it's just not
> simply obvious to me.  I am assuming that the QName("HelloService")
> argument to the Service.create method corresponds to the wsdl:service
> name attribute, but that appears not to be the case.
>
> Any clarity is greatly appreciated.
>
> Thanks,
> John



-- 
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog

Reply via email to