2012-05-11 14 views
0

Azure WCFサービスを作成しましたが、RESTfulな要求に対応したいと思います。そのうちの1つはIListリストをパラメータとして必要としますが、私はそれをWirkにすることはできません。カールを間違って使うのか、誤ったサービスを定義したのか分かりません。私はあなたのコードを与える:IList <>をカール経由でパラメータとして渡す

インタフェースクラス:

[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.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"、 "ハーロム"、 "がnegy"]

は、任意の助けをありがとう!

答えて

1

私はJSONが{"valami": ["egy", "ketto", "harom", "negy"]}であるべきであると思っています。

+0

あなたが正しいです!どうもありがとうございました! –

関連する問題