You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Mathias P.W Nilsson" <ma...@snyltarna.se> on 2007/09/21 14:59:52 UTC

Re: [Axis2] Axis2 and Enum type

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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [Axis2] Axis2 and Enum type

Posted by Leon Hwang <hw...@mystrands.com>.
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">
		<description>Some 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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [Axis2] Axis2 and Enum type

Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [Axis2] Axis2 and Enum type

Posted by robert lazarski <ro...@gmail.com>.
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 <ma...@snyltarna.se> 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: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org