RE: [vanjug] Mine field of marshallable types in Sun's JaxWs 2.1

From: Arash Ghavami
Sent on: Wednesday, December 3, 2008 1:43 PM
Not sure if I understand the question clearly or I am probably missing
something:

Are you trying to use JAX-WS to send a SOAP message and an URI is part of
this message?
OR
You're trying to marshal/unmarshal using JAXB?

In the first case, regardless of the type of the object you plan to send you
can use 
javax.xml.ws.HolderHolder<YOUR_OBJECT_TO_SEND_OVER_SOAP> to hold your object
and send it via SOAP.

In second case, I don't see the relation between URI and the schema really. 


Arash



-----Original Message-----
From: [address removed] [mailto:[address removed]] On
Behalf Of Jim Tivy
Sent: Wednesday, December 03, 2008 10:58 AM
To: VanJug Meetup; VanJugDeprecated
Subject: [vanjug] Mine field of marshallable types in Sun's JaxWs 2.1

We are finding things like URI and String[] do not automatically marshall
across the Sun implemenation of JaxWs 2.1.  Are other people finding this,
or is nobody using the Sun implementation.

 

Incidently, I think the annotations stuff is brilliant and the interweaving
of JaxB.  But the implementation is catching up...

 

Looks like there is user defineable primitive type mechanism.  But I am not
sure why they don't ship with these done for URI.

 

See this post from seajug

 

Although I haven't verified this completely, I think you should be able to
go either way.  For instance, this mapping that I had in my XML schema:

  <xs:annotation>
    <xs:appinfo>
      <jaxb:globalBindings>
        <jaxb:serializable/>
        <xjc:javaType name="java.sql.Timestamp"
xmlType="TimestampStringType" adapter="TimeConverter"/>
      </jaxb:globalBindings>
    </xs:appinfo>
  </xs:annotation>

  <xs:simpleType name="TimestampStringType">
    <xs:annotation>
      <xs:documentation>W3C Schema date-time constrained to
Zulu.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:dateTime">
      <xs:pattern value=".+Z"/>
    </xs:restriction>
  </xs:simpleType>

mapped to this in the generated JAXB object:

...
    @XmlElement(name = "Timestamp", required = true, type = String.class)
    @XmlJavaTypeAdapter(TimeConverter.class)
    protected Timestamp timestamp;
...

where TimeConverter is:

package com.ticomgeo.mtops.adapters;

import java.sql.Timestamp;
import java.util.TimeZone;
import javax.xml.bind.annotation.adapters.XmlAdapter;

public class TimeConverter extends XmlAdapter<String, Timestamp> {

  static {
    TimeZone.setDefault(TimeZone.getTimeZone("Zulu"));
  }

  @Override
  public Timestamp unmarshal(String value) {
    if (value == null) {
      return null;
    }   
    value = value.replace("T"," ").replaceFirst("[Zz]","");
    Timestamp t = Timestamp.valueOf(value);
    return t;
  }

  @Override
  public String marshal(Timestamp value) {
    if (value == null) {
      return null;
    }   
    String datetime = value.toString().replace(" ","T")+"Z";
    return datetime;
  }

  public static void main(String args[]) {
    Timestamp t = new Timestamp(System.currentTimeMillis());
    System.out.println(t.toString());
    TimeConverter tc = new TimeConverter();
    System.out.println(tc.marshal(t));
    Timestamp t1 = tc.unmarshal(tc.marshal(t));
    System.out.println(t1);
    if (t1.equals(t)) {
      System.out.println("Passed");
    }   
  }
}

 

www.bluestream.com

Jim Tivy

[masked] x116

 


_______________________________________________
Posted via the VanJug mailing list
[address removed]
http://www.openro...

Other nearby
Meetups
Why these groups?
x

The Meetup Groups shown here are topically similar to The Vancouver Java Users Group.

Groups are more likely to be displayed here if they:

  • have a Meetup scheduled
  • have a high rating
  • have a group photo
  • are "public" and not "private"
  • have shown they are likely to stick around (older than 30 days)
Find more Meetup Groups
near Vancouver

Log in

  • Not registered with us yet?
or

Log in to Meetup with your Facebook account.

Sign up

or

Join this Meetup Group even quicker with your Facebook account.

By clicking the "Sign up using Facebook" or "Sign up" buttons above, you agree to Meetup's Terms of Service