users@jaxb.java.net

Re: Web Services and images from j2me client

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Sun, 29 Aug 2010 14:45:13 +0200

One thing that looks curious at a first glance is that there are two
different classes for PacienteDTO, one at client and one at server side.
Usually you should have the same JAXB-annotated code at both ends, as this
will guarantee symmetric marshalling and unmarshalling.

Also, there is no package org.app.dev.client; in the server side client, and
so the generated XML will be in the default namespace (cf. the generated XML
schema. Chances are, that some namespace issue will arise.

Do you have any other classes? An ObjectFactory.java?

-W


On 29 August 2010 08:49, JULIAN ENRIQUE OSORIO AMAYA <
juliane.osorioa_at_unilibrebog.edu.co> wrote:

> Greetings
>
> I'm developing a web service and a j2me client using Netbeans 6.7.1.
>
> The j2me client sends an image to be stored in a mysql db and I need to be
> sure that the generated classes are correct.
>
> Here is the Pojo at server side
>
> import javax.activation.DataHandler;
> import javax.xml.bind.annotation.XmlAccessType;
> import javax.xml.bind.annotation.XmlAccessorType;
> import javax.xml.bind.annotation.XmlElement;
> import javax.xml.bind.annotation.XmlType;
> import javax.xml.bind.annotation.XmlMimeType;
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name="PacienteDTO", propOrder={"idPaciente", "nombrePaciente",
> "apellidoPaciente", "nombreImagen", "imagenPaciente", "fecha",
> "idUsuarioExterno", "idUsuarioInterno"})
> public class PacienteDTO {
> @XmlElement(required=true)
> private String idPaciente;
> @XmlElement(required=true)
> private String nombrePaciente;
> @XmlElement(required=true)
> private String apellidoPaciente;
> @XmlElement(required=true,nillable=true)
> private String nombreImagen;
> @XmlMimeType("image/jpeg")
> private DataHandler imagenPaciente;
> @XmlElement(required=true,nillable=true)
> private String fecha;
> @XmlElement(required=true)
> private String idUsuarioExterno;
> @XmlElement(required=true)
> private String idUsuarioInterno;
> public PacienteDTO() {
>
> }
> public String getApellidoPaciente() {
> return apellidoPaciente;
> }
>
> public String getFecha() {
> return fecha;
> }
>
> public void setFecha(String fecha) {
> this.fecha = fecha;
> }
>
> public String getIdPaciente() {
> return idPaciente;
> }
>
> public void setIdPaciente(String idPaciente) {
> this.idPaciente = idPaciente;
> }
>
> public String getIdUsuarioExterno() {
> return idUsuarioExterno;
> }
>
> public void setIdUsuarioExterno(String idUsuarioExterno) {
> this.idUsuarioExterno = idUsuarioExterno;
> }
>
> public String getIdUsuarioInterno() {
> return idUsuarioInterno;
> }
>
> public void setIdUsuarioInterno(String idUsuarioInterno) {
> this.idUsuarioInterno = idUsuarioInterno;
> }
>
> public DataHandler getImagenPaciente() {
> return imagenPaciente;
> }
>
> public void setImagenPaciente(DataHandler imagenPaciente) {
> this.imagenPaciente = imagenPaciente;
> }
>
> public String getNombreImagen() {
> return nombreImagen;
> }
>
> public void setNombreImagen(String nombreImagen) {
> this.nombreImagen = nombreImagen;
> }
>
> public String getNombrePaciente() {
> return nombrePaciente;
> }
>
> public void setNombrePaciente(String nombrePaciente) {
> this.nombrePaciente = nombrePaciente;
> }
>
> }
>
>
> Here is the schema generated by the schemagen command
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:complexType name="PacienteDTO">
> <xs:sequence>
> <xs:element name="idPaciente" type="xs:string"/>
> <xs:element name="nombrePaciente" type="xs:string"/>
> <xs:element name="apellidoPaciente" type="xs:string"/>
> <xs:element name="nombreImagen" type="xs:string" nillable="true"/>
> <xs:element name="imagenPaciente"
> ns1:expectedContentTypes="image/jpeg" type="xs:base64Binary" minOccurs="0"
> xmlns:ns1="http://www.w3.org/2005/05/xmlmime"/>
> <xs:element name="fecha" type="xs:string" nillable="true"/>
> <xs:element name="idUsuarioExterno" type="xs:string"/>
> <xs:element name="idUsuarioInterno" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
>
> <xs:complexType name="UsuarioDTO">
> <xs:sequence>
> <xs:element name="id" type="xs:string"/>
> <xs:element name="nombre" type="xs:string"/>
> <xs:element name="apellido" type="xs:string"/>
> <xs:element name="usuario" type="xs:string"/>
> <xs:element name="password" type="xs:string"/>
> <xs:element name="email" type="xs:string"/>
> <xs:element name="idRol" type="xs:int"/>
> </xs:sequence>
> </xs:complexType>
>
> <xs:complexType name="DiagnosticoDTO">
> <xs:sequence>
> <xs:element name="idPaciente" type="xs:string"/>
> <xs:element name="diagnostico" type="xs:string"/>
> <xs:element name="comentarios" type="xs:string" nillable="true"/>
> <xs:element name="fecha" type="xs:string" nillable="true"/>
> <xs:element name="idUsuarioOrigen" type="xs:string"/>
> <xs:element name="idUsuarioDestino" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
>
>
> Here is the Pojo at client side
>
> package org.app.dev.client;
>
> import javax.xml.namespace.QName;
> public class PacienteDTO {
>
> private String idPaciente;
>
> public void setIdPaciente( String idPaciente ) {
> this.idPaciente = idPaciente;
> }
>
> public String getIdPaciente() {
> return idPaciente;
> }
>
> private String nombrePaciente;
>
> public void setNombrePaciente( String nombrePaciente ) {
> this.nombrePaciente = nombrePaciente;
> }
>
> public String getNombrePaciente() {
> return nombrePaciente;
> }
>
> private String apellidoPaciente;
>
> public void setApellidoPaciente( String apellidoPaciente ) {
> this.apellidoPaciente = apellidoPaciente;
> }
>
> public String getApellidoPaciente() {
> return apellidoPaciente;
> }
>
> private String nombreImagen;
>
> public void setNombreImagen( String nombreImagen ) {
> this.nombreImagen = nombreImagen;
> }
>
> public String getNombreImagen() {
> return nombreImagen;
> }
>
> private byte[] imagenPaciente;
>
> public void setImagenPaciente( byte[] imagenPaciente ) {
> this.imagenPaciente = imagenPaciente;
> }
>
> public byte[] getImagenPaciente() {
> return imagenPaciente;
> }
>
> private String fecha;
>
> public void setFecha( String fecha ) {
> this.fecha = fecha;
> }
>
> public String getFecha() {
> return fecha;
> }
>
> private String idUsuarioExterno;
>
> public void setIdUsuarioExterno( String idUsuarioExterno ) {
> this.idUsuarioExterno = idUsuarioExterno;
> }
>
> public String getIdUsuarioExterno() {
> return idUsuarioExterno;
> }
>
> private String idUsuarioInterno;
>
> public void setIdUsuarioInterno( String idUsuarioInterno ) {
> this.idUsuarioInterno = idUsuarioInterno;
> }
>
> public String getIdUsuarioInterno() {
> return idUsuarioInterno;
> }
>
> }
>
>
> Is it ok or do I need to do some changes?
>
> Thanks for your time.
>
> --
> Julian Osorio Amaya
> Universidad Libre.
> Ingeniería de Sistemas.
> Bogota - Colombia
>
>