Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> ASP.NET AJAX XML Serialization Format with LLBLGen Pro 2.5
 

Pages: 1
LLBLGen Pro Runtime Framework
ASP.NET AJAX XML Serialization Format with LLBLGen Pro 2.5
Page:1/1 

  Print all messages in this thread  
Poster Message
mshe
User



Location:
Markham, Canada
Joined on:
02-Feb-2006 23:31:34
Posted:
167 posts
# Posted on: 21-Sep-2008 05:41:23.  
Hi all,

My adapter entities are having issues being serialized by ASP.NET's JSON serializer. I read Fran's suggestion to enable XML serialization instead.

I enabled XML serialization using the ScriptMethod attribute, however, I noticed the XML being generated is Compact25 format.

The ASP.NET's AJAX javascript does not seem to deserialize the XML correctly ... and I get an XML document.

Is there a way to set LLBLGen to create Verbose XML, or more "standard" XML that might be properly parsed by ASP.NET AJAX?

Or am I misinterpreting how to get around the "circular reference issue" with JSON/LLBLGen?
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8088 posts
# Posted on: 21-Sep-2008 20:27:41.  
- LLBLGen Pro version?
- Net Framework?
- How are you sending and receiving entities (WS, WCF, ...)?
- Did you read this already?


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
mshe
User



Location:
Markham, Canada
Joined on:
02-Feb-2006 23:31:34
Posted:
167 posts
# Posted on: 21-Sep-2008 21:11:30.  
daelmo wrote:
- LLBLGen Pro version?
- Net Framework?
- How are you sending and receiving entities (WS, WCF, ...)?
- Did you read this already?


Yup, read that already.

LLBLGen Pro v2.5
Adapter Framework
ASP.NET 3.5 with PageMethods

It seems when I use ScriptMethod(ResponseFormat:=XML) it outputs Compact25 XML. Is there a way I can control the output format?
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14531 posts
# Posted on: 22-Sep-2008 10:44:47.  
Please check these links:
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12057

And Josh Wright provides a sample here (check the attachement in his last pot):
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12426

And that's him blogging about it:
http://www.readingwright.com/Post/Show/LLBLGen-to-JSon


  Top
mshe
User



Location:
Markham, Canada
Joined on:
02-Feb-2006 23:31:34
Posted:
167 posts
# Posted on: 22-Sep-2008 14:26:59.  
The blog entry looks very interesting... thank you!
  Top
GabeNodland
User



Location:
Kansas City, MO USA
Joined on:
31-Dec-2004 05:20:39
Posted:
65 posts
# Posted on: 28-Sep-2009 20:51:22.  
I just found this thread while looking for a solution for this problem and wanted to add a solution I found in case someone else is searching for an answer too.

I am using .net 3.5 with VB I was was trying to return an entity from a webmethod in a web service, and was getting an error when it was trying to serialize to json.

I tried converting it to a json string and returning it, using System.Web.Script.Serialization.JavaScriptSerializer, which worked,
but the client just got the json string as a string, and i wanted the results to be an object.


I would have tried Josh's stuff from his blog however i didn't want to convert all of his code to vb, it wasn't immediately clear to me how it worked since it returned a string, not sure if it would be Content-Type: application/json on the client side or just a string, like my other attempts. One of the comments on his blog from "NATHAN" pointed me to my solution.

So I changed my return type from Entity to Object and returned an anonymous type with just the fields i wanted.

I usually don't like anything that returns an Object but since it is only being called by JS i think this should be acceptable since it will be an object on the client side.

Code:


    <WebMethod()> _
    Public Function GetPortalItem(ByVal portalItemId As Integer) As Object
        Dim item = PortalItemManager.FetchByPortalItemID(portalItemId)

        'hack to return an anon type via json with just the data we want
        Return New With {.Title = item.Title, .PortalItemID = item.PortalItemId}

    End Function



I just let the magic of asp.net convert it for me to an object or actually a json string, and since it is doing the work it also knows to set the content type to json too. On the client side it is a javascript Object ready to use.


Gabe


  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8088 posts
# Posted on: 29-Sep-2009 02:58:40.  
Thanks for sharing Gabe.
David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.