2012-05-11 51 views
0

我創建了一個Azure WCF服務,並且我想提供RESTful請求。其中一個需要一個IList列表作爲參數,但是我不能讓它變成wirk,我不知道我是否使用curl錯誤或者定義了錯誤的服務。我給你的代碼:通過curl傳遞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是: 「埃及」, 「ketto」, 「H芳族」, 「negy」]

感謝您的幫助!

回答

1

我相信(只是從我在網上看到的例子)JSON應該是{"valami": ["egy", "ketto", "harom", "negy"]}

+0

你說得對!非常感謝你! –

相關問題