I got my webservice to return the text I wanted by instantiating an
HttpContext object and using the .ContentType and .Write methods.  Any
reason not to just stick with that?

On Dec 15, 3:45 am, Chikelue Oji <[email protected]> wrote:
> Hello Jtaylor,
>
> The easiest way I know to implement this is using Jayrock api/library.
> You can get more information by googling Jayrock.
>
> One sacrifice you may have to make is to rewrite and rebuild your webservice 
> using Jayrock's template which I believe is implemented as a custom http 
> handler. They provide a very simple example that will get you up and running 
> quickly and it is not really complicated to use and won't be much work if the 
> web service code you will need to rewrite is not enormous.
>
> I hope this becomes of help to you. Please let us all know if it is.
>
> Cheers.
>
> Chike
>
> ________________________________
>  From: jtaylor <[email protected]>
> To: "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web 
> Services,.NET Remoting" <[email protected]>
> Sent: Thursday, December 15, 2011 5:20 AM
> Subject: [DotNetDevelopment] Re: Return JSON from ASP.NET (VB) webservice
>
> OK, I figured it would be easy to manually serialize the DataTable
> into JSON, and it was.  I exposed the webservice to the consumer, and
> they said it would work fine if it was not encapsulated in XML.  So my
> only issue now is #2 from above.
>
> Thanks
>
> On Dec 13, 7:46 pm, jtaylor <[email protected]> wrote:
>
>
>
>
>
>
>
>
>
> > Fair enough.
>
> > I am trying to serialize the DataTable into a String as JSON.  Here's
> > the code:
>
> >         Using memStream As New MemoryStream
> >             Dim serializer As New
> > DataContractJsonSerializer(lTable.GetType)
> >             serializer.WriteObject(memStream, lTable)
> >             Dim bytes As Byte() = memStream.GetBuffer()
> >             returnValue = Encoding.UTF8.GetString(bytes, 0,
> > bytes.Length).Trim
> >         End Using
>
> > I now have two problems.
> > 1. The String returnValue contains XML, not JSON.
> > 2. My web method appears to be returning the String as an XML document
> > containing a single string value that contains the text of
> > returnValue.
>
> > On Dec 12, 5:36 am, Cerebrus <[email protected]> wrote:
>
> > > IMHO, the return type of the function should be a string. JSON and
> > > XML, they're both just strings.
>
> > > On Dec 10, 8:57 pm, jtaylor <[email protected]> wrote:
>
> > > > #1:
> > > >     <WebMethod()>
> > > >     <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
> > > >     Public Function myWsFunction(ByVal parms As String) As DataTable
>
> > > >         Return CreateDataTable(parms)
> > > >     End Function
>
> > > > #2.  I'm just testing it in VS.
>
> > > > On Dec 5, 7:42 am, Cerebrus <[email protected]> wrote:
>
> > > > > 1. Show us the entire WebMethod.
>
> > > > > 2. Tell us the content type header being sent by the requesting
> > > > > client.
>
> > > > > On Dec 3, 8:40 am, jtaylor <[email protected]> wrote:
>
> > > > > > I have a ASP.NET webservice written in VB using VS2010.  I need it 
> > > > > > to
> > > > > > return JSON but it insists on returning XML.  I set
> > > > > > "<ScriptMethod(ResponseFormat:=ResponseFormat.Json)>" on the 
> > > > > > function,
> > > > > > but it still returns XML.
>
> > > > > > Any suggestions on where to start looking?- Hide quoted text -
>
> > > > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
> Web Services,.NET Remoting" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
> or visit the group website athttp://megasolutions.net

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to