Это мой WCF контракты:не дозвонились контракт на обслуживание WCF с двумя или более параметров
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "{type}/sports")]
List<SportsList> GetSportsList(string type);
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "{type}/sports/{sport}/championships")]
ChampsCountries GetChampsBySport(string type, string sport);
Когда я пытаюсь вызвать его из моего приложения WPF:
Service1Client client = new Service1Client();
SportsList[] sports = client.GetSportsList("line");
Как вы видите, я я вызываю первый контракт, но он дает ошибку относительно моего второго контракта:
Operation 'GetChampsBySport' of contract 'IService1' specifies multiple request body parameters to be serialized without any wrapper elements. At most one body parameter can be serialized without wrapper elements. Either remove the extra body parameters or set the BodyStyle property on the WebGetAttribute/WebInvokeAttribute to Wrapped
.
Я уже изменил BodyStyle
на Wrapped
и что еще мне делать? Я могу назвать этот контракт из браузера без проблем. Может быть, что-то связано с моей конфигурацией? Это мой WPF приложение конфигурация:
<client>
<endpoint address="http://localhost:1001/Services/Service1.svc" behaviorConfiguration="webBehavior"
binding="webHttpBinding" contract="MainService.IService1" />
</client>
Спасибо, брат, вы спасли мой день! –
В любое время :). Всегда пожалуйста. – firefalcon