Asmx Json Serialization Versus Wcf Json Serialization?
Nov 24, 2011
I have two experimental web services. One is an asmx contained within a .net web application. The other is a WCF service library being invoked from the web application.The asmx basically does everything I need, but I think WCF would be better, except that it doesn't do anything as I would expect after fiddling with the asmx service.For example, the same method behaves differently in each:
' ASMX
<WebMethod(BufferResponse:=True, EnableSession:=False)>
Function Test(aObject as Object) as Object
' object will have been successfully serializaed into a dictionary
I was hoping someone may be able to point me in the right direction in regards to the format of a Json.I've never really worked with Json's and Serialization before so it's all a little new.I need to return a Json from .Net in the following format.[[Date.UTC(2011,12,14,8), 8], [Date.UTC(2011,12,14,9), 1]]
I'm almost there but am struggling with the format of my string, as by default the string is quoted. This is what I have:
My ASMX call is returning Content-Type = text/xml; charset=utf-8 I am using ASP.NET 3.5 and jQuery.Ajax. Have added these things are per numerous suggestions from Stack Overflow. I have done these things
Done this at web.config <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> [Code] .....
But whatever I do, the response header is still of type xml. What part am I missing here?
I am stucking this problem for long time.I am developing an IOS which to throw JSON to web service in order to insert into database.But failed to do it.
I am been stuck on this for 3 days now...I have been accessing the twitter api to pull a user_timeline for a list of users and the json that comes back is impossible to work with. I tried to deserialize it using javascriptserializer and get an error:invalid object passed in , ':' or '}'
Now this is frustrating since I expect the json being returned to be error free. Then I tried json.net and split the posts using string.split and tried to convert each post to Jobject or jarray. for Jarray I get
'unexpected end of content while loading jArray
[Code]...
Now I have formatted the code here and not pasted the whole file but it does look like valid json to me and I do not alter anything after receiving the stream from the twitter api. Can someone please point me in the right direction? I really need to get this stuff parsed?
how to receive and send back json. Hope someone can help me on this. I understand by examples.
On my clientside, I am sending a ajax json string "name":"theName" to the server side and would like the server side to return a string saying "welcome &name ".
I've been using XML serialization for a while, and today I realized something really odd. If I have a new line right after a "dot" (.), when i deserialize, I lose the dot. Has anyone ever had this happen to them? The following is my serialization code:
{"AliasName": "ysiCountryInfo", "DataClass": {"Description":"United States 111","Code":"usa","WriteOffTaxPointAdjustment":0,"IndexationRounding":6}} I would like to deserialize object into below class
I have a JSON response from a web service that I need to be converted to an object then to an array. My response is similar to the one below:
{"status":{"error":"NO","code":"200","description":"none","message":"Request ok"},"geolocation":{"lat":"38.89515","lng":"-77.0310"},"stations":[{"country":"United States","regPrice":"0.00","midPrice":"0.00","prePrice":"0.00","streetAddress":"1401, I St[code]....
I am doing this is VB.NET within a console for now. Basically I am trying to create a simple way to test my API calls and output the information. What I am trying to accomplish is having to loop through the JSON array and list the stations.
How can I convert a JSON string to an array OR a JSON string to XML in VB.NET? I know how to do this in C#, as I have read dozens of articles on it, however, I am unable to figure out how to achieve the same result in VB.NET.
I'm using the System.Web.Script namespace via System.Web.Extensions.dll (from Microsoft).
I'm willing to use an additional DLL file if needed.
I'm sure this has been asked before but I'm not finding quite the information I'm needing so I thought I'd post this.
I've written a PHP script that returns a simple JSON object that looks like this:
{"status":"success","level":"admin"}
I'm doing a standard web request that submits the required data to the script over the internet and that's working fine.
Now, I want to use JSON.NET to pull out the individual variables so I can know what the values of "status" and "level" are. The problem is, I have no idea where to start.
I'm doing this in VB.NET (on the .NET Compact Framework).
I am accessing the facebook api and using the json.net library (newtonsoft.json.net)I declare a Jobject to parse the content and look for the specific elements and get their values. Everything works fine for the first few but then I get this unexplained nullexception error " (Object reference not set to an instance of an object)Now I took a look at the declaration but cannot see how to change it. Dim jobj as JObject = JObject.Parse(responseData) message = jobj("message").tostring
The error occurs at the last line above.I check to see if message is null and then look for the next desired field as follows
[Code]...
This is one example where "message" does not appear in the first few lines but appears later. So what I do is look for position of message and description and which ever is first go and get that and if I get an error or the fields do not return anything, I try and parse by regex and even that is not working right.
I have to send a request to Webservice and I have a working PHP solution, that I have to translate in VB.net
Here's the code working in PHP
//fill in the details of the contacts.userId is obtained from loginResult. $contactData = array('lastname'=>'Valiant', 'assigned_user_id'=>$userId); //encode the object in JSON format to communicate with the server.
[code]....
Naturally I imported a reference to a Json library and Imported (Imports Newtonsoft.Json)?
Why is XMLSession.FileList.Count always 0. I hypothesize it has something to do with the declaration above it but I am not sure what is wrong with it. Maybe it can't accept a path, if not, how can I do it?
I've been serialising and deserialising .net objects using the XmlSerializer class without problem, however we now need somebody else to look at that data to perform some analysis on it.In order to help with that we've produced an XSD based on our class like so:
Bizarly, the XML produced does not adhere to the XSD generated from the same class.My question then is, is there a way of telling the XmlSerializer to serialize the object based on a given XSD? As an aside, I've looked at other ways of fixing this: I've tried re-generating the classes from the generated XSD - this seemed to have the same problem.
I have a MRU list that keeps on clearing when I close my application. In order to keep this information, I am trying to serialize it to an xml file, however, I can't figure out how to get the list written to this xml file.
Class <Xml.Serialization.XmlRoot(ElementName:="Class_mrulist")> _ Public Class MRULIST
I have a base class ("MyBaseClass") in a project called "BaseFramework" which is included in several solutions within the company. There are several derived class's in various projects throughout the company that inherit from "MyBaseClass". If I then create a List and add derived class's to it, it will not serialize. I realise that if I were attempting to serialize this list, and the base class and derived class were in the same project, I could simply apply the "XmlInclude" attribute to the base class and include all of the derived class's. This is however not possible across projects, because that would require a circular dependency.
I am attempting to solve the well known problem of automatically generated serialization assemblies in VS 2010, both VB.NET and C#. The "Generate Serialization Assemblies" option in project settings does nothing for non-web projects (see [URL]). Thus the calls to serializers generate file i/o exceptions that are very unfortunate, and for which there is no cure. The method suggested above does not appear to work with VS2010 and SGEN still runs with /proxytypes enabled.
DataContract XML serialization and XML attributes which is most interesting I have attempted to directly convert it to VB.NET, but it does not seem to give me the right results. All I get is the root element with no attributes:
<ServiceContract()> <AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> <ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerCall)> Public Class Service1
I am creating a new windows program and I have used XML serialization to save the contents of my text boxes but when I try to open that file in the new application, no data is transferred. The code acts like it does everything fine and does not give me any errors, it just doesn't input the text back into the program.
what the relation between Serialization and encrypting files, i wanna know that and i wanna a lessons for serialization and i want to ask about this code in VB6 if we can convert it to VB.net 2008
Dim a As String * 10 Dim b As String * 10 Dim c As String * 10
I am new at this. Im trying to serialize a panel and its contents in vb. The controls are added at runtime. I have tried adding to a arraylist but it didnt work
I've been cloning my objects using serialization for awhile, and typically its been quick, at least for my purposes. After a series of updates to these objects, however, now the serialization process is much slower. Trial-and-error has so far failed to pinpoint the cause. Some of the added elements to my object are:
1.binding lists
2. an inherited dictionary class
3. more internal references (the object is actually group of nested objects, and these internal objects have more references to each other than before)
I have been careful to avoid/eliminate references to external elements when cloning, as that can lead to a cascade of extra cloning. So I think the problem is with the object structure itself. This is my serialization routine:
Friend Function CloneObj(ByVal obj As Object) As Object If Not obj.GetType.IsSerializable Then Throw New Exception("Object not serializable") Dim bf As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter