If you just want to handle the anyURI schema data type you can define a 
<format> for this purpose. <format>s are for simple values (the 
equivalent of a schema simpleType), which can be the text content of an 
element or an attribute value. <mapping>s are for more complex 
structures, the equivalent of a schema complexType.

A format just needs static serializer (if your binding supports output) 
and/or deserializer (if your binding supports input) methods. See 
http://jibx.sourceforge.net/tutorial/binding-extend.html#serdeser for a 
detailed example.

You can also just keep an anyURI value as a simple String, if you want. 
In that case you don't need any special serialization at all. Or you can 
use a custom class that has a constructor from a String value and a 
toString() method that gives the proper XML text representation - JiBX 
will use that constructor and the toString() method to handle a class of 
this type automatically, without the need to specify anything.

  - Dennis

Dennis M. Sosnoski
SOA and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Serkan Sunel wrote:
> Hi Dennis,
> Thanks for quick reply :)
>
> Yes, I do want to unwrapping...(especially after seeing the Axis Data
> Binding)
>
> But when I changed the mapping to the ABSTRACT it gives another
> exception
>
> IT IS JUST : no format definition found... Probably I don't know how to
> do it for that..
>
> Can you tell us how to define an abstract mapping for the type:anyURI
> exactly ?What is the syntax in binding xml?  Do I need a custom
> marshaller/unmarshaller also?
>
> Serkan SUNEL
>
>
> Exception in thread "main"
> org.apache.axis2.wsdl.codegen.CodeGenerationException:
> java.lang.RuntimeException: Cannot unwrap element
> {http://www.csapi.org/schema/parlayx/payment/reserve_amount_charging/v2_
> 1/local}reserveAmount: no format definition found for type
> {http://www.w3.org/2001/XMLSchema}anyURI (used by element
> {http://www.csapi.org/schema/parlayx/payment/reserve_amount_charging/v2_
> 1/local}endUserIdentifier)
>         at
> org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerati
> onEngine.java:224)
>         at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:32)
>         at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:21)
> Caused by: java.lang.RuntimeException: Cannot unwrap element
> {http://www.csapi.org/schema/parlayx/payment/reserve_amount_charging/v2_
> 1/local}reserveAmount: no format definition found for type
> {http://www.w3.org/2001/XMLSchema}anyURI (used by element
> {http://www.csapi.org/schema/parlayx/payment/reserve_amount_charging/v2_
> 1/local}endUserIdentifier)
>         at
> org.apache.axis2.jibx.CodeGenerationUtility.unwrapMessage(CodeGeneration
> Utility.java:779)
>         at
> org.apache.axis2.jibx.CodeGenerationUtility.engage(CodeGenerationUtility
> .java:383)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:324)
>         at
> org.apache.axis2.wsdl.codegen.extension.JiBXExtension.engage(JiBXExtensi
> on.java:74)
>         at
> org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerati
> onEngine.java:177)
>         ... 2 more
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Dennis
> Sosnoski
> Sent: Friday, April 20, 2007 1:06 PM
> To: JiBX users
> Subject: Re: [jibx-users] Local part not allowed to be null
>
> Hi Serkan,
>
> Your <mapping> for URI should probably be an abstract mapping, if you 
> want this mapping to apply to unwrapped method parameter types. If you 
> leave it non-abstract, you'll need to specify an element name on the 
> mapping for it to work with the current Axis2 code generation. The 
> abstract form is appropriate if you're using unwrapping, the concrete 
> form if you're not unwrapping.
>
> This is becoming a common issue, and I added code to the JiBX code 
> generation for Axis2 today to catch this case and give a somewhat 
> information error message rather than just an IllegalArgumentException. 
> Most of the cases I've seen have involved bindings that were completely 
> wrong. In your case, it looks like the binding may be good but the Axis2
>
> code generation is still not able to cope.
>
>   - Dennis
>
> Dennis M. Sosnoski
> SOA and Web Services in Java
> Training and Consulting
> http://www.sosnoski.com - http://www.sosnoski.co.nz
> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
>
>
>
> Serkan Sunel wrote:
>   
>> Hi all,
>>
>> I am getting below exception while running wsdl2java
>>
>> If i delete the anyURI (endUserIdentifier in
>> interface.wsdl->reserveAmount operation) paramaters from the wsdl it
>> works..Is its binding is wrong something missing ?
>>
>> Thanks..
>>
>> Serkan Sunel
>>
>> java org.apache.axis2.wsdl.WSDL2Java -uri 
>> payment_reserve_amount_charging_service_2_1.wsdl -ns2p
>>
>>     
> http://www.csapi.org/schema/parlayx/payment/reserve_amount_charging/v2_1
>   
> /local=com.telenity.canvas.platform.parlayx.ws.schema.payment.reserve_am
>   
>> ount_charging.v2_1.local -uw -o ../output/  -sd -s  -ss -t -ssi -g -u
>>     
> -d
>   
>> jibx -Ebindingfile /home/serkans/downloads/binding.xml
>>
>>
>>
>> Retrieving document at
>> 'parlayx_payment_reserve_amount_charging_interface_2_1.wsdl', relative
>> to
>>
>>     
> 'file:/home/serkans/products/platform/current/canvas/platform/parlayx/ws
>   
>> dl/'.
>> Retrieving document at 'parlayx_common_faults_2_0.wsdl', relative to
>>
>>     
> 'file:/home/serkans/products/platform/current/canvas/platform/parlayx/ws
>   
>> dl/parlayx_payment_reserve_amount_charging_interface_2_1.wsdl'.
>> Retrieving schema at 'parlayx_common_types_2_1.xsd', relative to
>>
>>     
> 'file:/home/serkans/products/platform/current/canvas/platform/parlayx/ws
>   
>> dl/parlayx_common_faults_2_0.wsdl'.
>> Retrieving schema at 'parlayx_payment_types_2_1.xsd', relative to
>>
>>     
> 'file:/home/serkans/products/platform/current/canvas/platform/parlayx/ws
>   
>> dl/parlayx_payment_reserve_amount_charging_interface_2_1.wsdl'.
>> Retrieving schema at 'parlayx_common_types_2_1.xsd', relative to
>>
>>     
> 'file:/home/serkans/products/platform/current/canvas/platform/parlayx/ws
>   
>> dl/parlayx_payment_reserve_amount_charging_interface_2_1.wsdl'.
>> Exception in thread "main"
>> org.apache.axis2.wsdl.codegen.CodeGenerationException:
>> java.lang.IllegalArgumentException: Local part not allowed to be null
>>         at
>>
>>     
> org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerati
>   
>> onEngine.java:224)
>>         at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:32)
>>         at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:21)
>> Caused by: java.lang.IllegalArgumentException: Local part not allowed
>>     
> to
>   
>> be null
>>         at javax.xml.namespace.QName.<init>(QName.java:85)
>>         at javax.xml.namespace.QName.<init>(QName.java:70)
>>         at
>>
>>     
> org.apache.axis2.jibx.CodeGenerationUtility.collectTopLevelComponents(Co
>   
>> deGenerationUtility.java:1057)
>>         at
>>
>>     
> org.apache.axis2.jibx.CodeGenerationUtility.engage(CodeGenerationUtility
>   
>> .java:310)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at
>>
>>     
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
>   
>> a:39)
>>         at
>>
>>     
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
>   
>> Impl.java:25)
>>         at java.lang.reflect.Method.invoke(Method.java:324)
>>         at
>>
>>     
> org.apache.axis2.wsdl.codegen.extension.JiBXExtension.engage(JiBXExtensi
>   
>> on.java:74)
>>         at
>>
>>     
> org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerati
>   
>> onEngine.java:177)
>>   
>>
>>     
> ------------------------------------------------------------------------
>   
>> <?xml version="1.0" encoding="UTF-8"?>
>> <binding force-classes="true"
>>     
> xmlns:tns="http://www.csapi.org/schema/parlayx/common/v2_1";  >
>   
>>   <namespace uri="http://www.csapi.org/schema/parlayx/common/v2_1";
>>     
> default="elements"/>
>   
>>   <mapping abstract="true"
>>     
> class="com.telenity.util.parlayx.common.ChargingInformation"
> type-name="tns:ChargingInformation">
>   
>>     <value name="description" style="attribute"  field="description"
>>     
> usage="required"/>
>   
>>     <value name="currency" style="attribute" field="currency"
>>     
> usage="optional"/>
>   
>>     <value name="amount" style="attribute"  field="amount"
>>     
> usage="optional"/>
>   
>>     <value name="code" style="attribute" field="code"
>>     
> usage="optional"/>
>   
>>   </mapping>
>>
>>   <mapping class="org.apache.axis2.databinding.types.URI"
>>     
> type-name="tns:anyURI"
> marshaller="com.telenity.canvas.platform.parlayx.ws.util.URIMarshaller"
> unmarshaller="com.telenity.canvas.platform.parlayx.ws.util.URIMarshaller
> ">
>   
>>     
>>   </mapping>
>>
>>   <mapping name="TimeMetric"
>>     
> class="com.telenity.util.parlayx.common.TimeMetric">
>   
>>     <value name="metric" style="attribute"  field="metric"
>>     
> usage="required"/>
>   
>>     <value name="units" style="attribute"  field="units"
>>     
> usage="required"/>
>   
>>   </mapping>
>>   <mapping name="SimpleReference"
>>     
> class="com.telenity.util.parlayx.common.SimpleReference">
>   
>>     <value name="endpoint" style="attribute"  field="endpoint"
>>     
> usage="required"/>
>   
>>     <value name="interfaceName" style="attribute"
>>     
> field="interfaceName" usage="required"/>
>   
>>     <value name="correlator" style="attribute"  field="correlator"
>>     
> usage="required"/>
>   
>>   </mapping>
>>   <mapping name="ServiceError"
>>     
> class="com.telenity.util.parlayx.common.ServiceError">
>   
>>     <value name="messageId" style="attribute"  field="messageId"
>>     
> usage="required"/>
>   
>>     <value name="text" style="attribute"  field="text"
>>     
> usage="required"/>
>   
>>     <collection field="variablesList">
>>       <value name="variables" type="java.lang.String"/>
>>     </collection>
>>   </mapping>
>>   <mapping name="ServiceException"
>>     
> class="com.telenity.util.parlayx.common.ServiceException">
>   
>>     <value name="messageId" style="attribute"  field="messageId"
>>     
> usage="required"/>
>   
>>     <value name="text" style="attribute"  field="text"
>>     
> usage="required"/>
>   
>>     <collection field="variablesList">
>>       <value name="variables" type="java.lang.String"/>
>>     </collection>
>>   </mapping>
>>   <mapping name="PolicyException"
>>     
> class="com.telenity.util.parlayx.common.PolicyException">
>   
>>     <value name="messageId" style="attribute"  field="messageId"
>>     
> usage="required"/>
>   
>>     <value name="text" style="attribute"  field="text"
>>     
> usage="required"/>
>   
>>     <collection field="variablesList">
>>       <value name="variables" type="java.lang.String"/>
>>     </collection>
>>   </mapping>
>> </binding>
>>   
>>
>>     
> ------------------------------------------------------------------------
>   
>>     
> ------------------------------------------------------------------------
> -
>   
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>>
>>     
> ------------------------------------------------------------------------
>   
>> _______________________________________________
>> jibx-users mailing list
>> jibx-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jibx-users
>>   
>>     
>
> ------------------------------------------------------------------------
> -
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>   

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to