Pessoal,
Estou com um problema e fazer dias que pesquiso e não encontro a resposta. Estou consumindo um WebService feito em .NET usando o Jquery. O problema que o retorno deste Web Service esta vindo com um cabeçalho em XML.
A Saída esta sendo esta:
<?xml
version="1.0"
encoding="utf-8"?>
<string
xmlns="http://tempuri.org/">[{"UserID":1,"Name":"Ivan
de Assis Leal","Email":"ivan@kogut.com.br","Role":"Developer"}]</string>
Meu WebService esta da seguinte forma:
[WebService]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class User : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
public string GetUsers()
{
var user = new Core.DAL.User();
return user.GetUsers().Filter("UserID=1").ToJson();
}
}
O Retorno deste método GetUsers é
[{"UserID":1,"Name":"Ivan
de Assis Leal","Email":"ivan@kogut.com.br","Role":"Developer"}]
Não entendo porque é inserido este cabeçalho em XML.
O código no cliente é:
$.ajax(
{
cache : false,
type: "Post",
url: 'http://localhost/Services/User.asmx/GetUsers',
dataType: 'jsonp',
data: "{}",
contentType: "application/json; charset=utf-8",
crossDomain: true,
success: function (data) {
var json = $.parseJSON(data);
},
error: function (result) {
alert("Erro: " + result.status + ' ' + result.statusText);
}
});
O WebConfig da Aplicação é este:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="db" connectionString="Server=mysql.ivanleal.com;Database=ivanleal;Uid=ivanleal;Pwd=061297;" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
<httpHandlers>
</httpHandlers>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Se alguém tiver uma luz me orientem, estou faz dias pesquisando e nada.
Obrigado!