Iβm sure you have a lot of questions about this, but none of the answers that I found seem to cope with the problem that I encountered, so I was hoping I could get some specific answers.
I have a project consisting of a client and a server. The server connects to the database, and the client can call methods on the server through the wsdl file. This works fine, but the server can only return simple types and lists. I looked at how to handle custom types, and I was directed to JaxB, which seems to be exactly what I'm looking for. Unfortunately, I am a little confused about how I should use it. I use NetBeans IDE (6.9.1), which makes working with wsdl files easier, although I read that passing complex classes is pretty trivial from the command line, once you have the wsdl-end of things working correctly?
What I want to do is return a class to the server - it will only contain data that the client can read and use.
I did the following, but obviously I'm wrong somewhere!
- I have a class called Server-side Customer, which is designed and returned when the client invokes a specific method.
- The client obviously cannot correctly interpret this class.
- I used a schema to create an XML schema from the Customer class. Then I use the netbeans wizard to bind the schema to a class on the client.
- I guess this is where I got confused. I want to cancel the xml response from the server and use it to create a new object on the client. I use the "jaxbu" netbeans shortcut, which extends into some code, but I'm not sure how to put the returned object in unmarshaller. If that makes sense?
The code generated by "jaxbu" is similar to the one below, inside the try block:
javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(c.getClass().getPackage().getName()); javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller(); c = (CustomerInfo) unmarshaller.unmarshal(new java.io.File("File path"));
Any help would be greatly appreciated and if you require further information. please feel free to ask.
Thanks Mathew
source share