0

一部の XML を適切なオブジェクト構造に逆シリアル化するのに問題があります。私が呼び出すReadObject(stream)DataContractSerializer、空の配列が返されます。エラーはなく、null ではなく、空の配列です。

物語

私はサードパーティのサービスを使用しており、彼らは wsdl を提供しています。wsdl をサービス参照としてプロジェクトに追加しました。このサービスへの呼び出しに成功し、.Net によって適切に逆シリアル化された応答を受け取りました。したがって、応答を逆シリアル化できることはわかっています。

サービスを 1 回呼び出して、初期データを取得します。次に、サードパーティがそのデータを更新すると、サービスから返された同じ応答 XML を使用して MVC URL に POST します。Request.InputStream から XML をデシリアライズしようとすると、空の配列が得られます。

検索して検索しましたが、完全に空白になっているため、適切な場所ではないようです。

あなたが提供できる方向性を本当に感謝します。

プレイ中のコードとファイルは次のとおりです。

私のデシリアライゼーション コード- かなり単純なものですね。updatedData問題のヌル配列です。

    var dcs = new DataContractSerializer(typeof(IEnumerable<Account1>),
        "ListOfIrstAccountBrandAccountResponseIo",
        "http://www.siebel.com/xml/IRST%20Account%20Brand%20Account%20Response%20IO");

    var updatedData = (IEnumerable<Account1>)dcs.ReadObject(stream);

    return updatedData;

XML - データはサニタイズされていますが、この例では重要ではありません。

<ListOfIrstAccountBrandAccountResponseIo xmlns="http://www.siebel.com/xml/IRST%20Account%20Brand%20Account%20Response%20IO">
    <Account>
        <AccountStatus>Active</AccountStatus>
        <IRSTAccoutSectorNum>xxxxx</IRSTAccoutSectorNum>
        <MainFaxNumber>xxxxx</MainFaxNumber>
        <MainPhoneNumber>xxxxx</MainPhoneNumber>
        <Name>xxxxx</Name>
        <ParentAccountId></ParentAccountId>
        <ParentAccountName></ParentAccountName>
        <AccountRowId>xxxxx</AccountRowId>
        <ListOfCutAddress>
            <CutAddress>
                <City>xxxxx</City>
                <Country>xxxxx</Country>
                <County>xxxxx</County>
                <PostalCode>xxxxx</PostalCode>
                <PrimaryAddressFlg>x</PrimaryAddressFlg>
                <State>xx</State>
                <StreetAddress>xxxxx</StreetAddress>
                <StreetAddress2></StreetAddress2>
            </CutAddress>
        </ListOfCutAddress>
        <ListOfIrstBrandAccount>
            <IrstBrandAccount>
                <IRSTBrand>xxxxx</IRSTBrand>
                <IRSTBrandAccountNumber>xxxxx</IRSTBrandAccountNumber>
                <IRSTSIC>xx</IRSTSIC>
                <Name>xxxxx</Name>
            </IrstBrandAccount>
            <IrstBrandAccount>
                <IRSTBrand>xxxxx</IRSTBrand>
                <IRSTBrandAccountNumber>xxxxx</IRSTBrandAccountNumber>
                <IRSTSIC>xx</IRSTSIC>
                <Name>xxxxx</Name>
            </IrstBrandAccount>
            <IrstBrandAccount>
                <IRSTBrand>xxxxx</IRSTBrand>
                <IRSTBrandAccountNumber>xxxxx</IRSTBrandAccountNumber>
                <IRSTSIC>xx</IRSTSIC>
                <Name>xxxxx</Name>
            </IrstBrandAccount>
        </ListOfIrstBrandAccount>
        <ListOfInternalDivision>
            <InternalDivision>
                <Organization>xxxxx</Organization>
            </InternalDivision>
            <InternalDivision>
                <Organization>xxxxx</Organization>
            </InternalDivision>
        </ListOfInternalDivision>
        <ListOfServiceAgreement>
            <ServiceAgreement>
                <AccountId>xxxxx</AccountId>
                <AgreementId>xxxxx</AgreementId>
                <AgreementNumber>xxxxx</AgreementNumber>
                <AgreementStatus>xxxxx</AgreementStatus>
                <ListOfFsAgreementItem>
                    <FsAgreementItem>
                        <AgreementId>xxxxx</AgreementId>
                        <BPTier1>xx</BPTier1>
                        <BPTier2>xx</BPTier2>
                        <IRSTBuyingProgram>xxxxx</IRSTBuyingProgram>
                        <Product>xxxxx</Product>
                        <ProductId>xxxxx</ProductId>
                    </FsAgreementItem>
                    <FsAgreementItem>
                        <AgreementId>xxxxx</AgreementId>
                        <BPTier1>xx</BPTier1>
                        <BPTier2>xx</BPTier2>
                        <IRSTBuyingProgram>xxxxx</IRSTBuyingProgram>
                        <Product>xxxxx</Product>
                        <ProductId>xxxxx</ProductId>
                    </FsAgreementItem>
                    <FsAgreementItem>
                        <AgreementId>xxxxx</AgreementId>
                        <BPTier1>xx</BPTier1>
                        <BPTier2>xx</BPTier2>
                        <IRSTBuyingProgram>xxxxx</IRSTBuyingProgram>
                        <Product>xxxxx</Product>
                        <ProductId>xxxxx</ProductId>
                    </FsAgreementItem>
                    <FsAgreementItem>
                        <AgreementId>xxxxx</AgreementId>
                        <BPTier1>xx</BPTier1>
                        <BPTier2>xx</BPTier2>
                        <IRSTBuyingProgram>xxxxx</IRSTBuyingProgram>
                        <Product>xxxxx</Product>
                        <ProductId>xxxxx</ProductId>
                    </FsAgreementItem>
                    <FsAgreementItem>
                        <AgreementId>xxxxx</AgreementId>
                        <BPTier1>xx</BPTier1>
                        <BPTier2>xx</BPTier2>
                        <IRSTBuyingProgram>xxxxx</IRSTBuyingProgram>
                        <Product>xxxxx</Product>
                        <ProductId>xxxxx</ProductId>
                    </FsAgreementItem>
                </ListOfFsAgreementItem>
            </ServiceAgreement>
        </ListOfServiceAgreement>
    </Account>
</ListOfIrstAccountBrandAccountResponseIo>

wsdl - ファイルからエンドポイントの IP アドレスを削除しました。これはパブリック サービスではありませんが、このシナリオをテストするためにサービスを呼び出す必要はありません。

<?xml version="1.0" encoding="UTF-8"?><definitions
 xmlns="http://schemas.xmlsoap.org/wsdl/"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:xsdLocal1="http://www.siebel.com/xml/IRST%20Account%20Address%20Query%20Request%20IO"
 targetNamespace="http://siebel.com/CustomUI"
 xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:xsdLocal2="http://www.siebel.com/xml/IRST%20Account%20Brand%20Account%20Response%20IO"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:tns="http://siebel.com/CustomUI"
><types
><xsd:schema
 elementFormDefault="qualified"
 attributeFormDefault="unqualified"
 targetNamespace="http://www.siebel.com/xml/IRST%20Account%20Brand%20Account%20Response%20IO"
 xmlns:xsdLocal2="http://www.siebel.com/xml/IRST%20Account%20Brand%20Account%20Response%20IO"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
><xsd:annotation
><xsd:documentation
>Copyright (C) 2001-2004 Siebel Systems, Inc. All rights reserved. Siebel XSD Generation</xsd:documentation
></xsd:annotation
><xsd:element
 name="ListOfIrstAccountBrandAccountResponseIo"
 type="xsdLocal2:ListOfIrstAccountBrandAccountResponseIo"
></xsd:element
><xsd:complexType
 name="ListOfIrstAccountBrandAccountResponseIoTopElmt"
><xsd:sequence
><xsd:element
 name="ListOfIrstAccountBrandAccountResponseIo"
 maxOccurs="1"
 minOccurs="1"
 type="xsdLocal2:ListOfIrstAccountBrandAccountResponseIo"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="ListOfIrstAccountBrandAccountResponseIo"
><xsd:sequence
><xsd:element
 name="Account"
 maxOccurs="unbounded"
 minOccurs="0"
 type="xsdLocal2:Account"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="Account"
><xsd:sequence
><xsd:element
 name="Id"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="AccountStatus"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="IRSTAccoutSectorNum"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="MainFaxNumber"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="MainPhoneNumber"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="Name"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="ParentAccountId"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="ParentAccountName"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="AccountRowId"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="ListOfCutAddress"
 maxOccurs="1"
 minOccurs="0"
 type="xsdLocal2:ListOfCutAddress"
></xsd:element
><xsd:element
 name="ListOfIrstBrandAccount"
 maxOccurs="1"
 minOccurs="0"
 type="xsdLocal2:ListOfIrstBrandAccount"
></xsd:element
><xsd:element
 name="ListOfInternalDivision"
 maxOccurs="1"
 minOccurs="0"
 type="xsdLocal2:ListOfInternalDivision"
></xsd:element
><xsd:element
 name="ListOfServiceAgreement"
 maxOccurs="1"
 minOccurs="0"
 type="xsdLocal2:ListOfServiceAgreement"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="ListOfCutAddress"
><xsd:sequence
><xsd:element
 name="CutAddress"
 maxOccurs="unbounded"
 minOccurs="0"
 type="xsdLocal2:CutAddress"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="CutAddress"
><xsd:sequence
><xsd:element
 name="City"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="Country"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="County"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="PostalCode"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="PrimaryAddressFlg"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="State"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="StreetAddress"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="StreetAddress2"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="ListOfIrstBrandAccount"
><xsd:sequence
><xsd:element
 name="IrstBrandAccount"
 maxOccurs="unbounded"
 minOccurs="0"
 type="xsdLocal2:IrstBrandAccount"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="IrstBrandAccount"
><xsd:sequence
><xsd:element
 name="Id"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="IRSTBrand"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="IRSTBrandAccountNumber"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="IRSTSIC"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="Name"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="ListOfInternalDivision"
><xsd:sequence
><xsd:element
 name="InternalDivision"
 maxOccurs="unbounded"
 minOccurs="0"
 type="xsdLocal2:InternalDivision"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="InternalDivision"
><xsd:sequence
><xsd:element
 name="Organization"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="ListOfServiceAgreement"
><xsd:sequence
><xsd:element
 name="ServiceAgreement"
 maxOccurs="unbounded"
 minOccurs="0"
 type="xsdLocal2:ServiceAgreement"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="ServiceAgreement"
><xsd:sequence
><xsd:element
 name="AccountId"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="AgreementId"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="AgreementNumber"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="AgreementStatus"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="ListOfFsAgreementItem"
 maxOccurs="1"
 minOccurs="0"
 type="xsdLocal2:ListOfFsAgreementItem"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="ListOfFsAgreementItem"
><xsd:sequence
><xsd:element
 name="FsAgreementItem"
 maxOccurs="unbounded"
 minOccurs="0"
 type="xsdLocal2:FsAgreementItem"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="FsAgreementItem"
><xsd:sequence
><xsd:element
 name="Id"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="AgreementId"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="BPTier1"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="BPTier2"
 maxOccurs="1"
 minOccurs="1"
 type="xsd:string"
></xsd:element
><xsd:element
 name="IRSTBuyingProgram"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="Product"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
><xsd:element
 name="ProductId"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
></xsd:sequence
></xsd:complexType
></xsd:schema
><xsd:schema
 elementFormDefault="qualified"
 attributeFormDefault="unqualified"
 targetNamespace="http://siebel.com/CustomUI"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
><xsd:import
 namespace="http://www.siebel.com/xml/IRST%20Account%20Brand%20Account%20Response%20IO"
></xsd:import
><xsd:import
 namespace="http://www.siebel.com/xml/IRST%20Account%20Address%20Query%20Request%20IO"
></xsd:import
><xsd:element
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Input"
><xsd:complexType
><xsd:sequence
><xsd:element
 ref="xsdLocal1:ListOfIrstAccountAddressQueryRequestIo"
></xsd:element
></xsd:sequence
></xsd:complexType
></xsd:element
><xsd:element
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Output"
><xsd:complexType
><xsd:sequence
><xsd:element
 ref="xsdLocal2:ListOfIrstAccountBrandAccountResponseIo"
></xsd:element
><xsd:element
 name="Error_spcCode"
 type="xsd:string"
></xsd:element
><xsd:element
 name="Error_spcMessage"
 type="xsd:string"
></xsd:element
></xsd:sequence
></xsd:complexType
></xsd:element
></xsd:schema
><xsd:schema
 elementFormDefault="qualified"
 attributeFormDefault="unqualified"
 xmlns:xsdLocal1="http://www.siebel.com/xml/IRST%20Account%20Address%20Query%20Request%20IO"
 targetNamespace="http://www.siebel.com/xml/IRST%20Account%20Address%20Query%20Request%20IO"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
><xsd:annotation
><xsd:documentation
>Copyright (C) 2001-2004 Siebel Systems, Inc. All rights reserved. Siebel XSD Generation</xsd:documentation
></xsd:annotation
><xsd:element
 name="ListOfIrstAccountAddressQueryRequestIo"
 type="xsdLocal1:ListOfIrstAccountAddressQueryRequestIo"
></xsd:element
><xsd:complexType
 name="ListOfIrstAccountAddressQueryRequestIoTopElmt"
><xsd:sequence
><xsd:element
 name="ListOfIrstAccountAddressQueryRequestIo"
 maxOccurs="1"
 minOccurs="1"
 type="xsdLocal1:ListOfIrstAccountAddressQueryRequestIo"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="ListOfIrstAccountAddressQueryRequestIo"
><xsd:sequence
><xsd:element
 name="Account"
 maxOccurs="unbounded"
 minOccurs="0"
 type="xsdLocal1:Account"
></xsd:element
></xsd:sequence
></xsd:complexType
><xsd:complexType
 name="Account"
><xsd:sequence
><xsd:element
 name="AccountRowId"
 maxOccurs="1"
 minOccurs="0"
 type="xsd:string"
></xsd:element
></xsd:sequence
></xsd:complexType
></xsd:schema
></types
><message
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Input"
><part
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Input"
 element="tns:IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Input"
></part
></message
><message
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Output"
><part
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Output"
 element="tns:IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Output"
></part
></message
><portType
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version"
><operation
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version"
><input
 message="tns:IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Input"
></input
><output
 message="tns:IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version_Output"
></output
></operation
></portType
><binding
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version"
 type="tns:IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version"
><soap:binding
 transport="http://schemas.xmlsoap.org/soap/http"
 style="document"
></soap:binding
><operation
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version"
><soap:operation
 soapAction="document/http://siebel.com/CustomUI:IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version"
></soap:operation
><input
><soap:body
 use="literal"
></soap:body
></input
><output
><soap:body
 use="literal"
></soap:body
></output
></operation
></binding
><service
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version"
><port
 binding="tns:IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version"
 name="IRST_spcQuery_spcAccount_spcAnd_spcBrand_spcAccnt_Version"
><soap:address
 location="http://xx.xx.xx.xx/path/to/service"
></soap:address
></port
></service
></definitions
>
4

1 に答える 1

0

間違ったシリアライザーを使用してデシリアライズしようとしていたようです。サードパーティ サービスの wsdl の以前のエディションは、DataContractSerializer. 彼らが実装した変更は明らかに互換性がなく、私には知られていない使用DataContractSerializersvcutil.exe切り替えられXmlSerializerました。

逆シリアル化に使用するように切り替えたところ、XmlSerializerようやく機能しています。

于 2012-12-02T23:05:04.937 に答える