Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi.
I made a WCF Service..that return a XML.
Well, Right Now I need that my WCF Service, return a pure JSON Response I mean: without XML headers or Tags

this is my code in service.vb:

VB
' NOTE: You can use the "Rename" command on the context menu to change the class name "Service" in code, svc and config file together.
Imports System.Collections.Generic
Imports System.Linq
Imports System.Runtime.Serialization
Imports System.ServiceModel
Imports System.Text
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web.Script.Serialization
Imports System.ServiceModel.Activation
Imports System.ServiceModel.Web
Imports System.Web.Script.Services


<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class Service
    Implements IService


    <WebInvoke(Method:="POST", ResponseFormat:=WebMessageFormat.Json)> _
    Public Function GetPolicyNuic(ByVal Prefijo As String, ByVal Folio As String, ByVal numVehiculo As String, ByVal TipoPoliza As String) As String Implements IService.GetPolicyNuic
        Dim DatosPoliza As SqlDataReader = Nothing
        Dim oConn As New dBTools()
        Dim oPolizas As Poliza
        oPolizas = New Poliza(Prefijo, Folio, numVehiculo, TipoPoliza)
        Return (New JavaScriptSerializer().Serialize(oPolizas))
    End Function
End Class 


In the IService.svc I have:
VB
<ServiceContract()> _
Public Interface IService

    <OperationContract()> _
    Function GetPolicyNuic(ByVal Prefijo As String, ByVal Folio As String, ByVal numVehiculo As String, ByVal TipoPoliza As String) As String


    ' TODO: Add your service operations here

End Interface





Can someone tell me how I can access to my Functions?

Http://www.mySite.com/wss/WCFService/service.svc/GetPolicyNuic?Prefijo=PBB&Folio=53355&numVehiculo=1&TipoPoliza=A

This is the correct way to access to my Functions??

Thanks Regards.
Posted

1 solution

 
Share this answer
 
Comments
Rene Bustos 14-May-14 12:50pm    
Thanks for the help. let me check the documentation.. Regards
Rene Bustos 14-May-14 12:54pm    
Abhinav. I have already check the documentation...is good ...but. im still have the question about how to access and Response a Pure Json ..without XML format.
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900