[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jibx-devs
Subject:    Re: [jibx-devs] java.util.map as model  in jibx implementaion
From:       Dennis Sosnoski <dms () sosnoski ! com>
Date:       2011-02-28 3:00:06
Message-ID: 4D6B0FB6.6000601 () sosnoski ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Ayash,

There's no one way of representing maps directly in XML or schema terms.
Depending on the actual data in the map, one form of representation or
another may be appropriate. The best I can suggest is that you use an
array (or List) of key-value pairs to represent the data from the map,
and modify your code to match when using Jibx2Wsdl. So for instance, if
you have a method that returns a map of String to Widget,
"Map<String,Widget> getMap()", create a pair class:

public class StringWidgetPair {
  public String key;
  public Widget value;
  public StringWidgetPair(String key, Widget value) {
    this.key = key;
    this.value = value;
  }
}

and substitute an adapter method "List<StringWIdgetPair> getList()".
This will let you generate an appropriate schema for your XML data.

If you want to use the generated schema and binding with JiBX you can
easily implement the adapter method:

List<StringWidgetPair> getList() {
  Map<String,Widget> map = getMap();
  List<StringWidgetPair> list = new ArrayList<StringWidgetPair>();
  for (String key : map.keySet()) {
    list.add(new StringWidgetPair(key, map.get(key));
  }
  return list;
}

(ignoring any typos).

  - Dennis

Dennis M. Sosnoski
Java SOA and Web Services Consulting <http://www.sosnoski.com/consult.html>
Axis2/CXF/Metro SOA and Web Services Training
<http://www.sosnoski.com/training.html>
Web Services Jump-Start <http://www.sosnoski.com/jumpstart.html>


On 02/16/2011 11:31 PM, Ayash Kant Baral wrote:
> 
> Hi team,
> 
> 
> 
> 
> 
> I am finding problem to convert java to wsdl using jibx2wsdl if any
> model is having java.util.map.
> 
> The exception is  as follows:-
> 
> 
> 
> Exception in thread "main" _java.lang.IllegalStateException_: No way
> to handle type java.util.Map, referenced from
> com.aegon.dot.model.bo.ProposalDetails
> 
> 
> 
> 
> 
> Regards,
> 
> Ayash
> 
> 
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> > > DISCLAIMER::
> -----------------------------------------------------------------------------------------------------------------------
>  
> The contents of this e-mail and any attachment(s) are confidential and
> intended for the named recipient(s) only.
> It shall not attach any liability on the originator or HCL or its
> affiliates. Any views or opinions presented in
> this email are solely those of the author and may not necessarily
> reflect the opinions of HCL or its affiliates.
> Any form of reproduction, dissemination, copying, disclosure,
> modification, distribution and / or publication of
> this message without the prior written consent of the author of this
> e-mail is strictly prohibited. If you have
> received this email in error please delete it and notify the sender
> immediately. Before opening any mail and
> attachments please check them for viruses and defect.
> 
> -----------------------------------------------------------------------------------------------------------------------
>  
> 
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> 
> 
> _______________________________________________
> jibx-devs mailing list
> jibx-devs@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-devs
> 


[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Hi Ayash,<br>
<br>
There's no one way of representing maps directly in XML or schema
terms. Depending on the actual data in the map, one form of
representation or another may be appropriate. The best I can suggest is
that you use an array (or List) of key-value pairs to represent the
data from the map, and modify your code to match when using Jibx2Wsdl.
So for instance, if you have a method that returns a map of String to
Widget, "Map&lt;String,Widget&gt; getMap()", create a pair class:<br>
<br>
public class StringWidgetPair {<br>
&nbsp; public String key;<br>
&nbsp; public Widget value;<br>
&nbsp; public StringWidgetPair(String key, Widget value) {<br>
&nbsp;&nbsp;&nbsp; this.key = key;<br>
&nbsp;&nbsp;&nbsp; this.value = value;<br>
&nbsp; }<br>
}<br>
<br>
and substitute an adapter method "List&lt;StringWIdgetPair&gt;
getList()". This will let you generate an appropriate schema for your
XML data.<br>
<br>
If you want to use the generated schema and binding with JiBX you can
easily implement the adapter method:<br>
<br>
List&lt;StringWidgetPair&gt; getList() {<br>
&nbsp; Map&lt;String,Widget&gt; map = getMap();<br>
&nbsp; List&lt;StringWidgetPair&gt; list = new
ArrayList&lt;StringWidgetPair&gt;();<br>
&nbsp; for (String key : map.keySet()) {<br>
&nbsp;&nbsp;&nbsp; list.add(new StringWidgetPair(key, map.get(key));<br>
&nbsp; }<br>
&nbsp; return list;<br>
}<br>
<br>
(ignoring any typos).<br>
<br>
&nbsp; - Dennis<br>
<br>
<div class="moz-signature">
<p>Dennis M. Sosnoski<br>
<a href="http://www.sosnoski.com/consult.html">Java SOA and Web
Services Consulting</a><br>
<a href="http://www.sosnoski.com/training.html">Axis2/CXF/Metro SOA and
Web Services Training</a><br>
<a href="http://www.sosnoski.com/jumpstart.html">Web Services Jump-Start</a>
</p>
</div>
<br>
On 02/16/2011 11:31 PM, Ayash Kant Baral wrote:
<blockquote
 cite="mid:196713748F6954459B10FE5282699F5F1E621B6AFF@CHN-HCLT-EVS09.HCLT.CORP.HCL.IN"
  type="cite">
  <meta http-equiv="Content-Type"
 content="text/html; charset=ISO-8859-1">
  <meta name="Generator" content="Microsoft Word 12 (filtered medium)">
  <style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
-->
  </style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
  <div class="WordSection1">
  <p class="MsoNormal">Hi team,<o:p></o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal">I am finding problem to convert java to wsdl
using jibx2wsdl if any model is having java.util.map.<o:p></o:p></p>
  <p class="MsoNormal">The exception is&nbsp; as follows:-<o:p></o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;">Exception
in thread "main"
  </span><u><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: \
navy;">java.lang.IllegalStateException</span></u><span  style="font-size: 10pt; \
font-family: &quot;Courier New&quot;; color: red;">: No way to handle type \
java.util.Map, referenced from \
com.aegon.dot.model.bo.ProposalDetails<o:p></o:p></span></p>  <p \
class="MsoNormal"><span  style="font-size: 10pt; font-family: &quot;Courier \
New&quot;; color: red;"><o:p>&nbsp;</o:p></span></p>  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: \
red;"><o:p>&nbsp;</o:p></span></p>  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: \
red;">Regards,<o:p></o:p></span></p>  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: \
red;">Ayash</span><o:p></o:p></p>  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </div>
  <br>
  <hr>
  <font face="Arial" size="1" color="Gray">::DISCLAIMER::<br>
-----------------------------------------------------------------------------------------------------------------------<br>
  <br>
The contents of this e-mail and any attachment(s) are confidential and
intended for the named recipient(s) only.<br>
It shall not attach any liability on the originator or HCL or its
affiliates. Any views or opinions presented in<br>
this email are solely those of the author and may not necessarily
reflect the opinions of HCL or its affiliates.<br>
Any form of reproduction, dissemination, copying, disclosure,
modification, distribution and / or publication of<br>
this message without the prior written consent of the author of this
e-mail is strictly prohibited. If you have<br>
received this email in error please delete it and notify the sender
immediately. Before opening any mail and<br>
attachments please check them for viruses and defect.<br>
  <br>
-----------------------------------------------------------------------------------------------------------------------<br>
  </font>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
<a class="moz-txt-link-freetext" \
href="http://p.sf.net/sfu/intel-dev2devfeb">http://p.sf.net/sfu/intel-dev2devfeb</a></pre>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
jibx-devs mailing list
<a class="moz-txt-link-abbreviated" \
href="mailto:jibx-devs@lists.sourceforge.net">jibx-devs@lists.sourceforge.net</a> <a \
class="moz-txt-link-freetext" \
href="https://lists.sourceforge.net/lists/listinfo/jibx-devs">https://lists.sourceforge.net/lists/listinfo/jibx-devs</a>
  </pre>
</blockquote>
</body>
</html>



------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 

_______________________________________________
jibx-devs mailing list
jibx-devs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-devs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic