Axis2 and Enum

2007-09-21 Thread Mathias P.W Nilsson

I try to serialize hibernate pojos via axis and it works fine except when
using ENUM. When using enum I get error 

org.apache.axis2.AxisFault: Mapping qname not fond for the package: sun.misc

When changing the type to int everything works great. Can anyone help me?
-- 
View this message in context: 
http://www.nabble.com/Axis2-and-Enum-tf4495600.html#a12819817
Sent from the Axis - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [Axis2] Axis2 and Enum type

2007-09-21 Thread robert lazarski
This is an old problem. Until Axis2 gets code to support java 5 enums,
 I just do a
simple conversion. With this example in the wsdl:

element minOccurs=1 maxOccurs=1 nillable=true
name=TipoMibEnum type=xsd:int/

You'd get that value in the Service with the idea of converting it to this:

public enum TipoMib implements Serializable{

   MIB2,
   MIB_GERENCIA,
   MIB_ESPECIFICA;
}

I do the conversion as:

private static TipoMib getTipoMib(Integer ordinal) {
  if (TipoMib.MIB2.ordinal() == ordinal) {
  return TipoMib.MIB2;
  } else if (TipoMib.MIB_ESPECIFICA.ordinal() == ordinal) {
  return TipoMib.MIB_ESPECIFICA;
  } else if (TipoMib.MIB_GERENCIA.ordinal() == ordinal) {
  return TipoMib.MIB_GERENCIA;
  } else
  return null;
}

To convert the other way I do tipoMib.ordinal() - see the javadoc of
Enum about ordinal() .

HTH,
Robert

On 9/21/07, Mathias P.W Nilsson [EMAIL PROTECTED] wrote:

 Did you find any solution to this? I'm having the same problem
 --
 View this message in context: 
 http://www.nabble.com/-Axis2--Axis2-and-Enum-type-tf4350527.html#a12819819
 Sent from the Axis - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [Axis2] Axis2 and Enum type

2007-09-21 Thread Mathias P.W Nilsson

Did you find any solution to this? I'm having the same problem
-- 
View this message in context: 
http://www.nabble.com/-Axis2--Axis2-and-Enum-type-tf4350527.html#a12819819
Sent from the Axis - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [Axis2] Axis2 and Enum type

2007-09-21 Thread Mathias P.W Nilsson

I don't quit get the response. I don't generate the wsdl myself. Axis2
servlet does that I suppose. 

In my method I should return int instead? 
-- 
View this message in context: 
http://www.nabble.com/-Axis2--Axis2-and-Enum-type-tf4350527.html#a12821870
Sent from the Axis - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: [Axis2] Axis2 and Enum type

2007-09-21 Thread Leon Hwang

They said the current Axis2 is based on Java 1.4 which doesn't have the enum 
type definition.
I was told that this will be fixed in the next release (I am not sure if that 
was an official answer or not).

For creating WSDL, look at the code (WSDLDataLocator.java) in Axis2 source.
Here is what I do.
Instead of inventing WSDL creator, create your own data locator extended from 
WSDLDataLocator.
In outputInlineForm, get the result (OMElemet) from the parent and make changes 
there.

 protected Data[] outputInlineForm(MessageContext msgContext, ServiceData[] 
dataList)
throws DataRetrievalException {
Data[] result = super.outputInlineForm(msgContext, dataList);

if (null != result  null != result[0]) {
OMElement wsdlElement = (OMElement)result[0].getData();
this.generateCustomWSDL(wsdlElement); // call your own function
result[0] = new Data(wsdlElement, null);
}

return result;
}


Then, add datalocator in service.xml

service name=api
descriptionSome API/description

messageReceivers
messageReceiver
mep=http://www.w3.org/2004/08/wsdl/in-only;

class=org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver /
messageReceiver 
mep=http://www.w3.org/2004/08/wsdl/in-out;

class=org.apache.axis2.rpc.receivers.RPCMessageReceiver /
/messageReceivers

parameter name=ServiceClass locked=false
YOUR_SERVICE_CLASS
/parameter

dataLocator
dialectLocator 
dialect=http://schemas.xmlsoap.org/wsdl/;
class=YOUR_DATA_LOCATOR_CLASS /
/dataLocator
/service

Hope this helps.

- Leon

Mathias P.W Nilsson wrote:

I don't quit get the response. I don't generate the wsdl myself. Axis2
servlet does that I suppose. 

In my method I should return int instead? 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[Axis2] Axis2 and Enum type

2007-08-29 Thread Leon Hwang

Hello there,

I created a simple function that returns an object type of enum.
It is very simple function:

public static Gender getGender() {
return Gender.MALE;
}

but when I opened the page from a browser
http://localhost:8080/OpenApi/services/TestApi10/getGender

it generates an error like
soapenv:Reason
soapenv:Text xml:lang=en-US
java.lang.RuntimeException: org.apache.axis2.AxisFault: Mapping qname 
not fond for the package: org.apache.catalina.loader
/soapenv:Text
/soapenv:Reason

If I return any other objects, it works fine.
Am I not supposed to Enum type?
I think this is an error in Axis2.
By the way, I would not like to use Type-safe enum.
It has its own problem.

I have attached a source code and services.xml (TestApi.xml) and wsdl 
(TestApi10.xml - created by Axis2 on the fly).


By the way, if I create a client using WSDL2Java
wsdl2java.bat -or -g -Eofv -uw -u -uri 
http://localhost:8080/OpenApi/services/UserApi10?wsdl

I get a warning like this:
[WARN] Type {http://www.w3.org/2001/XMLSchema}Enum missing!

How do I get rid of this?

Also WSDL2Java doesn't create a enum type for Gender. Rather it is a regular 
class.
Which I have to use it like

Gender g = new Gender();
g.getFEMALE();

This didn't make a sense to me.


As a comparison, .NET create an enum type correctly.
In WSDL that .NET create, it is a just simpleType with restrictions.
I don't know if that caused the problem or not.

I would appreciate if you could give any help on this.

Thank you,

- Leon
serviceGroup
	service name=TestApi10 scope=application
		descriptionTest Services Api - v1.0/description
		
		messageReceivers
			messageReceiver
mep=http://www.w3.org/2004/08/wsdl/in-only;
class=org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver /
			messageReceiver mep=http://www.w3.org/2004/08/wsdl/in-out;
class=org.apache.axis2.rpc.receivers.RPCMessageReceiver /
		/messageReceivers
		parameter name=ServiceClass locked=false
			com.strands.openapi.services.user.TestApi10
		/parameter
	/service
/serviceGrouppackage com.strands.openapi.services.user;

import com.strands.openapi.types.user.Gender;

public class TestApi10 {
	public static Gender getGender() {
		return Gender.MALE;
	}
}
?xml version=1.0 encoding=UTF-8?
wsdl:definitions xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:ns1=http://user.types.openapi.strands.com/xsd; xmlns:wsaw=http://www.w3.org/2006/05/addressing/wsdl; xmlns:http=http://schemas.xmlsoap.org/wsdl/http/; xmlns:ns0=http://user.services.openapi.strands.com; xmlns:xs=http://www.w3.org/2001/XMLSchema; xmlns:mime=http://schemas.xmlsoap.org/wsdl/mime/; xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/; xmlns:soap12=http://schemas.xmlsoap.org/wsdl/soap12/; targetNamespace=http://user.services.openapi.strands.com;
wsdl:documentationTestApi10/wsdl:documentation
wsdl:types
xs:schema xmlns:ns=http://user.services.openapi.strands.com; attributeFormDefault=qualified elementFormDefault=qualified targetNamespace=http://user.services.openapi.strands.com;
xs:element name=getGenderResponse
xs:complexType
xs:sequence
xs:element minOccurs=0 name=return nillable=true type=ns1:Gender/
/xs:sequence
/xs:complexType
/xs:element
/xs:schema
xs:schema xmlns:ax27=http://user.types.openapi.strands.com/xsd; attributeFormDefault=qualified elementFormDefault=qualified targetNamespace=http://user.types.openapi.strands.com/xsd;
xs:complexType name=Gender
xs:complexContent
xs:extension base=xs:Enum
xs:sequence
xs:element minOccurs=0 name=FEMALE nillable=true type=ax27:Gender/
xs:element minOccurs=0 name=MALE nillable=true type=ax27:Gender/
/xs:sequence
/xs:extension
/xs:complexContent
/xs:complexType
/xs:schema
/wsdl:types
wsdl:message name=getGenderRequest/
wsdl:message name=getGenderResponse
wsdl:part name=parameters element=ns0:getGenderResponse/
/wsdl:message
wsdl:portType name=TestApi10PortType
wsdl:operation name=getGender
wsdl:input message=ns0:getGenderRequest wsaw:Action=urn:getGender/
wsdl:output message=ns0:getGenderResponse wsaw:Action=urn:getGenderResponse/
/wsdl:operation
/wsdl:portType
wsdl:binding name=TestApi10SOAP11Binding type=ns0:TestApi10PortType
soap:binding transport=http://schemas.xmlsoap.org/soap/http; style=document/
wsdl:operation name=getGender
soap:operation soapAction=urn:getGender style=document/
wsdl:input
soap:body use=literal/
/wsdl:input
wsdl:output
soap:body use=literal/
/wsdl:output
/wsdl:operation
/wsdl:binding