コールアウトからのPOSTをサポートできるIIS7でホストされる単純なHTTPC#RESTful Webサービスを作成する必要があり、POSTデータの形式が適切に処理されていないようです。データメンバー名の要件は、custom-1のようにダッシュが含まれていることです。私の問題は、custom-10以上のデータメンバー名がデータに対してnullを与えるだけであるということです。custom-1からcustom-9までは問題ありません。
誰かが助けてくれるなら、私はそれを感謝します!!!
POSTデータに必要な形式は次のとおりです。
<person-search-request xmlns="someurl">
<person>
<custom-1 />
<custom-2 />
<custom-3 />
<custom-4 />
<custom-5 />
<custom-6 />
<custom-7 />
<custom-8 />
<custom-9 />
<custom-10 />
<custom-11 />
<custom-12 />
<custom-13 />
<custom-14 />
<custom-15 />
<custom-16 />
<custom-17 />
<custom-18 />
<custom-19 />
<custom-20 />
</person>
</person-search-request>
私のWebサービスデータコントラクトは次のようになります。
[CollectionDataContract(Name = "person-search-request", Namespace="")]
public class PersonsRequest : List<Person>
{ }
[CollectionDataContract(Name = "person-search-response", Namespace="")]
public class PersonsResponse : List<Person>
{ }
[DataContract(Name = "person", Namespace = "")]
public class Person
{
public Person()
{
Custom14 = String.Empty;
Custom13 = String.Empty;
Custom15 = String.Empty;
Custom16 = String.Empty;
Custom17 = String.Empty;
Custom18 = String.Empty;
Custom19 = String.Empty;
Custom20 = String.Empty;
Custom7 = String.Empty;
Custom8 = String.Empty;
Custom9 = String.Empty;
Custom1 = String.Empty;
Custom10 = String.Empty;
Custom11 = String.Empty;
Custom12 = String.Empty;
Custom3 = String.Empty;
Custom4 = String.Empty;
Custom5 = String.Empty;
Custom6 = String.Empty;
}
[DataMember(Name = "custom-14")]
public string Custom14 { get; set; }
[DataMember(Name = "custom-7")]
public string Custom7 { get; set; }
[DataMember(Name = "custom-8")]
public string Custom8 { get; set; }
[DataMember(Name = "custom-9")]
public string Custom9 { get; set; }
[DataMember(Name = "custom-13")]
public string Custom13 { get; set; }
[DataMember(Name = "custom-15")]
public string Custom15 { get; set; }
[DataMember(Name = "custom-16")]
public string Custom16 { get; set; }
[DataMember(Name = "custom-17")]
public string Custom17 { get; set; }
[DataMember(Name = "custom-18")]
public string Custom18 { get; set; }
[DataMember(Name = "custom-19")]
public string Custom19 { get; set; }
[DataMember(Name = "custom-20")]
public string Custom20 { get; set; }
[DataMember(Name = "custom-10")]
public string Custom10 { get; set; }
[DataMember(Name = "custom-11")]
public string Custom11 { get; set; }
[DataMember(Name = "custom-12")]
public string Custom12 { get; set; }
[DataMember(Name = "custom-1")]
public string Custom1 { get; set; }
[DataMember(Name = "custom-2")]
public string Custom2 { get; set; }
[DataMember(Name = "custom-3")]
public string Custom3 { get; set; }
[DataMember(Name = "custom-4")]
public string Custom4 { get; set; }
[DataMember(Name = "custom-5")]
public string Custom5 { get; set; }
[DataMember(Name = "custom-6")]
public string Custom6 { get; set; }
/// <summary>
}
私のサービスエンドポイントは次のように設定されています。
[ServiceBehavior(IncludeExceptionDetailInFaults = true), AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed), ServiceContract]
public partial class Service
{
[WebHelp(Comment = "Person POST")]
[WebInvoke(UriTemplate = "person/v1.0/fetch", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml)]
[OperationContract]
public PersonsResponse FetchPerson(PersonsRequest request)
{
....
}
}
投稿データは次のようになります(Fiddlerを使用してテストします)。
<person-search-request>
<person>
<custom-1>1</custom-1>
<custom-2>2</custom-2>
<custom-3>3</custom-3>
<custom-4>4</custom-4>
<custom-5>5</custom-5>
<custom-6>6</custom-6>
<custom-7>7</custom-7>
<custom-8>8</custom-8>
<custom-9>9</custom-9>
<custom-10>10</custom-10>
<custom-11>11</custom-11>
<custom-12>12</custom-12>
<custom-13>13</custom-13>
<custom-14>14</custom-14>
<custom-15 />
<custom-16 />
<custom-17 />
<custom-18 />
<custom-19 />
<custom-20 />
</person>
</person-search-request>
データは、10〜20個のカスタムタグにnullが含まれるエンドポイントに送られます。誰もが理由を知っていますか?:(
これは、メソッドに渡されたリクエストオブジェクトからデバッグしたときに表示されるものです。
Custom1 "1" string
Custom10 null string
Custom11 null string
Custom12 null string
Custom13 null string
Custom14 null string
Custom15 null string
Custom16 null string
Custom17 null string
Custom18 null string
Custom19 null string
Custom2 "2" string
Custom20 null string
Custom3 "3" string
Custom4 "4" string
Custom5 "5" string
Custom6 "6" string
Custom7 "7" string
Custom8 "8" string
Custom9 "9" string