0

Azure WCF サービスを作成しました。RESTful 要求を処理したいと考えています。そのうちの 1 つはパラメータとして IList リストを必要としますが、それを機能させることができず、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

where the ilistcontent.json is: ["egy","ketto","harom","negy"]

thank you for any help!

4

1 に答える 1

1

JSON は{"valami": ["egy", "ketto", "harom", "negy"]}.

于 2012-05-11T06:44:13.410 に答える