English 中文(简体)
Documenting POST parameters with WADL
原标题:

Looking at the current version of the WADL proposal, I couldn t quite figure out how to document POST request parameters (with application/x-www-form-urlencoded encoding).

I ve seen something like this in the wild:

<resource path="/path1">
<!-- default is mediaType="application/x-www-form-urlencoded" -->
    <method name="POST">
        <request>
            <name="param1" style="query"/>
        </request>
    </method>
</resource>

However, for a <param style="query"> used as a child of <request>, the spec describes it as:

Specifies a URI query parameter represented according to the rules for the query component media type specified by the queryType attribute.

The "URI query" bit threw me off since, to me, it suggests parameters being appended to the URI instead of being included in the body.

On the other hand, for a <param style="query"> used as a child of <representation>, the spec has:

Specifies a component of the representation as a name value pair formatted according to the rules of the media type. Typically used with media type application/x-www-form-urlencoded or multipart/form-data .

Do I have to use a <representation> element to explicitly document parameters that will be send in encoding as part of a POST body?

<resource path="/path1">
    <method name="POST">
        <request>
            <representation mediaType="application/x-www-form-urlencoded">
                <name="param1" style="query"/>
            </representation>
        </request>
    </method>
</resource>

This looks like an overkill. I m assuming I should be able to use the former, even though the spec makes mention of "URI query".

最佳回答

Now I see that I actually should be using the latter form. Even if it looks like an overkill for simply documenting some POST parameters, it s better to explicitly document the fact that the parameters are part of the body == representation.

3rd party edit

The latter one does probably mean this one

<resource path="/path1">
    <method name="POST">
        <request>
            <representation mediaType="application/x-www-form-urlencoded">
                <name="param1" style="query"/>
            </representation>
        </request>
    </method>
</resource>
问题回答

暂无回答




相关问题
IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

ASP.net web services

I am using a web service which sets the Thread.CurrentPrincipal object while logging in and soon later when another webmethod of the same web service accesses Thread.CurrentPrincipal, its different/...

Unity Container Disposing and XML Web Service

I am registering some wrapers over un-managed objects in container. How can I dispose of them at the end of the container s lifetime? Please bear in mind I have an XML Web service.

SharePoint : web service permission error

I have a sharepoint site, and I am calling a standard sharepoint web service. I create the web service request like this : wsDws.Url = this.SiteAddress + @"/_vti_bin/Dws.asmx"; When I use ...

热门标签