0

My web service now looks like this:

        [WebInvoke(UriTemplate = "/GetAllAreaNotes", Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        [OperationContract, CorsEnabled]
        [Description("Request to get all area note")]
        AreaNote[] GetAllAreaNotes();

        [WebInvoke(UriTemplate = "/GetAreaNotesByIDs", Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        [OperationContract, CorsEnabled]
        [Description("Request to get area notes by IDs")]
        AreaNote[] GetAreaNotesByIDs();

The /GetAllAreaNotes is already working. /GetAreaNotesByIDs should be similar, but I'm not sure how to pass a string array in this web service. Here's my questions:

  1. If this is still a Get request, it possible to pass string arrays as part of the URL?
  2. Or, I should make it a POST request instead?
0

1 Answer 1

1

We can’t pass the string array as part of the URL. If you want to pass parameters through the URL, the parameter type can only be a string.

The solution is to use the POST method:

    [WebInvoke(UriTemplate = "/GetAllAreaNotes", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    string[] GetAllAreaNotes(string[] test);

We can enable the help document in WCF:

           <endpointBehaviors>
                <behavior name="ESEndPointBehavior">
                    <webHttp helpEnabled="true"/>
                </behavior>
            </endpointBehaviors>

enter image description here

In the help document, we can see the request format and response format of the service.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.