Dan,

I have a working client:

QName portQName = new QName("http://<snip> "HelloWorldPort");
String body = "<ns1:findById xmlns:ns1=\"http://
<snip>\"><id>2</id></ns1:findById>\n";
InputStream requestStream = new ByteArrayInputStream(body.getBytes());
Service service = Service.create(new QName("http://<snip>",
"HelloWorldService"));
service.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, "
http://localhost:8181/cxf/HelloWorld";);
Dispatch<Source> dispatch = service.createDispatch(new QName("http://<snip>",
"HelloWorldPort"), Source.class, Service.Mode.PAYLOAD);
Source request = new StreamSource(requestStream);
Source response = dispatch.invoke(request);
Transformer copier = TransformerFactory.newInstance().newTransformer();
copier.transform(response, new StreamResult(System.out));


Yet, when I add your System.out.println() statement for the
XmlSchemaCollection.class, I get the following:

jar:file:/home/jdr0887/.m2/repository/org/apache/ws/commons/schema/XmlSchema/1.4.7/XmlSchema-1.4.7.jar!/org/apache/ws/commons/schema/XmlSchemaCollection.class

How is this possible?  I have a maven pom with
org.apache.ws.xmlschema:xmlschema-core:2.0.1 defined and have imported the
project into eclipse using mvn eclipse:eclipse.  Running 'mvn
dependency:tree' shows no reference to xmlschema-core:1.4.7.  How on earth
is that jar found?


On Fri, Nov 4, 2011 at 6:28 PM, Daniel Kulp <[email protected]> wrote:

>
> It definite sounds like you're getting an older version of XmlSchema
> picked up
> from somplace.  That's definitely what you'll need to look for.  Prior to
> calling that code, you could TRY something like:
>
>
>
>
> System.out.println(XmlSchemaCollection.class.getResource("XmlSchemaCollection.class"))
>
> to see if it will print the URL out to where that class is being loaded
> from.
> That may help you diagnose what's going on.
>
>
> Dan
>
>
>
> On Friday, November 04, 2011 11:09:52 AM Jason Reilly wrote:
> > Hi all,
> >
> > I am trying to get web services deployed and successfully callable from a
> > CXF/Karaf environment.  I have Karaf running and CXF installed and a
> > HelloWorld service deployed.  My problem is within the client.  I keep
> > running into errors.  The first error looks like this:
> >
> > INFO: Creating Service {http://<snipped-namespace>}HelloWorldService
> from
> > class <snipped-package>.HelloWorld
> > Exception in thread "main" java.lang.NoSuchMethodError:
> >
> org.apache.ws.commons.schema.XmlSchemaCollection.read(Lorg/w3c/dom/Document;
> > Ljava/lang/String;)Lorg/apache/ws/commons/schema/XmlSchema; at
> >
> org.apache.cxf.common.xmlschema.SchemaCollection.read(SchemaCollection.java:
> > 130) at
> >
> org.apache.cxf.databinding.AbstractDataBinding.addSchemaDocument(AbstractDat
> > aBinding.java:177)
> >
> > There were a number of threads I read up to instruct me to ensure that
> > XmlSchema Core version 2.0.1 is in my classpath.  In my Maven POM, I have
> > the following:
> >
> >     <dependency>
> >       <groupId>org.ops4j.pax.logging</groupId>
> >       <artifactId>pax-logging-service</artifactId>
> >       <scope>provided</scope>
> >     </dependency>
> >     <dependency>
> >       <groupId>org.ops4j.pax.logging</groupId>
> >       <artifactId>pax-logging-api</artifactId>
> >       <scope>provided</scope>
> >     </dependency>
> >     <dependency>
> >       <groupId>org.apache.geronimo.specs</groupId>
> >       <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
> >       <version>1.1.3</version>
> >     </dependency>
> >     <dependency>
> >       <groupId>javax.xml.bind</groupId>
> >       <artifactId>jaxb-api</artifactId>
> >       <version>2.2.5</version>
> >     </dependency>
> >     <dependency>
> >       <groupId>org.apache.geronimo.specs</groupId>
> >       <artifactId>geronimo-jaxws_2.2_spec</artifactId>
> >       <version>1.1</version>
> >     </dependency>
> >     <dependency>
> >       <groupId>org.apache.ws.xmlschema</groupId>
> >       <artifactId>xmlschema-core</artifactId>
> >       <version>2.0.1</version>
> >     </dependency>
> >     <dependency>
> >       <groupId>org.apache.cxf</groupId>
> >       <artifactId>cxf-rt-frontend-jaxws</artifactId>
> >       <version>2.5.0</version>
> >     </dependency>
> >     <dependency>
> >       <groupId>org.apache.cxf</groupId>
> >       <artifactId>cxf-rt-transports-http</artifactId>
> >       <version>2.5.0</version>
> >     </dependency>
> >
> >
> > The client code snippet is as follows:
> >
> > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> > factory.getInInterceptors().add(new LoggingInInterceptor());
> > factory.getOutInterceptors().add(new LoggingOutInterceptor());
> > factory.setServiceClass(HelloWorld.class);
> > factory.setAddress("http://localhost:8181/HelloWorld?wsdl";);
> > HelloWorld client = (HelloWorld) factory.create();
> > String reply = client.findById(2L);
> > System.out.println("Server said: " + reply);
> > System.exit(0);
> >
> > The server side code looks like this:
> >
> > @WebService()
> > public class HelloWorld {
> >
> >     private final Logger log = LoggerFactory.getLogger(HelloWorld.class);
> >
> >     @WebMethod
> >     public String findById(@WebParam(name = "id") Long id) {
> >         log.info("id: " + id);
> >         return "asdfasdf";
> >     }
> >
> >     @WebMethod
> >     public String findByNameAndInstrument(@WebParam(name = "name") String
> > name,
> >             @WebParam(name = "instrument") String instrument) {
> >         return "qwerqwer";
> >     }
> >
> > }
> >
> > When I request "http://localhost:8181/cxf/HelloWorld/findById";, I am
> > returned a soap envelope with the body containing "asdfasdf".  This
> > indicates to me that the server side is fine....just something amiss with
> > the client.
> >
> > Any suggestions?
> --
> Daniel Kulp
> [email protected]
> http://dankulp.com/blog
> Talend - http://www.talend.com
>



-- 
Jason Reilly
Software Engineer

Reply via email to