View Full Version : WCF json problems

8 May 2012, 10:18 PM
I have built a WCF web service
or http://nzrabwcfservice.nzrab.org.nz/ShipperService.svc/json/?s=test&ab=ab&sdfd
it returns


Which looks like it should work to me but I cant get a json p store to open it. As far as I can see in the browser and using fiddler the out put formatting is similar to twitters feed (http://api.twitter.com/1/statuses/user_timeline.json?screen_name=microsoft&include_rts=1) which works perfectly.

Please help

9 May 2012, 3:59 PM
Heres my code

<?xml version="1.0"?>
<compilation debug="true" targetFramework="4.0">
<add assembly="System.Security, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Entity.Design, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<buildProviders><add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" /></buildProviders></compilation>
<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
<behavior name="web">
<webHttp />
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<modules runAllManagedModulesForAllRequests="true" />


Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Text

Namespace RestService
Public Class RestServiceImpl
Implements IRestServiceImpl

Public Function XMLData(search As String) As List(Of Architect) _
Implements IRestServiceImpl.XMLData

Return ArchitectFromSearch(search)
End Function

Public Function JSONData(search As String) As List(Of Architect) _
Implements IRestServiceImpl.JSONData

Return ArchitectFromSearch(search)
End Function
Public Function JSONData2(search As String) As List(Of Architect) _
Implements IRestServiceImpl.JSONData2
Return ArchitectFromSearch(search)
End Function
Public Function ArchitectFromSearch(search As String) As List(Of Architect)

Dim Archis As New List(Of Architect)
Dim RATableAdapter As New RabTableAdapters.ArchitectsTableAdapter
Dim ta As Rab.ArchitectsDataTable = RATableAdapter.Search(search)
Dim tr As Rab.ArchitectsRow
For Each tr In ta
Dim Archi As New Architect
Archi.FirstName = tr.FirstName
Archi.LastName = tr.LastName
Return Archis
End Function

End Class
End Namespace


Imports System.ServiceModel
Imports System.Runtime.Serialization
Imports System.ServiceModel.Web

Namespace RestService
<ServiceContract()> _
Public Interface IRestServiceImpl

<OperationContract()> _
<WebInvoke(Method:="*", _
RequestFormat:=WebMessageFormat.Json, _
ResponseFormat:=WebMessageFormat.Json, _
BodyStyle:=WebMessageBodyStyle.Bare, _
UriTemplate:="json/{search}/*")> _
Function JSONData(ByVal search As String) As List(Of Architect)

<OperationContract()> _
<WebInvoke(Method:="*", _
RequestFormat:=WebMessageFormat.Json, _
ResponseFormat:=WebMessageFormat.Json, _
BodyStyle:=WebMessageBodyStyle.Bare, _
UriTemplate:="json/?s={search}")> _
Function JSONData2(ByVal search As String) As List(Of Architect)

<OperationContract()> _
<WebInvoke(Method:="GET", _
ResponseFormat:=WebMessageFormat.Xml, _
BodyStyle:=WebMessageBodyStyle.Wrapped, _
UriTemplate:="xml/{search}")> _
Function XMLData(ByVal search As String) As List(Of Architect)

'<OperationContract()> _
'Sub SaveShipper(ByVal shipper As Shipper)

End Interface
<DataContract()> _
Public Class Architect
<DataMember()> _
Public Property FirstName As String

<DataMember()> _
Public Property LastName As String

End Class
End Namespace

9 May 2012, 4:48 PM
this is interesting and very strange
if I copy the twitter feed data from
which works fine and create a file

I have the same problem