Comportamento estranho do WCF
Eu tenho isso quando eu consome um webservice:
A operação 'Login' do contrato 'IServices' especifica vários parâmetros do corpo da solicitação a serem serializados sem nenhum elemento de wrapper. No máximo, um parâmetro de corpo pode ser serializado sem elementos de wrapper. Remova os parâmetros de corpo extras ou defina a propriedade BodyStyle no WebGetAttribute / WebInvokeAttribute como Wrapped.
Eu uso interface parecido com:
namespace DreamServices
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IServices
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "LogIn/{username}/{password}")]
string Login(string username, string password);
[OperationContract]
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "WaletTotalAmount/{userid}")]
double? WaletTotalAmount(string userid);
[OperationContract]
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "UserService/{userid}")]
IList<UserServiceses> UserService(string userid);
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "InsertUpdateWallet/{userid}/{Amount}/{ComissionAmount}")]
void InsertUpdateWallet(string userid, string Amount, string ComissionAmount);
}
}
e eu hospedo, então eu adiciono uma referência web ao meu site e modifico o web.config de tal forma que o será como
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="defaultRest">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1381/PMAHost/Service.svc" binding="webHttpBinding" contract="ServiceReference.IServices" behaviorConfiguration="web"/>
</client>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Alguma idéia de como corrigir esse erro?