Web Service WCF XML output

Asked

Viewed 82 times

0

I’m building a web service using WCF. I created the edmx file, made the connection to the database where I am informing the tables, views and procedures that I want to use and my file. svc is like this:

' This method is called only once to initialize service-wide policies.
Public Shared Sub InitializeService(ByVal config As DataServiceConfiguration)
    ' TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
    ' Examples:
    config.SetEntitySetAccessRule("*", EntitySetRights.All)
    ' config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All)
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3

When I run the application appears in xml the entities I have.

<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom"          xml:base="http://localhost:25415/WcfBarramentoDS.svc/">
<workspace>
<atom:title>Default</atom:title>
<collection href="Produtos">
<atom:title>Produtos</atom:title>
</collection>
<collection href="Ocorrencias">
<atom:title>Ocorrencias</atom:title>
</collection>
<collection href="Colaboradores">
<atom:title>Colaboradores</atom:title>
</collection>
<collection href="Despesas">
<atom:title>Despesas</atom:title>
</collection>
</workspace>
</service>

However, when choosing one as for example '.svc/Products' my return is not in XML.

<?xml version="1.0" encoding="utf-8"?><feed xml:base="http://localhost:25415/Nome.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><id>http://localhost/Nome.svc/ProdutosTI</id><title type="text">Produtos</title><updated>2015-11-09T10:40:57Z</updated><link rel="self" title="ProdutosTI" href="ProdutosTI" /><entry><id>http://localhost/Nome.svc/Produtos(Codigo='01000123',Produto='nomedoproduto')</id><category term="Model.Produtos" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" title="Produtos" href="Produtos(Codigo='01000123',Produto='nomedoproduto')" /><title /><updated>2015-11-09T10:40:57Z</updated><author><name /></author><content type="application/xml"><m:properties><d:Codigo>01000123</d:Codigo><d:Produto>NomedoProduto</d:Produto></m:properties></content></entry>

What do I need to change to get the XML output? And in this case I can only return what is table in my entity. How do I return in XML the result of a view or Procedure?

1 answer

0

Hello,

The format displayed in your example is 'ATOM': https://msdn.microsoft.com/en-us/library/dd541106.aspx

In this other link has everything about odata, version 2, 3 and 4 http://www.odata.org/documentation/

Luiz

Browser other questions tagged

You are not signed in. Login or sign up in order to post.