传递IList<>作为参数通过卷曲

时间:2012-05-11 06:15:15

标签: .net wcf curl azure

我创建了一个Azure WCF服务,我想提供RESTful请求。其中一个需要一个IList列表作为参数,但我不能使它wirk,我不知道我是否使用curl错误或定义服务错误。我给你代码:

接口类:

 [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "generate", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    HttpResponseMessage Generate(IList<string> valami);

service.svc.cs:

public HttpResponseMessage Generate(IList<string> valami)
    {

        HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
    }

的Web.config:

<configuration>
<configSections>
</configSections>
<system.diagnostics>
    <trace>
        <listeners>
            <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
              name="AzureDiagnostics">
                <filter type="" />
            </add>
        </listeners>
    </trace>
</system.diagnostics>
<system.web>
    <compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata httpGetEnabled="true"/>
                <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

这就是我使用curl的方式:

curl.exe -i -X POST http://127.0.0.1:81/PowerpointService.svc/generate -H "Content-Type: application/json" -d @ilistcontent.json

其中ilistcontent.json是:[“egy”,“ketto”,“harom”,“negy”]

谢谢你的帮助!

1 个答案:

答案 0 :(得分:1)

我相信(仅从我在网上看到的例子)JSON应该是{"valami": ["egy", "ketto", "harom", "negy"]}