Dan Diephouse napisał(a):
Hiya,
You might need a jaxb.index file in your package which contains the name of the class on a single line (i.e. WsLoginMode). jaxb.dev.java.net should have more details somewhere...

- Dan
I tried with jaxb.index , in such case I get :

javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: unable to marshal type "generated.EnumType" as an element because it is missing an @XmlRootElement annotation]

And indeed , after adding this adnotation into generated enum class , it started working. But it is not acceptable (for me) to modify generated code. Another hint I got from jaxb users list was that I should add element declaration into my schema (apart from enum type declaration) , something like this :

<xs:element name="MyEnum" type="WsLoginMode"/>

and then marshall it using following piece of code:

ObjectFactory factory = new ObjectFactory();
JAXBElement el = factory.createMyEnum(myEnum) ;
mar.marshal(el , .....);

Apart from bigger complexity of this solution, I am not sure if it can be smoothly plugged into xfire service, can it?? The problem is that I have this enum type in my service login method signature: login(...,WsLoginMode loginMode,....). How to combine it with above piece of code??

Regards
bartek


Bartek Wasko wrote:

Dan Diephouse napisał(a):

What version of XFire are you using? I recall there being a bug with 1.1.x and enums. Also could you maybe post your server side config? I don't see anything immediately wrong with your posting, so I'm not sure whats going on...
- Dan

Thanks for reply


Bartek Wasko wrote:

Hi all

I have a following problem. During unmarshalling of a paramater of enum type I got such exception:

javax.xml.bin.JAXBException com.consol.cm.ws.schema.WsLoginMode is not known to this context.

Where WsLoginMode is an enum type generated by JAXB from the schema:

<xsd:simpleType name="WsLoginMode"> <xsd:restriction base="xsd:string">
           <xsd:enumeration value="admin">
           </xsd:enumeration>
           <xsd:enumeration value="engineer">
           </xsd:enumeration>
           <xsd:enumeration value="customer">
           </xsd:enumeration>
       </xsd:restriction>
   </xsd:simpleType>


in incomming soap it is serialized like this:

<loginMode xmlns="http://cm.consol.com/ws/schema";>engineer</loginMode>

the service  method uses it like this:

@WebMethod
   public WsEnv login(
                      @WebParam(name="login")java.lang.String login,
@WebParam(name="password")java.lang.String password, @WebParam(name="loginMode") WsLoginMode loginMode,
                      MessageContext ctx) throws WsException;

I would appreciate any hints..

bartek



Here is my configuration: (xfire 1.2.1)
*services.xml:*

<beans xmlns="http://xfire.codehaus.org/config/1.0";>

<bean id="cmService" class="com.consol.cm.ws.CmServiceImpl"> </bean>

<service>
<serviceBean>#cmService</serviceBean>
<serviceFactory>#jaxbServiceFactory</serviceFactory>
<schemas>
 <schema>META-INF/xfire/CmService.xsd</schema>
</schemas>
<style>document</style>
</service>

<bean name="jaxbServiceFactory" class="org.codehaus.xfire.jaxb2.JaxbServiceFactory">
   <constructor-arg ref="xfire.transportManager"/>
 </bean>
</beans>

*Generated WsLoginMode (in com.consol.cm.ws.schema package):*

@XmlEnum
public enum WsLoginMode {

   @XmlEnumValue("admin")
   ADMIN("admin"),
   @XmlEnumValue("customer")
   CUSTOMER("customer"),
   @XmlEnumValue("engineer")
   ENGINEER("engineer");
   private final String value;

   WsLoginMode(String v) {
       value = v;
   }

   public String value() {
       return value;
   }

   public static WsLoginMode fromValue(String v) {
       for (WsLoginMode c: WsLoginMode.values()) {
           if (c.value.equals(v)) {
               return c;
           }
       }
       throw new IllegalArgumentException(v.toString());
   }

}

*perhaps it is a hint, I carried out also another trivial test with simple Marshaller usage:*

try {
JAXBContext ctx = JAXBContext.newInstance("com.consol.cm.ws.schema");
           Marshaller mar =  ctx.createMarshaller();
           try {
mar.marshal(WsLoginMode.ENGINEER, new FileOutputStream("c:\\test.xml"));
           } catch (FileNotFoundException e) {
               e.printStackTrace();            }
       } catch (JAXBException e) {
           e.printStackTrace();        }

And also got the same results :

javax.xml.bind.JAXBException: com.consol.cm.ws.schema.WsLoginMode nor any of its super class is known to this context at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:480) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:449)

So it seems to be jaxb related.?

bartek





--
**********************************************
ConSol*
Consulting & Solutions Software Poland
ul. Bronowicka 10A, 30-084 Kraków
tel. +48 (012) 6231525
[EMAIL PROTECTED]
http://www.consol.de
**********************************************


---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to