I am trying to serialize a WFS GetFeature request back to XML. I setup 
my code as follows:

Configuration c = new org.geotools.wfs.v1_0.WFSConfiguration();
Encoder e = new Encoder( c );
e.setIndenting(true);
e.encode( object, new QName( c.getXSD().getNamespaceURI(), "GetFeature" 
), System.out );

However, I get the following error:

Caused by: java.lang.ClassCastException: javax.xml.namespace.QName 
cannot be cast to java.lang.String
    at 
org.geotools.wfs.bindings.QueryTypeBinding.getProperty(QueryTypeBinding.java:192)
    at 
org.geotools.xml.impl.GetPropertyExecutor.visit(GetPropertyExecutor.java:91)

It seems like the problem is in the 
org.geotools.wfs.bindings.QueryTypeBinding getProperty function. The XSD 
defines typeName as a QName but the code looks like it expects it to be 
a String:

public Object getProperty(Object object, QName name) throws Exception {
     if ("typeName".equals(name.getLocalPart())) {
         QueryType query = (QueryType) object;
         List typeName = query.getTypeName();
         StringBuilder typeNameList = new StringBuilder();
         if (typeName != null) {
             for (Iterator<String> it = typeName.iterator(); 
it.hasNext();) {
                 typeNameList.append(it.next());
                 if (it.hasNext()) {
                     typeNameList.append(",");
                 }
             }
         }
         return typeNameList.toString();
     } else if ("SortBy".equals(name.getLocalPart())) {
         QueryType query = (QueryType) object;
         List sortBy = query.getSortBy();
         if (sortBy != null && sortBy.size() == 0) {
             return null;
         }
     }

     return super.getProperty(object, name);
}

Am I reading this right? Any ideas?

Thanks, David

-- 

David R Robison
Open Roads Consulting, Inc.
103 Watson Road, Chesapeake, VA 23320
phone: (757) 546-3401
e-mail: [email protected]
web: http://openroadsconsulting.com
blog: http://therobe.blogspot.com
book: http://www.xulonpress.com/bookstore/bookdetail.php?PB_ISBN=9781597816526

This e-mail communication (including any attachments) may contain confidential 
and/or privileged material intended solely for the individual or entity to 
which it is addressed.  If you are not the intended recipient, you should 
immediately stop reading this message and delete it from all computers that it 
resides on. Any unauthorized reading, distribution, copying or other use of 
this communication (or its attachments) is strictly prohibited.  If you have 
received this communication in error, please notify us immediately.  



------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to