With JAXB, the beans basically have to:
a) have a public 0 arg constructor
b) either have public getter and setter methods or the field is public.
I think if you update the bean to meet that requirement, it might go
better.
Dan
On Wednesday 03 October 2007, Hycel Taylor wrote:
> Hello,
>
> I'm evaluating the CXF API and I'm going through some of your
> examples. I got the sample code under java_first_jaxws, working fairly
> quickly. I'm trying to expand on the code with a more realistic
> scenario where I will be using a custom defined POJO as a parameter in
> the sayHi() method. I created a simple class called block which does
> nothing but accept a string in its' constructor and allows access to
> the string via a getter method (I provided my code below). I
> restarted the server and then ran the client. When the client
> executes, I get the following exception:
>
> JAXBException: demo.hw.client.Block is not known to this context
>
> I understand that I need to somehow register or dThe code is almost
identical to the code in original simple example:
public class Block implements Serializable {
private String message;efine the Block class
> so the JAXB context knows about it. I haven't been able to determine
> how to do this. Could some one provide a code block or set of
> instructions that clearly describes how this should be done so that I
> can successfully execute this example using the Block class.
>
> The code is almost identical to the code in original simple example:
>
> public class Block implements Serializable {
> private String message;
> public Block(String message) { this.message = message; }
> public String getMessage() { return message; }
> }
>
> @WebService
> public interface HelloWorld {
> public String sayHi(Block block);
> }
>
> @WebService(endpointInterface = "demo.hw.server.HelloWorld",
> serviceName = "HelloWorld")
> public class HelloWorldImpl implements HelloWorld {
> public String sayHi(Block block) {return "Hello " +
> block.getMessage(); } }
>
> public final class Client {
> private static String QNAME = "http://server.hw.demo/";
> private static final QName SERVICE_NAME = new QName(QNAME,
> "HelloWorld"); private static final QName PORT_NAME = new QName(QNAME,
> "HelloWorldPort");
>
> private Client() {}
>
> public static void main(String args[]) throws Exception {
> final Service service = Service.create(SERVICE_NAME);
> final String endpointAddress = "http://localhost:9000/helloWorld";
>
> service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING,
> endpointAddress);
>
> final HelloWorld hw = service.getPort(HelloWorld.class);
> final String message = "World";
> final Block block = new Block(message);
> final String result = hw.sayHi(block);
>
> System.out.println(result);
> }
>
> public class Server {
> protected Server() throws Exception {
> System.out.println("Starting Server");
>
> HelloWorldImpl implementor = new HelloWorldImpl();
> String address = "http://localhost:9000/helloWorld";
> Endpoint.publish(address, implementor);
> }
>
> public static void main(String args[]) throws Exception {
> new Server();
> System.out.println("Server ready...");
>
> Thread.sleep(5 * 60 * 1000);
> System.out.println("Server exiting");
> System.exit(0);
> }
> }
>
> Thank you,
> Hycel
> [EMAIL PROTECTED]
--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727 C: 508-380-7194
[EMAIL PROTECTED]
http://www.dankulp.com/blog