问题
I have one method "CreateAccount" as mentioned below
[OperationContract]
[WebInvoke(UriTemplate = "CreateAccount", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public CreateAccountServiceResponse CreateAccount(AuthenticateApplication Application, ApplicationCustomer Customer, CustomerService Service, Option Options)
{
// Some Implementation
}
If I am using
BodyStyle = WebMessageBodyStyle.Wrapped
then I am not able to find Request/Response parameters in browser. Instead it is showing like
Message direction Format Body
Request Unknown Cannot infer schema. The Request body is wrapped.
Response Unknown Cannot infer schema. The Response body is wrapped

Can someone provide solution to this so that I can able to find request/response format.
回答1:
Hosting it on IIS instead of using visual studio in-build server did the trick for me.
回答2:
If you can wrap all of your inputs into a transport class, then you can remove the BodyStyle
attribute, and everything will show up nicely.
ex.
public class CreateAccountServiceRequest {
public AuthenticateApplication Application { get; set; }
public ApplicationCustomer Customer { get; set; }
public CustomerService Service { get; set; }
public Option Options { get; set; }
}
[OperationContract]
[WebInvoke(UriTemplate = "CreateAccount", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
public CreateAccountServiceResponse CreateAccount(CreateAccountServiceRequest request)
{
// you can even reuse the existing method, as long as you don't expose it or change the UriTemplate so there's no conflict
return CreateAccount(request.Application, request.Customer, request...
}
来源:https://stackoverflow.com/questions/24691444/wcf-rest-by-using-bodystyle-webmessagebodystyle-wrapped-i-am-not-able-to