2

自分の管理下にない外部サービスにアクセスする必要があります。したがって、vs2012 を介してサービス参照を追加すると、すべて問題ありません。

soapUI を介してサービスの動作を確認できます。それで、すべて問題ないように見えます。

しかし、以下のようにクライアントを初期化した後、client.InnerChannel およびその他のプロパティがほとんどエラーになっていることに気付きました。(一部のプロパティには以下のようなエラーがあり、一部のプロパティはサービスが障害状態にあると言っています)

SomeService.SomeServiceV1x1Client client = new SomeService.SomeServiceV1x1Client ();

client.InnerChannelの使用を続行すると、次のエラーが発生します。

XmlSerializer attribute System.Xml.Serialization.XmlChoiceIdentifierAttribute is not valid in Items. 
Only XmlElement, XmlArray, XmlArrayItem, XmlAnyAttribute and XmlAnyElement attributes are supported when IsWrapped is true.

短縮版:

との一般的な非互換性の問題はありますかこのタイプの動作を引き起こしているreference.csに影響を与えるwsdlの要素? さらに重要なことは、以下の回避策ではなく、適切な回避策があるかどうかです。ここで問題は(多かれ少なかれ)説明されていますが、この場合はあまり役に立ちません。

長いバージョン:

wsdlを確認すると、次のような部分があります。

 <xsd:complexType name="getCitizenFromLocalDb">
    <xsd:choice minOccurs="1" maxOccurs="1">
      <xsd:sequence>
        <xsd:element minOccurs="1" maxOccurs="1" name="citizenId" type="profileMgmnt:IdType" />
      </xsd:sequence>
      <xsd:sequence>
        <xsd:element minOccurs="0" maxOccurs="1" name="name" type="xsd:string" />
        <xsd:element minOccurs="0" maxOccurs="1" name="surname" type="xsd:string" /> >
        <xsd:element minOccurs="0" maxOccurs="1" name="birthDate" type="xsd:date" /> 
      </xsd:sequence>
    </xsd:choice>
  </xsd:complexType>

References.csを確認すると、

 [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://somwhere.com/SomeService/Service/V4", IncludeInSchema=false)]
public enum ItemsChoiceType {

    [System.Xml.Serialization.XmlEnumAttribute(":birthDate")]
    birthDate,
    [System.Xml.Serialization.XmlEnumAttribute(":citizenId")]
    citizenId,
    [System.Xml.Serialization.XmlEnumAttribute(":name")]
    name,
    [System.Xml.Serialization.XmlEnumAttribute(":surname")]
    surname,
}

public partial class getCitizenFromLocalDbRequest {

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute("birthDate", typeof(System.DateTime), Form=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType="date")]
    [System.Xml.Serialization.XmlElementAttribute("citizenId", typeof(long), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlElementAttribute("name", typeof(string), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlElementAttribute("surname", typeof(string), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
    public object[] Items;

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://somewhere.com/SomeService/Service/V4", Order=1)]
    [System.Xml.Serialization.XmlElementAttribute("ItemsElementName")]
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public GeneralServices.SomeService.ItemsChoiceType[] ItemsElementName;

    public getCitizenFromLocalDbRequest() {
    }

    public getCitizenFromLocalDbDbRequest(object[] Items, GeneralServices.SomeService.ItemsChoiceType[] ItemsElementName) {
        this.Items = Items;
        this.ItemsElementName = ItemsElementName;
    }
}

これを解決するために、以下のように getCitizenFromLocalDbRequest を変更し、references.cs から ItemsChoiceType 列挙も削除しました。この種の動作を引き起こす一般的な非互換性の問題はありますか? さらに重要なことに、これよりも適切な回避策はありますか?

public partial class getCitizenFromLocalDbRequest {

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://somewhere.com/SomeService/Service/V4", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public long citizenId;

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://somewhere.com/SomeService/Service/V4", Order=1)]
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string name;

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://somewhere.com/SomeService/Service/V4", Order=2)]
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string surname;

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://somewhere.com/SomeService/Service/V4", Order=3)]
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType="date")]
    public System.DateTime birthDate;


    public getCitizenFromLocalDbRequest() {
    }

    public getCitizenFromLocalDbRequest(long citizenId, string name, string surname,  System.DateTime birthDate) {
        this.citizenId = citizenId;
        this.name = name;
        this.surname = surname;
        this.birthDate = birthDate;
    }
}
4

0 に答える 0